diff --git a/src/controller/genericmidi.cxx b/src/controller/genericmidi.cxx index 2146450..99ba5be 100644 --- a/src/controller/genericmidi.cxx +++ b/src/controller/genericmidi.cxx @@ -452,22 +452,18 @@ int GenericMIDI::loadController( std::string file ) - cJSON* feedbackBindings = cJSON_GetObjectItem( controllerJson, "feedbackBindings"); - if ( feedbackBindings ) + cJSON* outputBindings = cJSON_GetObjectItem( controllerJson, "outputBindings"); + if ( outputBindings ) { - int nBindings = cJSON_GetArraySize( feedbackBindings ); + int nBindings = cJSON_GetArraySize( outputBindings ); for(int i = 0; i < nBindings; i++ ) { - cJSON* binding = cJSON_GetArrayItem( feedbackBindings, i ); + cJSON* bindingJson = cJSON_GetArrayItem( outputBindings, i ); + Binding* tmp = setupBinding( bindingJson ); + if ( tmp ) + actionToMidi.push_back( tmp ); - cJSON* action = cJSON_GetObjectItem( binding, "action" ); - - cJSON* status = cJSON_GetObjectItem( binding, "status" ); - cJSON* data = cJSON_GetObjectItem( binding, "data" ); - - LUPPP_NOTE("Binding from %s to %i %i", action->valuestring, status->valueint, data->valueint ); - - //actionToMidi.push_back( Binding(status->valueint, data->valueint, action->valuestring ) ); + //LUPPP_NOTE("Binding from %s to %i %i", actionJ->valuestring, statusJson->valueint, dataJson->valueint ); } } else @@ -546,9 +542,12 @@ Binding* GenericMIDI::setupBinding( cJSON* binding ) tmp->active = 0; // release event } + else if ( strcmp( actionJson->valuestring, "footpedal1" ) == 0 ) { + //tmp->action = Event::MASTER_VOL; + } else if ( strcmp( actionJson->valuestring, "master:volume" ) == 0 ) { tmp->action = Event::MASTER_VOL; - } + } // check for valid event: otherwise pass if ( tmp->action != Event::EVENT_NULL ) diff --git a/src/jack.cxx b/src/jack.cxx index 17da703..be4738a 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -254,6 +254,13 @@ int Jack::process (jack_nframes_t nframes) memset( buffers.audio[Buffers::SIDECHAIN_KEY] , 0, sizeof(float) * nframes ); memset( buffers.audio[Buffers::SIDECHAIN_SIGNAL] , 0, sizeof(float) * nframes ); + + /// init buffers for each MidiIO + for(unsigned int i = 0; i < midiIO.size(); i++ ) + { + midiIO.at(i)->initBuffers( nframes ); + } + /// do events from the ringbuffer handleDspEvents(); diff --git a/src/observer/midi.cxx b/src/observer/midi.cxx index de751f9..9d638f1 100644 --- a/src/observer/midi.cxx +++ b/src/observer/midi.cxx @@ -27,7 +27,7 @@ void MidiIO::writeMidi( unsigned char* data ) } else { - cout << "JC::writeMidi() " << int(data[0]) << ", " << int(data[1]) << ", " << int(data[2]) << endl; + cout << "JC::writeMidi() port = " << jackOutputPort << int(data[0]) << ", " << int(data[1]) << ", " << int(data[2]) << endl; //memcpy( buffer, data, sizeof(unsigned char)*3 ); buffer[0] = data[0]; buffer[1] = data[1]; @@ -56,7 +56,8 @@ void MidiIO::registerMidiPorts(std::string name) if ( jackInputPort && jackOutputPort ) { - LUPPP_NOTE("%i, %i", jackInputPort, jackOutputPort ); + cout << jackOutputPort << endl; + //LUPPP_NOTE("%i, %i", jackInputPort, jackOutputPort ); } else { @@ -65,12 +66,17 @@ void MidiIO::registerMidiPorts(std::string name) } +void MidiIO::initBuffers(int nframes) +{ + // clear the output buffer + void* outputBuffer= (void*) jack_port_get_buffer( jackOutputPort, nframes ); + jack_midi_clear_buffer( outputBuffer ); +} + void MidiIO::process(int nframes) { // get port buffers and setup void* inputBuffer = (void*) jack_port_get_buffer( jackInputPort, nframes ); - void* outputBuffer= (void*) jack_port_get_buffer( jackOutputPort, nframes ); - jack_midi_clear_buffer( outputBuffer ); jack_midi_event_t in_event; int index = 0; diff --git a/src/observer/midi.hxx b/src/observer/midi.hxx index 60bd8a3..d7eda8d 100644 --- a/src/observer/midi.hxx +++ b/src/observer/midi.hxx @@ -25,6 +25,9 @@ class MidiIO /// int status(); + /// gets / clears MIDI buffers + void initBuffers(int nframes); + /// gets called each process() in JACK void process(int nframes); diff --git a/src/tests/lupppTestMaterial/akai_apc.ctlr b/src/tests/lupppTestMaterial/akai_apc.ctlr index d35db25..b8f5a04 100644 --- a/src/tests/lupppTestMaterial/akai_apc.ctlr +++ b/src/tests/lupppTestMaterial/akai_apc.ctlr @@ -8,6 +8,15 @@ "inputBindings" : [ { + "status" : 176, + "data" : 14, + "action" : "master:volume" + }, + + + { + "__COMMENT__" : "track 0", + "status" : 176, "data" : 7, "action" : "track:volume", @@ -16,16 +25,107 @@ { "status" : 176, "data" : 16, - "action" : "track:sendAmount", + "action" : "track:send", "track" : 0 }, { + "status" : 176, + "data" : 20, + "action" : "track:xside", + "track" : 0 + }, + { + "status" : 144, + "data" : 48, + "action" : "track:recordarm", + "track" : 0, + "active" : 1 + }, + { + "status" : 128, + "data" : 48, + "action" : "track:recordarm", + "track" : 0, + "active" : 0 + }, + { + "status" : 144, + "data" : 49, + "action" : "track:keyactive", + "track" : 0, + "active" : 1 + }, + { + "status" : 128, + "data" : 49, + "action" : "track:keyactive", + "track" : 0, + "active" : 0 + }, + { + "status" : 144, + "data" : 50, + "action" : "track:sendactive", + "track" : 0, + "active" : 1 + }, + { + "status" : 128, + "data" : 50, + "action" : "track:sendactive", + "track" : 0, + "active" : 0 + }, + { + "status" : 144, + "data" : 53, + "action" : "track:clippressed", + "track" : 0, + "scene" : 0 + }, + { + "status" : 144, + "data" : 54, + "action" : "track:clippressed", + "track" : 0, + "scene" : 1 + }, + { + "status" : 144, + "data" : 55, + "action" : "track:clippressed", + "track" : 0, + "scene" : 2 + }, + { + "status" : 144, + "data" : 56, + "action" : "track:clippressed", + "track" : 0, + "scene" : 3 + }, + { + "status" : 144, + "data" : 57, + "action" : "track:clippressed", + "track" : 0, + "scene" : 4 + }, + + + { + "__COMMENT__" : "track 1", + "status" : 177, "data" : 7, "action" : "track:volume", "track" : 1 }, + + { + "__COMMENT__" : "track 2", + "status" : 178, "data" : 7, "action" : "track:volume", @@ -64,7 +164,7 @@ { "status" : 176, "data" : 64, - "action" : "footpedal" + "action" : "footpedal1" } ],