[sdiy] software / firmware envelopes in C (or anything else)

Chris McDowell declareupdate at gmail.com
Sun Nov 9 14:17:04 CET 2025


What Brian said! 

> On a related note, I've always been (slightly) baffled by how the firmware of certain renowned synths handle polyphonic glide / portamento

I triggered a similar thread on this list about 5 years ago digging in to this subject. It is really not obvious what -should- happen. For a group of voices getting allocated by a system receiving note-ons and note-offs, who glides from what notes to the note we just received? I found it to be a little bit of a rabbit hole. I'll have to go back and check which approach I landed on for that project. 

Cheers,
Chris 

> On Nov 9, 2025, at 1:48 AM, brianw <brianw at audiobanshee.com> wrote:
> 
> On Nov 8, 2025, at 4:44 PM, jslee wrote:
>>> On Fri, 7 Nov 2025, at 12:33, brian w. wrote:
>>> However, with Legato playing, it does make sense to alter the Sustain
>>> level of the envelope with the new Velocity, even though it's a new
>>> Note On without a corresponding Note Off for the previous note
>>> (although Note Off can occur *after* the new Note On).
>> 
>> Curious: what’s your heuristic for deciding if legato playing/not? “Instrument is monophonic or a poly in unison mode?” A foot pedal? Or would you apply it on a poly also?
> 
> I seem to recall that there might be two kinds of Legato modes, but I can't recall at the moment. At any rate, they're always under control of the user who edits the synth patch.
> 
> A keyboard can generally produce a Gate signal and a Trigger. For a mono analog keyboard, Gate is true when *any* key is down, so if you press a new key before releasing the old key, the Gate does not change at all. But Trigger is just a pulse when a key goes down, and that pulse ends even if you hold the key, thus there will always be a new trigger on each key down, regardless of the previous key(s). So, generally, a mono keyboard can restart the Envelope Attack based on Gate or Trigger.
> 
> If the Envelope is following Gate, then it will not Attack until you release all keys and then press a new one, so Legato playing avoid Attack until there's a gap.
> 
> If the Envelope is following Trigger, then it will Attack for every new key, regardless of whether the previous key is still being held down or was released first.
> 
> I think that the other "legato" mode that I'm remembering is that the Sequential Circuits Pro-One actually has a mode where Gate is simply held on, even when all keys are released. I suppose that's not really a "legato" mode, per se.
> 
> The above is all for analog synth circuits.
> 
> When you have (digital) MIDI, it's merely whether Note On #2 comes before Note Off #1.
> 
> 
> ... but you might not be asking "how to detect legato playing in the sense of what the keyboard player's fingers are doing," but instead you might be asking "how does the synthesis engine decide what sounds to make, whether those be legato sounds or staccato sounds."
> 
> 
> In the latter interpretation of the question, the answer is entirely part of the patch editing design. The synth always allows the patch editor to decide on different modes. If an analog synth is mono, then there's only the choice of Gate or Trigger for the Envelope Attack, because polyphonic isn't an option. If a synth is polyphonic, then there will be various modes to allow monophonic options despite the general polyphonic capability.
> 
> You mention unison mode, and that's one obvious mode when a poly would effectively be operating like a mono synth (although lots of oscillators and filters). But there are actually many ways to design a patch editing system to allow more flexibility, and users might not want to be forced into legato mode just because they chose unison mode.
> 
> Take a look at the Oberheim Matrix-12 voice patch architecture. That synth has a ridiculous number of options. You can set individual voices to their own MIDI channel, even disconnect them from the local keyboard, put them into groups on the same channel, or the local keyboard, and when grouped the voice allocation setup can be fixed order, round robin, last note priority, same note priority, least recent note priority.
> 
> I once got a discount on an Oberheim Xpander (for a friend) because the synth happened to have one voice set to a mode where it literally could not be played from the keyboard. Everyone involved in the sale honestly thought it was a dead voice, but when my friend got the synth delivered I dug into the manual and reassigned the voice to the keyboard and it worked perfectly.
> 
> 
> Long story short, the sound of synthesized legato depends both upon how the keyboard is played *and* how the patch is programmed. It would certainly be valid to create a patch design that allowed a foot pedal to control legato, as you suggest. If any player can use it, then it's probably a good option to allow.
> 
> And besides just the Envelope Attack options, Legato could also affect things like whether the VCO waveform continues where it left off (legato) or resets to the start of the waveform (which probably would not sound very 'legato'). A more complicated voice architecture that has more than the traditional VCO/VCF/VCA might even have other details controlled by legato playing.
> 
> 
> On a related note, I've always been (slightly) baffled by how the firmware of certain renowned synths handle polyphonic glide / portamento. There must be a very specific heuristic for deciding which start notes slide to which end notes, and I imagine that sloppy playing (especially legato) could easily confuse the algorithm (or maybe nobody can hear the difference between the possible variations).
> 
> 
>> eg. if you were writing firmware for a midi master keyboard
> 
> A MIDI Master Keyboard should not even "think" about legato. A MIDI Master Keyboard should strictly send Note On for any key that is pressed, and Note Off for any key that is released. Velocity can be calculated for both Note On and Note Off if you have staggered position sensors, or continuous position detection (like the Ensoniq inductive keyboard).
> 
> But it's up to the sound-generating module to decide how and when to use legato, based on the patch settings, and not the master keyboard controller.
> 
> Even if a MIDI Master Keyboard has an internal synth engine, and even if the keyboard uses a protocol other than MIDI (like the Ensoniq poly-aftertouch keyboards do), there's still a separation between the CPU that reads the keyboard and the CPU that handles voice allocation and patch modes. And, yes, sometimes it's even the same CPU chip, but the firmware would keep those two aspects separate for maximum flexibility.
> 
>> John
> 
> Brian
> 
> 
> ________________________________________________________
> This is the Synth-diy mailing list
> Submit email to: Synth-diy at synth-diy.org
> View archive at: https://synth-diy.org/pipermail/synth-diy/
> Check your settings at: https://synth-diy.org/mailman/listinfo/synth-diy
> Selling or trading? Use marketplace at synth-diy.org



More information about the Synth-diy mailing list