void Loop::sendCurrentNoteToBuffer(MidiBuffer& buffer, int sample_number, int velocity) { MidiMessage m = this->getEventPointer(currentIndex)->message; //playingNote[m.getNoteNumber()][m.getChannel()-1][0] = jlimit(0,127,m.getNoteNumber()+getTransposition()); m.setNoteNumber(jlimit(0,127,m.getNoteNumber()+getTransposition())); m.setVelocity((((float)velocity*midiScaler * velocitySensitivity) + (1.f-velocitySensitivity))); if (outChannel>0) m.setChannel(outChannel); buffer.addEvent(m,sample_number); indexOfLastNoteOn=currentIndex; }
void CtrlrPanelProcessor::processBlock(MidiBuffer &midiMessages, MidiBuffer &leftoverBuffer, const AudioPlayHead::CurrentPositionInfo &info) { if (owner.getMidiOptionBool(panelMidiInputFromHostCompare)) { owner.getMIDIInputThread().handleMIDIFromHost(midiMessages); } leftoverBuffer.clear(); processLua(midiMessages, info); MidiBuffer::Iterator i(midiMessages); MidiMessage m; int time; while (i.getNextEvent(m,time)) { _MIN("VST INPUT", m, time); if (owner.getMidiOptionBool(panelMidiThruH2D) == true) { if (owner.getMidiOptionBool(panelMidiThruH2DChannelize)) { m.setChannel (owner.getMidiChannel(panelMidiOutputChannelDevice)); } owner.sendMidi(m); } if (owner.getMidiOptionBool(panelMidiThruH2H) == true) { if (owner.getMidiOptionBool(panelMidiThruH2HChannelize)) { m.setChannel (owner.getMidiChannel(panelMidiOutputChannelHost)); } leftoverBuffer.addEvent (m, time); } } }
void CtrlrPanelProcessor::processBlock(MidiBuffer &midiMessages, MidiBuffer &leftoverBuffer) { if (owner.getMidiOptionBool(panelMidiInputFromHostCompare)) { owner.getMIDIInputThread().handleMIDIFromHost(midiMessages); } MidiBuffer::Iterator i(midiMessages); MidiMessage m; int time; while (i.getNextEvent(m,time)) { _MIN("VST INPUT", m); if (owner.getMidiOptionBool(panelMidiThruH2D) == true) { if (owner.getMidiOptionBool(panelMidiThruH2DChannelize)) { m.setChannel (owner.getMidiChannel(panelMidiOutputChannelDevice)); } owner.sendMidi(m); } if (owner.getMidiOptionBool(panelMidiThruH2H) == true) { if (owner.getMidiOptionBool(panelMidiThruH2HChannelize)) { m.setChannel (owner.getMidiChannel(panelMidiOutputChannelHost)); } leftoverBuffer.addEvent (m, m.getTimeStamp()); } } }
//============================================================================== void MidiTransform::processEvents (MidiBuffer& midiMessages, const int blockSize) { int timeStamp; MidiMessage message (0xf4, 0.0); MidiBuffer::Iterator it (midiMessages); MidiBuffer midiOutput; switch (command) { case MidiTransform::KeepEvents: break; case MidiTransform::DiscardEvents: { midiMessages.clear (); break; } case MidiTransform::RemapChannel: { while (it.getNextEvent (message, timeStamp)) { message.setChannel (channelNumber); midiOutput.addEvent (message, timeStamp); } midiMessages = midiOutput; break; } case MidiTransform::ScaleNotes: { while (it.getNextEvent (message, timeStamp)) { if (message.isNoteOnOrOff ()) { message.setNoteNumber (roundFloatToInt (message.getNoteNumber () * noteScale)); midiOutput.addEvent (message, timeStamp); } } midiMessages = midiOutput; break; } case MidiTransform::InvertNotes: { while (it.getNextEvent (message, timeStamp)) { if (message.isNoteOnOrOff ()) { message.setNoteNumber (127 - message.getNoteNumber ()); midiOutput.addEvent (message, timeStamp); } } midiMessages = midiOutput; } case MidiTransform::TransposeNotes: { while (it.getNextEvent (message, timeStamp)) { if (message.isNoteOnOrOff ()) { message.setNoteNumber (jmax (0, jmin (127, message.getNoteNumber () - noteTranspose))); midiOutput.addEvent (message, timeStamp); } } midiMessages = midiOutput; break; } case MidiTransform::ScaleVelocity: { while (it.getNextEvent (message, timeStamp)) { if (message.isNoteOn ()) { message.setVelocity ((message.getVelocity () / 127.0f) * velocityScale); midiOutput.addEvent (message, timeStamp); } } midiMessages = midiOutput; break; } case MidiTransform::InvertVelocity: { while (it.getNextEvent (message, timeStamp)) { if (message.isNoteOn ()) { message.setVelocity ((uint8) (127 - message.getVelocity ())); midiOutput.addEvent (message, timeStamp); } } midiMessages = midiOutput; break; } case MidiTransform::TransposeVelocity: { while (it.getNextEvent (message, timeStamp)) { if (message.isNoteOn ()) { message.setVelocity (jmax (0, jmin (127, message.getVelocity () - velocityTranspose))); midiOutput.addEvent (message, timeStamp); } } midiMessages = midiOutput; break; } case MidiTransform::TriggerCC: { break; } case MidiTransform::TriggerNote: { break; } } }