Closed brucelane closed 9 years ago
This may help...
setup the event bind in setup with something like this...
//////////////////////////////////////////////////////////////////////////
//! Midi setup
if ( midiIn.mPortCount > 0 ) {
if ( midiIn.OpenPort( 0 ) ) {
midiIn.mMidiInCallback = std::bind( &MyApp::midiInput, this, std::placeholders::_1 );
CI_LOG_I( "Found MIDI input device: " << midiIn.mPortName );
} else {
CI_LOG_I( "No MIDI devices found..." );
}
}
then something like this for the event function...
void MyApp::midiInput( midi::MidiMessage msg ) {
switch ( msg.StatusCode ) {
case MIDI_NOTE_ON: {
CI_LOG_I( msg.Name << " ON - Pitch: " << toString( msg.Pitch ) << ", Velocity: " << toString( msg.Velocity ) );
if ( msg.Velocity > 0 ) {
bgColor = Color( CM_HSV, glm::vec3( lmap( ( float ) msg.Pitch, 0.0f, 127.0f, 0.0f, 1.0f ), 1.0f, 1.0f ) );
} else {
bgColor = Color::black();
}
} break;
case MIDI_NOTE_OFF: {
CI_LOG_I( msg.Name << " OFF - Pitch: " << toString( msg.Pitch ) << ", Velocity: " << toString( msg.Velocity ) );
bgColor = Color::black();
} break;
case MIDI_CONTROL_CHANGE: {
CI_LOG_I( msg.Name << " - Control: " << toString( msg.Control ) << ", Value: " << toString( msg.Value ) );
if ( msg.Value > 0 ) {
bgColor = Color( CM_HSV, glm::vec3( lmap( ( float ) msg.Control, 0.0f, 127.0f, 0.0f, 1.0f ), 1.0f, 1.0f ) );
} else {
bgColor = Color::black();
}
} break;
case MIDI_PITCH_BEND: {
} break;
default: {
} break;
}
}
ah ok, classic! thank you very much
Sorry, I was not paying attention to github for a while and my notifications are off.
Yeah, I'm planning to revisit some of my repositories soon, and this one is on top of my list
hi Martin or Hunter, please update to 0.9? I switched to hluisi's repo for my fork, seems good but I can't figure out the way to use MidiInCallback: I tryed mMidiIn0.mMidiInCallback([&](midi::MidiMessage msg){}) or mMidiIn1.mMidiInCallback = &MessageRouter::midiListener without success