Cabbage Logo
Back to Cabbage Site

Setting a keyboard with an envelope

I used the keyboard template to create a synth that plays short envelopes.
The thing is : I realized that the keyboard sends the amp level, and when I press a key too fast - it doesn’t finish the envelope and get chopped. If I press a note longer than the speed of the envelope it works great, but I don’t like this choppy behavior.

How would you suggest I override the keyboards function? by a controller instrument that just sends a trigger? maybe there’s a way to ignore “note off” messages, or somehow define that a sound continues even if you stopped pressing it as long as the envelope timing is longer?

Can you post your .csd file?

Button Module - Midi .csd (4.1 KB)

The problem here is you are using a fixed duration envelop. You should always use one of the ‘r’ variant envelopes for realtime performance. In your case transegr. That will give a release segment when you lift the note.

hmm… that did fix the clipping problem. However - this synth was designed for very short, tactile sounds. Almost pitch-less (like a knock on a door lets say). if I change it to transegr I can’t get the super fast envelopes.

What I want is a fixed duration based on the envelope, not based on how long I press the note, however the trigger and the frequency will come from the midi controller

In that case I would use the MIDI instrument to trigger the note, rather than perform the note itself. Something like:

instr 1
event_i "i", 2, 0, .1

instr 2
;//play note with fixed duration

Thank you! that’s what I thought I might have to do. But hey, now I discovered that there are ‘r’ envelopes!