Notes not turning off

Hi everyone. First of all, thanks for all of the great advice I’ve been able to gather from your collected postings; they’ve been a big help to me over the past few weeks as I’ve learned about VSTs and JUCE.

I’ve implemented a VST synthesizer as my senior design project using JUCE for my UI, MIDI and VST bits, STK ( for my “oscillators” and envelope generators, and my own delay and filter implementations based on my advisor’s templates. I have a good grasp on the DSP concepts and theory involved, but this is my first serious attempt at programming in C++ (read: started with a little C but learned C++ through coding this). It’s easily the biggest programming project I’ve undertaken in over a decade and I’ve run into a few snags as I’m wrapping it up.

The biggest of these is that notes do not reliably turn off during performance via MIDI device. I’ve tried debugging my plugin using both a physical MIDI keyboard over USB and an iPad over WiFi with the same results; the execution does not proceed to myVoice::stopNote and subsequently never reaches Synthesiser::stopVoice or Synthesiser::noteOff on those occasions when the note continues to sound. I am using clearCurrentNote() in myVoice::stopNote as described in the documentation - it just never gets there. However, the plugin does seem to respond properly to MIDI commands from a MIDI file in a DAW.

The plugin more or less “works” on both OSX Lion and Windows 7 besides this issue, but I’d like to get it to some electronic music/keyboardist friends for feedback (I’m a clarinetist) before finalizing the design and report; clearly, “sticky keys” will trump any musical considerations in their eyes. :wink: I’d appreciate any insight anyone with more experience might be able to offer. My code is a bit… rambling (being new to C++ and all) but if any sections would be relevant/helpful I’d be happy to post them. Thanks!

After some more troubleshooting (including profiling using Instruments as recommend by Jules in another thread), I determined that the most likely cause for the noteOff signals being missed was simply too many voices. The majority of processing time was spent in the STK waveform generators; for simplicity while getting started in my design I chose to have them all run concurrently - even when not sounding. As a result, “two hands worth” of polyphony took quite a lot of time to generate (even when silent) in comparison to the rest of the processing.

My assumption is that a SynthesiserVoice can only respond to a MIDI signal when it’s the active voice; if this is correct, any noteOff signals sent while another voice is processing would be missed leading to the “stuck key” effect. Assuming this is a valid train of thought, I’m going to experiment with storing the MIDI note state for each voice as a parameter that can be stored regardless of which voice is processing and referenced by the appropriate voice when it comes around again to ensure that at the very least they turn off “soon” after the key is released.

In short, my formerly polyphonic design works just fine as a monophonic synth.

If anyone is interested in seeing more, please visit Yes,I know the name is terribly unoriginal and undescriptive - I’m an engineer, not a poet! :slight_smile: