Hi all,
i need to build a bank of MIDI CC in a plugin that can send MIDI CC from its MIDI output.
Any example / help around?
I don't understand if the Juce MIDIMessage classes can send to the plugin output or send just to hardware midi output of a Juce application.
thanks and all the best!
I actually came up with this in the processBlock
void StiXctrlAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
buffer.clear();
MidiBuffer processedMidi;
int time;
MidiMessage m;
for (MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);)
{
int8 myVal = (int8)CC00Val;
m = MidiMessage::controllerEvent(2, 1, myVal);
processedMidi.addEvent(m, time);
}
midiMessages.swapWith (processedMidi);
}
But it has some relevant problems that i can't figure out how to solve
1. It only works if some MIDI event is coming to the buffer from the host.
2. It only works if the host is running.
How can i keep it "alive" even when the host is not running and not sending any event to MidiBuffer?
many thanks and all the best
a.
I guess that the thing is that in
for (MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);)
the for loop doen not run because its exit condition is given by
i.getNextEvent(m, time)
so basically if there is no event arriving to the buffer the for loop just quit.
Am i right?
If yes, is there anyway to let the for loop run while adding events to buffer?
thanks
Hi guys,
someone has any suggestion?
many thanks
a.
oxxyyd
April 8, 2016, 12:09pm
5
Why don’t you just clear the incoming Midibuffer and add whatever new Midimessages you want to that.
I don’t see any point in iterating through the incoming buffer, when you eventually throw all it’s content away anyhow with the swapWith call?
Thanks oxxyyd! I just got the same idea but i’m a Juce newbie so still learning.
BTW now i have my CC being sent continously even if the value isn’t changed.
So at every audio process block i have a new MIDI CC sent even if the value isn’t changed.
Any idea on how to solve this?
thanx and all the best.
a.
oxxyyd
April 11, 2016, 8:28pm
7
Why not save the value and in the next processBlock call you check if the value has changed?
Thanks oxxyyd,
yes i tried this but same beheaviour.
I guess i’m doing something really stupid until i’ll have the “ha ha!!!” moment
void StiXctrlAudioProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
buffer.clear();
midiMessages.clear();
MidiBuffer generatedMidi;
int time;
MidiMessage m;
int8 ccTempVal;
int8 myVal = (int8)CC00Val;
if (myVal != ccTempVal)
{
m = MidiMessage::controllerEvent(2, 1, myVal);
generatedMidi.addEvent(m, midiMessages.getLastEventTime());
}
else generatedMidi.clear();
ccTempVal = myVal;
midiMessages.swapWith (generatedMidi);
}
daniel
April 12, 2016, 10:57am
9
Well, if you define your ccTempVal inside the processBlock and furthermore don’t initialize it, it is pure luck, if the comparism returns true or false
Make it a member variable of your AudioProcessor, and initialize it in the constructor
Thanks! here’s the “haha!” moment dressed with “what a dummy mofo am i?” sauce
Now it works
daniel
April 12, 2016, 11:26am
11
Don’t worry, happens to all of us from time to time…
except maybe Donald Knuth
hi @alfonso ,
can you paste the code or explain what you did in the end?
I am also a newbie wrestling my way through this stuff!
thanks