Hi, There’ a think that I cannot understand:
I created two plugins that I load in juce audioPluginHost as internal plugins that give me the possibility to: open a midi device and to send throw a midi channel index incoming messages and get incoming midi messages in processblock and send them to a midi output port.
.h:
Array<MidiMessage> incomingMessages; // needs me to show incoming or outgoing messages in a monitor
MidiBuffer collectorBuffer = MidiBuffer();
double sampleRate = 48000;
void prepareToPlay (double samplRate, int samplPerBlock) override { sampleRate = samplRate; }
.cpp:
void MidiIO::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiBuffer)
{
buffer.clear();
MidiBuffer newMidiBuffer;
if (deviceType == MidiIO::IODeviceType::input)
{
midiBuffer.clear();
midiBuffer.data = collectorBuffer.data;
collectorBuffer.clear();
} else {
for (const MidiMessageMetadata metadata : midiBuffer)
{
incomingMessages.add (metadata.getMessage());
sendMessage(ayra::Messages::newMidiMessage);
sendToOutputs(metadata.getMessage());
}
}
}
void MidiIO::handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message)
{
if (deviceType == IODeviceType::input)
{
auto timestamp = message.getTimeStamp();
int sampleNumber = (int) (timestamp * sampleRate );
collectorBuffer.addEvent (message, sampleNumber);
incomingMessages.add (message);
sendMessage(ayra::Messages::newMidiMessage);
}
}
If I connect midiInputPlugin to MidiOutputPlugin in MidiOutputPlugin monitor I can see the midi messages sent from midiInputPlugin, but if I connect midiInputPlugin to for example a twin2 this one don’t produces any sound… ideas ?