本文整理汇总了C++中MidiMessage::isProgramChange方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiMessage::isProgramChange方法的具体用法?C++ MidiMessage::isProgramChange怎么用?C++ MidiMessage::isProgramChange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidiMessage
的用法示例。
在下文中一共展示了MidiMessage::isProgramChange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleMidiEvent
void Synthesiser::handleMidiEvent (const MidiMessage& m)
{
if (m.isNoteOn())
{
noteOn (m.getChannel(), m.getNoteNumber(), m.getFloatVelocity());
}
else if (m.isNoteOff())
{
noteOff (m.getChannel(), m.getNoteNumber(), m.getFloatVelocity(), true);
}
else if (m.isAllNotesOff() || m.isAllSoundOff())
{
allNotesOff (m.getChannel(), true);
}
else if (m.isPitchWheel())
{
const int channel = m.getChannel();
const int wheelPos = m.getPitchWheelValue();
lastPitchWheelValues [channel - 1] = wheelPos;
handlePitchWheel (channel, wheelPos);
}
else if (m.isAftertouch())
{
handleAftertouch (m.getChannel(), m.getNoteNumber(), m.getAfterTouchValue());
}
else if (m.isController())
{
handleController (m.getChannel(), m.getControllerNumber(), m.getControllerValue());
}
else if (m.isProgramChange())
{
handleProgramChange (m.getChannel(), m.getProgramChangeNumber());
}
}
示例2: handleMidiEvent
void MPESynthesiser::handleMidiEvent (const MidiMessage& m)
{
if (m.isController())
handleController (m.getChannel(), m.getControllerNumber(), m.getControllerValue());
else if (m.isProgramChange())
handleProgramChange (m.getChannel(), m.getProgramChangeNumber());
MPESynthesiserBase::handleMidiEvent (m);
}
示例3: midiMessageToType
const CtrlrMidiMessageType midiMessageToType (const MidiMessage &midiMessage)
{
if (midiMessage.isController())
{
return (CC);
}
else if (midiMessage.isSysEx())
{
return (SysEx);
}
else if (midiMessage.isNoteOn())
{
return (NoteOn);
}
else if (midiMessage.isNoteOff())
{
return (NoteOff);
}
else if (midiMessage.isAftertouch())
{
return (Aftertouch);
}
else if (midiMessage.isChannelPressure())
{
return (ChannelPressure);
}
else if (midiMessage.isProgramChange())
{
return (ProgramChange);
}
else if (midiMessage.isPitchWheel())
{
return (PitchWheel);
}
else if (midiMessage.isMidiClock())
{
return (MidiClock);
}
else if (midiMessage.isMidiContinue())
{
return (MidiClockContinue);
}
else if (midiMessage.isMidiStart())
{
return (MidiClockStart);
}
else if (midiMessage.isMidiStop())
{
return (MidiClockStop);
}
else if (midiMessage.isActiveSense())
{
return (ActiveSense);
}
return (SysEx);
}
示例4: PK_STRING
static PyObject *
PyMidiMessage_str(PyObject *self) {
MidiMessage *m = ((PyMidiMessage*)self)->m;
static char s[256];
if(m->isNoteOn()) {
sprintf(s, "<NOTE ON, note: %d (%s), velocity: %d, channel: %d>",
m->getNoteNumber(),
m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
m->getVelocity(),
m->getChannel());
} else if(m->isNoteOff()) {
sprintf(s, "<NOTE OFF, note: %d (%s), channel: %d>",
m->getNoteNumber(),
m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
m->getChannel());
} else if(m->isProgramChange()) {
sprintf(s, "<PROGRAM CHANGE: program: %d, channel: %d>", m->getProgramChangeNumber(), m->getChannel());
} else if(m->isPitchWheel()) {
sprintf(s, "<PITCH WHEEL: value: %d, channel: %d>", m->getPitchWheelValue(), m->getChannel());
} else if(m->isAftertouch()) {
sprintf(s, "<AFTERTOUCH: note: %d (%s) value: %d, channel: %d>",
m->getNoteNumber(),
m->getMidiNoteName(m->getNoteNumber(), true, true, 3),
m->getAfterTouchValue(),
m->getChannel());
} else if(m->isChannelPressure()) {
sprintf(s, "<CHANNEL PRESSURE: pressure: %d, channel: %d>", m->getChannelPressureValue(), m->getChannel());
} else if(m->isController()) {
const char *name = m->getControllerName(m->getControllerNumber());
if(strlen(name) > 0) {
sprintf(s, "<CONTROLLER: %d (\"%s\"), value: %d, channel: %d>",
m->getControllerNumber(),
m->getControllerName(m->getControllerNumber()),
m->getControllerValue(),
m->getChannel());
} else {
sprintf(s, "<CONTROLLER: %d, value: %d, channel: %d>",
m->getControllerNumber(),
m->getControllerValue(),
m->getChannel());
}
} else {
sprintf(s, "<MidiMessage (misc type)>");
}
return PK_STRING(s);
}
示例5: processMidiMessage
void MidiManager::processMidiMessage(const MidiMessage& midi_message, int sample_position) {
if (midi_message.isProgramChange()) {
current_patch_ = midi_message.getProgramChangeNumber();
File patch = LoadSave::loadPatch(current_bank_, current_folder_, current_patch_,
synth_, *gui_state_);
PatchLoadedCallback* callback = new PatchLoadedCallback(listener_, patch);
callback->post();
return;
}
if (midi_message.isNoteOn()) {
engine_->noteOn(midi_message.getNoteNumber(),
midi_message.getVelocity() / (mopo::MIDI_SIZE - 1.0),
0, midi_message.getChannel() - 1);
}
else if (midi_message.isNoteOff())
engine_->noteOff(midi_message.getNoteNumber());
else if (midi_message.isAllNotesOff())
engine_->allNotesOff();
else if (midi_message.isSustainPedalOn())
engine_->sustainOn();
else if (midi_message.isSustainPedalOff())
engine_->sustainOff();
else if (midi_message.isAftertouch()) {
mopo::mopo_float note = midi_message.getNoteNumber();
mopo::mopo_float value = (1.0 * midi_message.getAfterTouchValue()) / mopo::MIDI_SIZE;
engine_->setAftertouch(note, value);
}
else if (midi_message.isPitchWheel()) {
double percent = (1.0 * midi_message.getPitchWheelValue()) / PITCH_WHEEL_RESOLUTION;
double value = 2 * percent - 1.0;
engine_->setPitchWheel(value, midi_message.getChannel());
}
else if (midi_message.isController()) {
int controller_number = midi_message.getControllerNumber();
if (controller_number == MOD_WHEEL_CONTROL_NUMBER) {
double percent = (1.0 * midi_message.getControllerValue()) / MOD_WHEEL_RESOLUTION;
engine_->setModWheel(percent, midi_message.getChannel());
}
else if (controller_number == BANK_SELECT_NUMBER)
current_bank_ = midi_message.getControllerValue();
else if (controller_number == FOLDER_SELECT_NUMBER)
current_folder_ = midi_message.getControllerValue();
midiInput(midi_message.getControllerNumber(), midi_message.getControllerValue());
}
}
示例6: handleIncomingMidiMessage
void VoicerUGenInternal::handleIncomingMidiMessage (MidiInput* /*source*/, const MidiMessage& message) throw()
{
if(message.isForChannel(midiChannel_) == false) return;
if(message.isNoteOnOrOff())
{
const ScopedLock sl(lock);
sendMidiNote(message.getChannel(), message.getNoteNumber(), message.getVelocity());
}
else if(message.isController())
{
if((message.getControllerNumber() == 123) && (message.getControllerValue() == 0))
{
const ScopedLock sl(lock);
initEvents();
}
getController(message.getControllerNumber()) =
(message.getControllerValue() * (1.f / 127.f));
}
else if(message.isPitchWheel())
{
getPitchWheel() = (jlimit(-8191, 8191, message.getPitchWheelValue() - 8192) * (1.f / 8191.f));
}
else if(message.isChannelPressure())
{
getChannelPressure() = (message.getChannelPressureValue() * (1.f / 127.f));
}
else if(message.isAftertouch())
{
getKeyPressure(message.getNoteNumber()) =
(message.getAfterTouchValue() * (1.f / 127.f));
}
else if(message.isProgramChange())
{
getProgram() = (message.getProgramChangeNumber());
}
else if(message.isAllNotesOff())
{
const ScopedLock sl(lock);
initEvents();
}
}
示例7: getMidiNumber
const String getMidiNumber(const MidiMessage &m)
{
if (m.isAftertouch())
{
return (String::formatted (" No:[%4d]", m.getNoteNumber()));
}
if (m.isController())
{
return (String::formatted (" No:[%4d]", m.getControllerNumber()));
}
if (m.isNoteOnOrOff())
{
return (String::formatted (" No:[%4d]", m.getNoteNumber()));
}
if (m.isProgramChange())
{
return (String::formatted (" No:[%4d]", m.getProgramChangeNumber()));
}
return (" No:[----]");
}
示例8: getMidiMessageDescription
String ZenMidiVisualiserComponent::getMidiMessageDescription(const MidiMessage& m)
{
if (m.isNoteOn()) return "Note on: " + S(m.getNoteNumber()) + " (" + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ") Vel: " + S(m.getVelocity());
if (m.isNoteOff()) return "Note off: " + S(m.getNoteNumber()) + " (" + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ")";
if (m.isProgramChange()) return "Program change (Number): " + String(m.getProgramChangeNumber());
if (m.isPitchWheel()) return "Pitch wheel: " + String(m.getPitchWheelValue());
if (m.isAftertouch()) return "After touch: " + MidiMessage::getMidiNoteName(m.getNoteNumber(), true, true, 3) + ": " + String(m.getAfterTouchValue());
if (m.isChannelPressure()) return "Channel pressure: " + String(m.getChannelPressureValue());
if (m.isAllNotesOff()) return "All notes off";
if (m.isAllSoundOff()) return "All sound off";
if (m.isMetaEvent()) return "Meta event";
if (m.isController())
{
String temp = MidiMessage::getControllerName(m.getControllerNumber());
String name = "Controller [" + S(m.getControllerNumber()) + "]";
if (!temp.isEmpty())
name += " " + temp;
return name + ": " + String(m.getControllerValue());
}
return String::toHexString(m.getRawData(), m.getRawDataSize());
}
示例9: getMidiMessageDescription
static String getMidiMessageDescription (const MidiMessage& m)
{
if (m.isNoteOn()) return "Note on " + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3);
if (m.isNoteOff()) return "Note off " + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3);
if (m.isProgramChange()) return "Program change " + String (m.getProgramChangeNumber());
if (m.isPitchWheel()) return "Pitch wheel " + String (m.getPitchWheelValue());
if (m.isAftertouch()) return "After touch " + MidiMessage::getMidiNoteName (m.getNoteNumber(), true, true, 3) + ": " + String (m.getAfterTouchValue());
if (m.isChannelPressure()) return "Channel pressure " + String (m.getChannelPressureValue());
if (m.isAllNotesOff()) return "All notes off";
if (m.isAllSoundOff()) return "All sound off";
if (m.isMetaEvent()) return "Meta event";
if (m.isController())
{
String name (MidiMessage::getControllerName (m.getControllerNumber()));
if (name.isEmpty())
name = "[" + String (m.getControllerNumber()) + "]";
return "Controler " + name + ": " + String (m.getControllerValue());
}
return String::toHexString (m.getRawData(), m.getRawDataSize());
}
示例10: midiCcReceived
//------------------------------------------------------------------------------
void MidiMappingManager::midiCcReceived(const MidiMessage& message,
double secondsSinceStart)
{
if(message.isController())
{
multimap<int, MidiMapping *>::iterator it;
multimap<int, MidiAppMapping *>::iterator it2;
int cc = message.getControllerNumber();
int value = message.getControllerValue();
//Check if it matches any MidiMappings.
for(it=mappings.lower_bound(cc);
it!=mappings.upper_bound(cc);
++it)
{
it->second->ccReceived(value);
}
if(value > 64)
{
//Check if it matches any MidiAppMappings.
for(it2=appMappings.lower_bound(cc);
it2!=appMappings.upper_bound(cc);
++it2)
{
CommandID id = it2->second->getId();
MainPanel *panel = dynamic_cast<MainPanel *>(appManager->getFirstCommandTarget(MainPanel::TransportPlay));
if(panel)
{
if(id != MainPanel::TransportTapTempo)
panel->invokeCommandFromOtherThread(id);
else
{
double tempo = tapHelper.updateTempo(secondsSinceStart);
if(tempo > 0.0)
panel->updateTempoFromOtherThread(tempo);
}
}
}
}
}
else if(message.isMidiMachineControlMessage())
{
if(PropertiesSingleton::getInstance().getUserSettings()->getBoolValue(L"mmcTransport", false))
{
CommandID id = -1;
MainPanel *panel = dynamic_cast<MainPanel *>(appManager->getFirstCommandTarget(MainPanel::TransportPlay));
switch(message.getMidiMachineControlCommand())
{
case MidiMessage::mmc_stop:
id = MainPanel::TransportPlay;
break;
case MidiMessage::mmc_play:
id = MainPanel::TransportPlay;
break;
case MidiMessage::mmc_rewind:
id = MainPanel::TransportRtz;
break;
case MidiMessage::mmc_pause:
id = MainPanel::TransportPlay;
break;
default:
break;
}
if((id > -1) && panel)
panel->invokeCommandFromOtherThread(id);
}
}
else if(message.isProgramChange())
{
if(PropertiesSingleton::getInstance().getUserSettings()->getBoolValue(L"midiProgramChange", false))
{
int newPatch;
MainPanel *panel = dynamic_cast<MainPanel *>(appManager->getFirstCommandTarget(MainPanel::TransportPlay));
newPatch = message.getProgramChangeNumber();
if(panel)
panel->switchPatchFromProgramChange(newPatch);
}
}
}
示例11: timerCallback
//==============================================================================
void MidiMonitorEditor::timerCallback ()
{
MidiBuffer tmpBuffer;
int hours, minutes, seconds, frames;
MidiMessage::SmpteTimecodeType timeCode;
MidiMessageCollector* collector = owner->getMessageCollector ();
collector->removeNextBlockOfMessages (tmpBuffer, 1024);
if (! tmpBuffer.isEmpty())
{
String midiLine;
int samplePos = 0;
MidiMessage msg (0xf4, 0.0);
MidiBuffer::Iterator eventIterator (tmpBuffer);
while (eventIterator.getNextEvent (msg, samplePos))
{
midiLine.printf (T("[CH: %d] "), msg.getChannel());
if (msg.isNoteOnOrOff ())
{
midiLine += MidiMessage::getMidiNoteName (msg.getNoteNumber(),
true, true, 0);
midiLine += " ";
midiLine += String ((int) msg.getVelocity ());
if (msg.isNoteOn())
{
midiLine += " ON";
}
else
{
midiLine += " OFF";
}
}
else if (msg.isAllNotesOff())
{
midiLine += "ALL NOTES OFF";
}
else if (msg.isAllSoundOff())
{
midiLine += "ALL SOUND OFF";
}
else if (msg.isPitchWheel())
{
midiLine += "PITCHWEEL: ";
midiLine += String (msg.getPitchWheelValue());
}
else if (msg.isAftertouch())
{
midiLine += "AFTERTOUCH: ";
midiLine += String (msg.getAfterTouchValue());
}
else if (msg.isChannelPressure())
{
midiLine += "CHANNELPRESSURE: ";
midiLine += String (msg.getChannelPressureValue());
}
else if (msg.isSysEx())
{
midiLine += "SYSEX: ";
midiLine += String (msg.getSysExDataSize());
midiLine += " bytes";
}
else if (msg.isProgramChange())
{
midiLine += "PROGRAM CHANGE: ";
midiLine += String (msg.getProgramChangeNumber());
midiLine += " (";
midiLine += MidiMessage::getGMInstrumentName (msg.getProgramChangeNumber());
midiLine += ")";
}
else if (msg.isController())
{
midiLine += "CC: #";
midiLine += String (msg.getControllerNumber());
midiLine += " (";
midiLine += MidiMessage::getControllerName (msg.getControllerNumber());
midiLine += ") = ";
midiLine += String (msg.getControllerValue());
}
else if (msg.isTimeSignatureMetaEvent ())
{
int newNumerator, newDenominator;
msg.getTimeSignatureInfo (newNumerator, newDenominator);
midiLine += "TIME SIGNATURE: ";
midiLine += String (newNumerator);
midiLine += " / ";
midiLine += String (newDenominator);
}
else if (msg.isTempoMetaEvent ())
{
midiLine += "TEMPO: ";
midiLine += String (msg.getTempoSecondsPerQuarterNote ());
//midiLine += " ";
//midiLine += String (msg.getTempoMetaEventTickLength (ticksPerQuarterNote));
//.........这里部分代码省略.........
示例12: messageTypeChanged
void stepQuickEdit::messageTypeChanged()
{
MidiMessage *m = 0;
MidiBuffer *mB = 0;
if (editorComponent)
{
deleteAndZero (editorComponent);
}
if (midiMessage == 0)
{
return;
}
m = midiMessage->getMidiMessage();
if (m)
{
if (m->isNoteOn())
{
addAndMakeVisible (editorComponent = new stepEditNote(midiMessage));
typeCombo->setSelectedId (noteOn, true);
}
else if (m->isProgramChange())
{
typeCombo->setSelectedId (ProgramChange, true);
}
else if (m->isController())
{
addAndMakeVisible (editorComponent = new stepEditController(midiMessage));
typeCombo->setSelectedId (Controller, true);
}
else if (m->isMidiMachineControlMessage())
{
typeCombo->setSelectedId (MMC, true);
}
else if (m->isSysEx())
{
addAndMakeVisible (editorComponent = new stepEditSysex(midiMessage));
typeCombo->setSelectedId (SysEx, true);
}
resized();
}
mB = midiMessage->getMidiBuffer();
if (mB == 0)
return;
if (!m && mB)
{
MidiBuffer::Iterator i(*mB);
int len;
MidiMessage message (0xf4, 0.0);
if (i.getNextEvent (message, len))
{
uint8 *data = message.getRawData();
if (*data == 0xb0)
{
addAndMakeVisible (editorComponent = new stepEditController(midiMessage));
typeCombo->setSelectedId (Controller, true);
}
if (*data == 0xf0)
{
addAndMakeVisible (editorComponent = new stepEditSysex(midiMessage));
typeCombo->setSelectedId (SysEx, true);
}
resized();
}
}
}
示例13: processBlock
void InstanceProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
for(int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i)
{
buffer.clear(i, 0, buffer.getNumSamples());
}
bool infos = false;
AudioPlayHead* playhead = getPlayHead();
if(playhead && m_patch_tie)
{
infos = playhead->getCurrentPosition(m_playinfos);
}
lock();
{
m_midi.clear();
if(infos)
{
m_playing_list.setFloat(0, m_playinfos.isPlaying);
m_playing_list.setFloat(1, m_playinfos.timeInSeconds);
sendMessageAnything(m_patch_tie, s_playing, m_playing_list);
m_measure_list.setFloat(0, m_playinfos.bpm);
m_measure_list.setFloat(1, m_playinfos.timeSigNumerator);
m_measure_list.setFloat(2, m_playinfos.timeSigDenominator);
m_measure_list.setFloat(3, m_playinfos.ppqPosition);
m_measure_list.setFloat(4, m_playinfos.ppqPositionOfLastBarStart);
sendMessageAnything(m_patch_tie, s_measure, m_measure_list);
}
for(size_t i = 0; i < m_parameters.size() && m_parameters[i].isValid(); ++i)
{
sendMessageFloat(m_parameters[i].getTie(), m_parameters[i].getValueNonNormalized());
}
MidiMessage message;
MidiBuffer::Iterator it(midiMessages);
int position = midiMessages.getFirstEventTime();
while(it.getNextEvent(message, position))
{
if(message.isNoteOnOrOff())
{
sendMidiNote(message.getChannel(), message.getNoteNumber(), message.getVelocity());
}
else if(message.isController())
{
sendMidiControlChange(message.getChannel(), message.getControllerNumber(), message.getControllerValue());
}
else if(message.isPitchWheel())
{
sendMidiPitchBend(message.getChannel(), message.getPitchWheelValue());
}
else if(message.isChannelPressure())
{
sendMidiAfterTouch(message.getChannel(), message.getChannelPressureValue());
}
else if(message.isAftertouch())
{
sendMidiPolyAfterTouch(message.getChannel(), message.getNoteNumber(), message.getAfterTouchValue());
}
else if(message.isProgramChange())
{
sendMidiProgramChange(message.getChannel(), message.getProgramChangeNumber());
}
}
}
midiMessages.clear();
performDsp(buffer.getNumSamples(),
getTotalNumInputChannels(), buffer.getArrayOfReadPointers(),
getTotalNumOutputChannels(), buffer.getArrayOfWritePointers());
midiMessages.swapWith(m_midi);
unlock();
}
示例14: getName
const String getName(const MidiMessage &m)
{
if (m.isActiveSense())
{
return (" [Active Sense]");
}
if (m.isAftertouch())
{
return (" [Aftertouch]");
}
if (m.isAllNotesOff())
{
return (" [All notes off]");
}
if (m.isAllSoundOff())
{
return (" [All sound off]");
}
if (m.isChannelPressure())
{
return (" [Channel pressure]");
}
if (m.isController())
{
return (" [Controller]");
}
if (m.isFullFrame())
{
return (" [Full frame]");
}
if (m.isMetaEvent())
{
return (" [Meta event]");
}
if (m.isMidiClock())
{
return (" [MIDI Clock]");
}
if (m.isMidiContinue())
{
return (" [MIDI Continue]");
}
if (m.isMidiStart())
{
return (" [MIDI Start]");
}
if (m.isMidiStop())
{
return (" [MIDI Stop]");
}
if (m.isNoteOff())
{
return (" [Note off]");
}
if (m.isNoteOn())
{
return (" [Note on]");
}
if (m.isPitchWheel())
{
return (" [Pitch wheel]");
}
if (m.isProgramChange())
{
return (" [Program change]");
}
if (m.isQuarterFrame())
{
return (" Quarter frame]");
}
if (m.isSysEx())
{
return (" [System exclusive]");
}
return (" [Yet unknown]");
}
示例15: main
//.........这里部分代码省略.........
graph->addConnection(1000, 1, AUDIO_OUT_ID, 1);
plugInst->setCurrentProgram(program);
int numInputChannels = plugInst->getTotalNumInputChannels();
int numOutputChannels = plugInst->getTotalNumOutputChannels();
cout << "----- Plugin Information -----" << endl;
cout << "Input channels : " << numInputChannels << endl;
cout << "Output channels : " << numOutputChannels << endl;
cout << "Num Programs: " << plugInst->getNumPrograms() << endl;
cout << "Current program: " << plugInst->getCurrentProgram() << endl;
int numParams = plugInst->getNumParameters();
cout << "Num Parameters: " << numParams << endl;
for (int p = 0; p < numParams; ++p)
{
std::cout << "Param " << p << ": " << plugInst->getParameterName(p);
if (!plugInst->getParameterLabel(p).isEmpty()) {
cout << "(" << plugInst->getParameterLabel(p) << ")";
}
cout << " = " << plugInst->getParameter(p) << endl;
}
cout << "-----------------------------" << endl;
int maxChannels = std::max(numInputChannels, numOutputChannels);
AudioBuffer<float> entireAudioBuffer(maxChannels, totalSizeInSamples);
entireAudioBuffer.clear();
unsigned int midiSeqPos = 0;
graph->releaseResources();
graph->prepareToPlay(sampleRate, blockSize);
cout << "Num midi events: " << msgSeq->getNumEvents() << endl;
// Render the audio in blocks
for (int t = 0; t < totalSizeInSamples; t += blockSize)
{
//cout << "processing block " << t << " to " << t + blockSize << endl;
MidiBuffer midiBuffer;
for (int j = midiSeqPos; j < msgSeq->getNumEvents(); ++j)
{
MidiMessageSequence::MidiEventHolder* midiEventHolder = msgSeq->getEventPointer(j);
MidiMessage midiMsg = midiEventHolder->message;
int samplePos = static_cast<int>(midiMsg.getTimeStamp() * sampleRate);
if (samplePos >= t && samplePos < t + blockSize) {
if (midiMsg.isNoteOnOrOff()) {
if (midiMsg.isNoteOn()) {
cout << "note on event (" << midiMsg.getNoteNumber() << ") at " << samplePos << "(" << midiMsg.getTimeStamp() << "s) bufferpos=" << (samplePos - t) << endl;
}
else if (midiMsg.isNoteOff()) {
cout << "note off event (" << midiMsg.getNoteNumber() << ") at " << samplePos << "(" << midiMsg.getTimeStamp() << "s) bufferpos=" << (samplePos - t) << endl;
}
midiBuffer.addEvent(midiMsg, samplePos - t);
}
else if (midiMsg.isProgramChange()) {
program = midiMsg.getProgramChangeNumber();
plugInst->setCurrentProgram(program);
}
midiSeqPos++;
}
else {
break;
}
}
playHead.posInfo.timeInSamples = t;
playHead.posInfo.timeInSeconds = t / sampleRate;
AudioBuffer<float> blockAudioBuffer(entireAudioBuffer.getNumChannels(), blockSize);
blockAudioBuffer.clear();
graph->processBlock(blockAudioBuffer, midiBuffer);
for (int ch = 0; ch < entireAudioBuffer.getNumChannels(); ++ch) {
entireAudioBuffer.addFrom(ch, t, blockAudioBuffer, ch, 0, blockSize);
}
}
if (outWavFile.exists()) {
outWavFile.deleteFile();
}
FileOutputStream* fileOutputStream = outWavFile.createOutputStream();
WavAudioFormat wavFormat;
StringPairArray metadataValues;
juce::AudioFormatWriter* wavFormatWriter = wavFormat.createWriterFor(
fileOutputStream, sampleRate, 2, 16, metadataValues, 0);
bool writeAudioDataRet = wavFormatWriter->writeFromAudioSampleBuffer(entireAudioBuffer, 0, entireAudioBuffer.getNumSamples());
wavFormatWriter->flush();
cout << "Done writing to output file " << outWavFile.getFileName() << " . Write return value: "
<< (int)writeAudioDataRet << endl;
delete wavFormatWriter;
}
else {
cerr << "Could not find plugin from file " << plugFile << endl;
}
}
return 0;
}