示例#1
0
/**
 *
 * External midi message listener
 *
 */
void FluidPlayer::newMidiMessage(ofxMidiMessage & eventArgs) {

    lastMessage = eventArgs;

    switch (eventArgs.status) {
    case MIDI_START:
        ofLog(OF_LOG_NOTICE, eventArgs.toString());
        startPerformance();
        break;
    case MIDI_STOP:
        ofLog(OF_LOG_NOTICE, eventArgs.toString());
        stopPerformance();
    case MIDI_SONG_POS_POINTER:
        ofLog(OF_LOG_NOTICE, eventArgs.toString());
        break;
    case MIDI_TIME_CLOCK:
        if(isPlaying) musicTick();
        break;
    default:
        break;
    }


}
示例#2
0
void chMidiListener::newMidiMessage(ofxMidiMessage& msg) {
    
    // hackhack
    if (msg.status == MIDI_NOTE_ON && msg.velocity == 0) {
        msg.status = MIDI_NOTE_OFF;
    }

    ofLogNotice() << "midiListener: " << msg.toString() << msg.pitch;

    // Play every channel
    forwardMidiMessageToSynth(msg);

    // Only remember channel 1 for keydowns
    if (msg.channel == 1) {
        if (msg.velocity == 0 || msg.status == MIDI_NOTE_OFF) {
            keydown.erase(std::remove(keydown.begin(), keydown.end(), msg.pitch), keydown.end());
        } else {
            keydown.push_back(msg.pitch);
        }
    }

}
//--------------------------------------------------------------
void sketchApp::newMidiMessage(ofxMidiMessage& msg) {
	if (mVerboseMidiLogging.get()) {
		ofLog() << msg.toString() << endl;
	}
	mMidiMessage = msg;
}