Use of sah~ in adsr~ polysynth example, is it really necessary?


    Jan 25 2009 | 1:13 am
    I was looking at the polysynth example in the adsr~ help file. The second outlet is used to drive a sah~ that only lets a new frequency be set when an envelope starts attacking. That sounds reasonable in theory...
    I was trying to make the simplest possible poly synth patch and I started out with this adsr~ example. I deleted the sah~ and had mtof go directly to the oscillator. I was trying to see if there is some case where that sah~ prevents something undesirable from happening. So I made my poly~ have only one voice and turned on voice stealing, but I can't really tell a difference between having and not having the sah~.
    I can imagine some extreme example where for maybe one sample vector the pitch is wrong at the peak envelope amplitude. But then why is this example also using a [swap] for the midi input? If we just send the right outlet of the unpack directly to the [/ 127.] won't that go trigger the envelope first before the pitch is changed? So the ampltitude would jump to 0 and an instant later (but practically the same instant from the perspective of the Max scheduler?) the pitch will be changed. That seems fine to me, but I suppose the pitch could be set slightly too late? I can't imagine it would be noticeable though. I tried with attack 0 and I can't hear anything wrong. Maybe my ears are not discerning enough ;)
    So sah~ is used to ensure the pitch change occrs *exactly* when the evelope starts, but I'm just wondering, how important is this really? It seems fine to omit it in practice, at least from my brief experiments. If someone can demonstrate a case where it fixes a noticeable problem, I'd be really interested.

    • Jan 26 2009 | 8:07 pm
      Just taking a quick look at this--without testing anything--it seems sah~ could prevent the pitch from changing when turning notes off with a long decay time. This is unlikely in the example for the reasons you give and because it's triggered with the "midinote" message (so presumably only notes that are already on get turned off). Nonetheless, I can imagine using adsr-synth in a situation where it might receive a noteoff message with a different pitch value than the previous noteon message. With the sah~ object this would cause it to suddenly change the pitch of the held note and then decay.
    • Jan 28 2009 | 3:35 am
      Quote: Holland Hopson wrote on Mon, 26 January 2009 12:07 ---------------------------------------------------- > I can imagine using adsr-synth in a situation where it might receive a noteoff message with a different pitch value than the previous noteon message
      Ah, good point. That makes a lot of sense. So sah~ is important if you want to make a patch that is robust in any situation, including ones where voice allocation might not be handled properly (I consider this case to be "incorrect").
      It seems when using midinote to trigger poly~ notes, this situation will never happen: a noteoff for the previous note is sent whenever a voice is stolen. So I'm concluding it is safe to omit the sah~ mechanism when using midinote messages with poly~. I will keep in mind things can potentially malfunction if noteoffs occur out of order.
      Thanks for the response.