How to stop a MIDI note


#1

Hi, i’m trying to create a Plug-In Synthesiser. I started from the example found in the Juce library.
My problem is that it actually sounds but when the press key of the host virtual midi keyboard is released the sound doesn’t stop but when i press another key it produces a different note as expected. Plus after switching many times different notes the attack of the currently pressed note seems to be delayed and i can hear some artifacts which disappear after some milliseconds.

I just used the code of the JUCE library removing the delay implemented using delayBuffer.

Thanks in advance for your kind replies.


#2

Erm, perhaps I’ve miss-understood; send NoteOff()s?


#3

I already called MidiMessage::noteOff in this way:

for (int i = 1; i<3 ; ++i)
for(int k = 0; k<128 ; ++k)
MidiMessage::noteOff(i, k, (float)0.2);

I called it both in stopNote method of SynthesiserVoice and in processBlock of pluginProcessor file. How you can see, i called it for all the channels and midi notes number but it doesn’t solve the problem.

I tried to make a check on the tailOff variable: i did a print of the value in the if condition and it doesn’t display anything. It means that it never enter in the if condition i.e if(tailOff>0) is never verified. I guess that the reason why this happens is due to the fact that in the stopNote method the parameter allowTailOff is never assigned to true and thus the variable tailOff keeps being zero.


#4

All that your code does is that it creates a bunch of noteOff events, i.e

MidiMessage myNoteOffEvent = MidiMessage::noteOff(i, k);

To achieve your goal you must incorporate these messages somewhere in the midi flow e.g in your processBlock function. Have a look at the arpeggiator sample for an example of how noteoffs are created and inserted in the flow of midimessages


#5

Thanks for the answer but i didn’t understand what you mean.
I tried to write what you said but it doesn’t work.

Could you explain more in detail?


#6

Please have a look at juce sample plugin juce\examples\PlugInSamples\Arpeggiator. In its processblock you can see an example of how noteoffs are created, and used.


#7

There’s this old post - MIDI ‘all notes off’ message