Hello there,
having big fun exploring Juce
I am trying to create a steady pulse of Midi notes. I used the arpeggiator example as a guide counting samples and stuff.
Still I am doing something wrong, as the notes do not stop. I can not tell if its a steady flow of notes or just one thats not ending…
Here is my code:
As the fomatting is party weird, its the process Block function in PluginProcessor, sorry for the hassle.
ScopedNoDenormals noDenormals;
int numSamples = buffer.getNumSamples();
midiMessages.clear();
if (isPlaying && !noteIsOn && (samplesTillNextNote<=0))
{
samplesTillNoteOff = samplesPerQuarterNote / 4;
samplesTillNextNote = samplesPerQuarterNote;
midiMessages.addEvent(MidiMessage::noteOn(1, 64, uint8(100)), 1);
noteIsOn = true;
}
if (isPlaying && noteIsOn && (samplesTillNoteOff==0))
{
midiMessages.addEvent(MidiMessage::noteOff(1, 64, uint8(0)), 1);
noteIsOn = false;
}
if (!isPlaying && noteIsOn)
{
midiMessages.addEvent(MidiMessage::noteOff(1, 64, uint8(0)), 1);
noteIsOn = false;
}
if (samplesTillNextNote >= numSamples)
samplesTillNextNote -= numSamples;
else
samplesTillNextNote = 0;
if (samplesTillNoteOff >= numSamples)
samplesTillNoteOff -= numSamples;
else
samplesTillNoteOff = 0;
any ideas, suggestions? Am I completely on the wrong path?
Thank you,
Jens