mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 17:11:40 -05:00
-MIDI binding enable added to Options dialog, allows binding of most functionality: no save feature yet.
This commit is contained in:
parent
62dd928d9b
commit
ca0fab2d17
9 changed files with 70 additions and 16 deletions
|
@ -374,7 +374,12 @@ void GenericMIDI::midi(unsigned char* midi)
|
|||
// create new MIDI binding?
|
||||
if ( jack->bindingEventRecordEnable )
|
||||
{
|
||||
setupBinding( jack->bindingEventType, status, data, 0 );
|
||||
setupBinding( jack->bindingEventType, status, data,
|
||||
jack->bindingTrack,
|
||||
jack->bindingScene,
|
||||
jack->bindingSend,
|
||||
jack->bindingActive );
|
||||
|
||||
jack->bindingEventRecordEnable = false;
|
||||
}
|
||||
|
||||
|
@ -604,17 +609,22 @@ int GenericMIDI::loadController( std::string file )
|
|||
return LUPPP_RETURN_OK;
|
||||
}
|
||||
|
||||
void GenericMIDI::setupBinding( LupppAction eventType, int midiStatus, int midiData, int track )
|
||||
void GenericMIDI::setupBinding( LupppAction eventType, int midiStatus, int midiData, int track, int scene, int send, int active )
|
||||
{
|
||||
LUPPP_NOTE("MIDI binding, track %d, from eventType %d to %d, %d", track, eventType, midiStatus, midiData );
|
||||
|
||||
// FIXME: NON-RT Have stack of Bindings() available, or push in GUI thread?
|
||||
Binding* tmp = new Binding();
|
||||
|
||||
tmp->action = eventType;
|
||||
tmp->status = midiStatus;
|
||||
tmp->data = midiData;
|
||||
tmp->track = track;
|
||||
tmp->scene = scene;
|
||||
tmp->send = send;
|
||||
tmp->active = active;
|
||||
|
||||
// FIXME: Could allocate memory! Issue? Shouldn't be binding during performance?
|
||||
midiToAction.push_back( tmp );
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class Binding
|
|||
int scene;
|
||||
int send;
|
||||
|
||||
/// maps from Gridlogic::State to MIDI output value from binding
|
||||
std::map<int,int> clipStateMap;
|
||||
};
|
||||
|
||||
|
@ -84,7 +85,7 @@ class GenericMIDI : public Controller, public MidiIO
|
|||
void process(int nframes);
|
||||
|
||||
// for adding bindings from MIDI / GUI event pair
|
||||
void setupBinding( LupppAction eventType, int midiStatus, int midiData, int track );
|
||||
void setupBinding( LupppAction eventType, int midiStatus, int midiData, int track, int scene, int send, int active );
|
||||
|
||||
private:
|
||||
STATUS stat;
|
||||
|
|
|
@ -89,7 +89,9 @@ namespace Event
|
|||
|
||||
SAMPLERATE,
|
||||
|
||||
// Controller
|
||||
CONTROLLER_INSTANCE,
|
||||
CONTROLLER_BIND_ENABLE,
|
||||
|
||||
QUIT,
|
||||
|
||||
|
@ -109,6 +111,15 @@ class EventBase
|
|||
virtual uint32_t size() = 0;
|
||||
};
|
||||
|
||||
class EventControllerBindEnable : public EventBase
|
||||
{
|
||||
public:
|
||||
int type() { return int(CONTROLLER_BIND_ENABLE); }
|
||||
uint32_t size() { return sizeof(EventControllerBindEnable); }
|
||||
bool enable;
|
||||
EventControllerBindEnable(bool e=false):enable(e){}
|
||||
};
|
||||
|
||||
class EventGridSelectClipEvent : public EventBase
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -40,7 +40,7 @@ void handleDspEvents()
|
|||
// MIDI binding creation: sample the Event.
|
||||
if( jack->bindingEventRecordEnable )
|
||||
{
|
||||
printf("event %i\n", e->type() );
|
||||
//printf("event %i\n", e->type() );
|
||||
jack->bindingEventType = e->type();
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,8 @@ void handleDspEvents()
|
|||
if ( availableRead >= sizeof(EventGridEvent) ) {
|
||||
EventGridEvent ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridEvent) );
|
||||
jack->bindingTrack = ev.track;
|
||||
jack->bindingScene = ev.scene;
|
||||
if ( ev.pressed )
|
||||
jack->getGridLogic()->pressed( ev.track, ev.scene );
|
||||
else
|
||||
|
@ -119,6 +121,7 @@ void handleDspEvents()
|
|||
EventGridLaunchScene ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridLaunchScene) );
|
||||
jack->getGridLogic()->launchScene( ev.scene );
|
||||
jack->bindingScene = ev.scene;
|
||||
break; }
|
||||
|
||||
case Event::GRID_SELECT_CLIP_ENABLE: {
|
||||
|
@ -196,6 +199,7 @@ void handleDspEvents()
|
|||
EventTrackVol ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTrackVol) );
|
||||
jack->getLogic()->trackVolume( ev.track, ev.vol );
|
||||
jack->bindingTrack = ev.track;
|
||||
break; }
|
||||
}
|
||||
|
||||
|
@ -204,6 +208,8 @@ void handleDspEvents()
|
|||
EventTrackRecordArm ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTrackRecordArm) );
|
||||
jack->getLogic()->trackRecordArm( ev.track, ev.recordArm );
|
||||
jack->bindingTrack = ev.track;
|
||||
jack->bindingActive = ev.recordArm;
|
||||
break; }
|
||||
}
|
||||
|
||||
|
@ -212,6 +218,8 @@ void handleDspEvents()
|
|||
EventTrackSendActive ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTrackSendActive) );
|
||||
jack->getLogic()->trackSendActive( ev.track, ev.send, ev.active );
|
||||
jack->bindingTrack = ev.track;
|
||||
jack->bindingActive = ev.active;
|
||||
} break; }
|
||||
|
||||
case Event::TRACK_SEND: {
|
||||
|
@ -219,6 +227,8 @@ void handleDspEvents()
|
|||
EventTrackSend ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTrackSend) );
|
||||
jack->getLogic()->trackSend( ev.track, ev.send, ev.value );
|
||||
jack->bindingTrack = ev.track;
|
||||
jack->bindingSend = ev.send;
|
||||
} break; }
|
||||
|
||||
|
||||
|
@ -245,6 +255,13 @@ void handleDspEvents()
|
|||
jack->getControllerUpdater()->registerController( static_cast<Controller*>(ev.controller) );
|
||||
} break; }
|
||||
|
||||
case Event::CONTROLLER_BIND_ENABLE: {
|
||||
if ( availableRead >= sizeof(EventControllerBindEnable) ) {
|
||||
EventControllerBindEnable ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventControllerBindEnable) );
|
||||
jack->bindingEventRecordEnable = ev.enable;
|
||||
} break; }
|
||||
|
||||
default:
|
||||
{
|
||||
cout << "DSP: Unkown message!! Will clog ringbuffer" << endl;
|
||||
|
|
|
@ -82,7 +82,7 @@ void gtrack_sendDial_cb(Fl_Widget *w, void *data)
|
|||
GTrack* track = (GTrack*) data;
|
||||
EventTrackSend e( track->ID, SEND_POSTFADER, ((Avtk::Dial*)w)->value() );
|
||||
writeToDspRingbuffer( &e );
|
||||
printf("track %i reverb send %f\n", track->ID, ((Avtk::Dial*)w)->value() );
|
||||
//printf("track %i reverb send %f\n", track->ID, ((Avtk::Dial*)w)->value() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,7 +101,7 @@ void gtrack_key_cb(Fl_Widget *w, void *data)
|
|||
EventTrackSendActive e( track->ID, SEND_KEY, false );
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
printf("track %i post send %s\n", track->ID, b ? "off" : "on" );
|
||||
//printf("track %i post send %s\n", track->ID, b ? "off" : "on" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +110,7 @@ void gtrack_xsideDial_cb(Fl_Widget *w, void *data)
|
|||
GTrack* track = (GTrack*) data;
|
||||
EventTrackSend e( track->ID, SEND_XSIDE, ((Avtk::Dial*)w)->value() );
|
||||
writeToDspRingbuffer( &e );
|
||||
printf("track %i side send %f\n", track->ID, ((Avtk::Dial*)w)->value() );
|
||||
//printf("track %i side send %f\n", track->ID, ((Avtk::Dial*)w)->value() );
|
||||
}
|
||||
|
||||
void gtrack_vol_cb(Fl_Widget *w, void *data)
|
||||
|
@ -118,7 +118,7 @@ void gtrack_vol_cb(Fl_Widget *w, void *data)
|
|||
GTrack* track = (GTrack*) data;
|
||||
EventTrackVol e( track->ID, ((Avtk::Volume*)w)->value() );
|
||||
writeToDspRingbuffer( &e );
|
||||
printf("track %i vol %f\n", track->ID, ((Avtk::Dial*)w)->value() );
|
||||
//printf("track %i vol %f\n", track->ID, ((Avtk::Dial*)w)->value() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,7 +138,7 @@ void gtrack_send_cb(Fl_Widget *w, void *data)
|
|||
EventTrackSendActive e( track->ID, SEND_POSTFADER, 0.0f );
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
printf("track %i reverb send %s\n", track->ID, b ? "true" : "false" );
|
||||
//printf("track %i reverb send %s\n", track->ID, b ? "true" : "false" );
|
||||
}
|
||||
void gtrack_record_cb(Fl_Widget *w, void *data)
|
||||
{
|
||||
|
@ -155,6 +155,6 @@ void gtrack_record_cb(Fl_Widget *w, void *data)
|
|||
EventTrackRecordArm e( track->ID, 0.0f );
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
printf("track %i record Arm %s\n", track->ID, b ? "off" : "on" );
|
||||
//printf("track %i record Arm %s\n", track->ID, b ? "off" : "on" );
|
||||
}
|
||||
|
||||
|
|
|
@ -148,6 +148,13 @@ void Gui::showOptions()
|
|||
optionWindow->show();
|
||||
}
|
||||
|
||||
void Gui::writeBindEnable(Fl_Widget* w, void*)
|
||||
{
|
||||
LUPPP_NOTE("MIDI bind mode enabled");
|
||||
EventControllerBindEnable e( true );
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
|
||||
void Gui::selectLoadController(Fl_Widget* w, void*)
|
||||
{
|
||||
// FIXME: refactor
|
||||
|
@ -262,7 +269,9 @@ Gui::Gui() :
|
|||
// setup Options dialog
|
||||
optionWindow = new Fl_Double_Window(400,300,"Options");
|
||||
Avtk::Button* ctlrButton = new Avtk::Button(5, 25, 200, 20, "Add Controller");
|
||||
Avtk::LightButton* bindEnable = new Avtk::LightButton(5, 55, 200, 20, "Bind Enable");
|
||||
ctlrButton->callback( selectLoadController );
|
||||
bindEnable->callback( writeBindEnable );
|
||||
optionWindow->end();
|
||||
|
||||
// Create AudioEditor after window.end() has been called
|
||||
|
|
|
@ -52,7 +52,8 @@ class Gui
|
|||
|
||||
/// allows the user to select a Controller definition
|
||||
static void selectLoadController(Fl_Widget* w, void*);
|
||||
|
||||
|
||||
|
||||
int samplerate;
|
||||
|
||||
private:
|
||||
|
@ -72,6 +73,8 @@ class Gui
|
|||
// FIXME: refactor tooltip code out..?
|
||||
std::string tooltip;
|
||||
Fl_Box* tooltipLabel;
|
||||
|
||||
static void writeBindEnable(Fl_Widget* w, void*);
|
||||
};
|
||||
|
||||
#endif // LUPPP_GUI
|
||||
|
|
|
@ -77,8 +77,11 @@ class Jack
|
|||
|
||||
// MIDI binding creation
|
||||
bool bindingEventRecordEnable;
|
||||
int bindingTrack;
|
||||
int bindingEventType;
|
||||
int bindingTrack;
|
||||
int bindingScene;
|
||||
int bindingSend;
|
||||
int bindingActive;
|
||||
|
||||
private:
|
||||
jack_client_t* client;
|
||||
|
|
|
@ -80,14 +80,14 @@ void MidiIO::process(int nframes)
|
|||
// get port buffers and setup
|
||||
void* inputBuffer = (void*) jack_port_get_buffer( jackInputPort, nframes );
|
||||
|
||||
jack_midi_event_t in_event;
|
||||
jack_midi_event_t event;
|
||||
int index = 0;
|
||||
int event_count = (int) jack_midi_get_event_count( inputBuffer );
|
||||
while ( index < event_count )
|
||||
{
|
||||
jack_midi_event_get(&in_event, inputBuffer, index);
|
||||
midi( (unsigned char*) &in_event.buffer[0] );
|
||||
printf( "MIDI %i %i %i\n", int(in_event.buffer[0]), int(in_event.buffer[1]), int(in_event.buffer[2]) );
|
||||
jack_midi_event_get(&event, inputBuffer, index);
|
||||
midi( (unsigned char*) &event.buffer[0] );
|
||||
//printf( "MIDI %i %i %i\n", int(event.buffer[0]), int(event.buffer[1]), int(event.buffer[2]) );
|
||||
index++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue