I often use short decay pitch or filter envelope drops to add some bite to a synth sound's attack. To spare the internal zone envelopes for other uses, I made a simple modulation parameter to do the job. There is a problem though.
When playing lower notes, there are noticeable variations in the attack character of successive notes, especially sounds with a longer release. It sounds like the oscillator phase and rapid envelope decay are out of sync (with fixed phase osc). The modulation param also doesn't take "Key On Del" into account. I'm guessing this has something to do with the execution order of the program tree.
The same thing happens with the standard Env Midi Module.
I've tried various ways of delaying the mod param to sync with onNote, but nothing worked. Any ideas?
Code: Select all
defineModulation("Quick Decay", false) modVal = 1 durationMS = 15 function calcModulation() if retrigger then modVal = 1 retrigger = false end rate = getSamplingRate() / 32 rateVal = 1 / (rate * (durationMS / 1000)) if modVal <= 0 then modVal = 0 else modVal = modVal - rateVal end return modVal end function onNote(event) retrigger = true postEvent(event) end function onRelease(event) postEvent(event) end
I have a boolean parameter tied to a UI switch with no callback function. It's only there to retrieve the state of the switch.
As soon as you use the boolean parameter in the onNote function, it changes the values to 0 and 1 instead of false and true. This messes with the shorthand "if boolParam then" syntax, as both become true. Even when the "if statement" is inside an external function and called from onNote, this still happens.
I know this runs in different threads in the Halion engine, but as parameters are variables, this is kind of strange.
Any help with these 2 questions would be much appreciated.