Mercurial > hg > beaglert
diff projects/basic_midi/render.cpp @ 226:af1e662400fc mergingClockSync
Added argument to callback
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sun, 13 Mar 2016 03:31:19 +0000 |
parents | 97faaf985164 |
children |
line wrap: on
line diff
--- a/projects/basic_midi/render.cpp Tue Mar 08 16:03:14 2016 +0000 +++ b/projects/basic_midi/render.cpp Sun Mar 13 03:31:19 2016 +0000 @@ -18,7 +18,10 @@ int gVelocity = 0; float gSamplingPeriod = 0; -void midiMessageCallback(MidiChannelMessage message){ +void midiMessageCallback(MidiChannelMessage message, void* arg){ + if(arg != NULL){ + rt_printf("Message from midi port %d: ", *(int*)arg); + } message.prettyPrint(); if(message.getType() == kmmNoteOn){ gFreq = powf(2, (message.getDataByte(0)-69)/12.0f) * 440; @@ -37,14 +40,15 @@ // // Return true on success; returning false halts the program. Midi midi; +int gMidiPort0 = 0; bool setup(BeagleRTContext *context, void *userData) { - midi.readFrom(0); - midi.writeTo(0); + midi.readFrom(gMidiPort0); + midi.writeTo(gMidiPort0); midi.enableParser(true); - midi.setParserCallback(midiMessageCallback); + midi.setParserCallback(midiMessageCallback, &gMidiPort0); if(context->analogFrames == 0) { - rt_printf("Error: this example needs the matrix enabled\n"); + rt_printf("Error: this example needs the analog I/O to be enabled\n"); return false; } gSamplingPeriod = 1/context->audioSampleRate;