Function with sustain in poly~

    Apr 12 2021 | 6:37 am
    Hello lovely Max folks,
    I'm sure some of you have seen this before but after looking at what I assume is anything related to this topic i've still not found a single working version of how to implement sustain using function (not interested in adsr~) inside of poly~.
    I've seen many suggestions about using adsr~ but the idea that function has well (more functionality) is what i'm after. I understand how to use sustain in a mono setting with things like note on/off in tandem with the "next" message but how to get that into a poly~ is beyond me.
    Quick rundown: looking to create a simple FM synth with Fm env and Amp env that function in a standard adsr+ way (play midi note and it makes lovely sharp sounds), but also will be aiming to have a hold/sustain/latch setting that loops wherever function has set those points.
    Would love some assistance on this one!
    FM Poly~ voice
    Main Patcher

    • Apr 16 2021 | 3:17 am
      Well, I don't entirely know how your patch works by looking at it, but I did notice that voices aren't specified when it receives notes. I wonder if you might like just simply having control of which poly~ voice plays. [poly] without the ~ can also handle voice management separately. Perhaps with that, you can create sustains by filtering out voice off messages depending on voice number.
      But I'm not sure this fixes it. Did I miss something?
    • Apr 16 2021 | 4:57 pm
      Yeah poly is definitely an option. I guess my only thing there is that i'm kind of limited in # of voices. Not the end of the world as I could manage all of the enveloping for each voice but was hoping to use poly~ specifically.
    • Apr 16 2021 | 6:53 pm
      Okay after about a week of tinkering I've sorted this out! For anyone interested i've included the patch below! I haven't put this thing through any extensive tests but after playing with it for a while it seems to be stable.
      FM Voice with Function as Envelope including Sustain
      Simple FM Synth
      Happy patching!