mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-06 01:21:38 -05:00
-Initial controller MIDI binding hacked in
This commit is contained in:
parent
49b95653bc
commit
62dd928d9b
8 changed files with 61 additions and 3 deletions
|
@ -22,7 +22,7 @@ GenericMIDI::GenericMIDI(std::string file) :
|
||||||
name = "generic";
|
name = "generic";
|
||||||
|
|
||||||
// load the JSON config file
|
// load the JSON config file
|
||||||
int result = loadController( file );
|
int result = LUPPP_RETURN_OK; //loadController( file );
|
||||||
|
|
||||||
if ( result == LUPPP_RETURN_OK )
|
if ( result == LUPPP_RETURN_OK )
|
||||||
{
|
{
|
||||||
|
@ -371,6 +371,13 @@ void GenericMIDI::midi(unsigned char* midi)
|
||||||
|
|
||||||
//LUPPP_NOTE("GenericMIDI::midi() %i %i %f", status, data, value );
|
//LUPPP_NOTE("GenericMIDI::midi() %i %i %f", status, data, value );
|
||||||
|
|
||||||
|
// create new MIDI binding?
|
||||||
|
if ( jack->bindingEventRecordEnable )
|
||||||
|
{
|
||||||
|
setupBinding( jack->bindingEventType, status, data, 0 );
|
||||||
|
jack->bindingEventRecordEnable = false;
|
||||||
|
}
|
||||||
|
|
||||||
// iterate over bindings, execute binding action if matches
|
// iterate over bindings, execute binding action if matches
|
||||||
for(unsigned int i = 0; i < midiToAction.size(); i++)
|
for(unsigned int i = 0; i < midiToAction.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -597,6 +604,20 @@ int GenericMIDI::loadController( std::string file )
|
||||||
return LUPPP_RETURN_OK;
|
return LUPPP_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenericMIDI::setupBinding( LupppAction eventType, int midiStatus, int midiData, int track )
|
||||||
|
{
|
||||||
|
LUPPP_NOTE("MIDI binding, track %d, from eventType %d to %d, %d", track, eventType, midiStatus, midiData );
|
||||||
|
|
||||||
|
Binding* tmp = new Binding();
|
||||||
|
|
||||||
|
tmp->action = eventType;
|
||||||
|
tmp->status = midiStatus;
|
||||||
|
tmp->data = midiData;
|
||||||
|
tmp->track = track;
|
||||||
|
|
||||||
|
midiToAction.push_back( tmp );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Binding* GenericMIDI::setupBinding( cJSON* binding )
|
Binding* GenericMIDI::setupBinding( cJSON* binding )
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "../cjson/cJSON.h"
|
#include "../cjson/cJSON.h"
|
||||||
#include "../observer/midi.hxx"
|
#include "../observer/midi.hxx"
|
||||||
|
|
||||||
/// for future compatibility, LupppAction might be a string mapped to a unique number
|
/// a LupppAction represents the Event type, as from Event.hxx
|
||||||
typedef int LupppAction;
|
typedef int LupppAction;
|
||||||
|
|
||||||
class Binding
|
class Binding
|
||||||
|
@ -83,6 +83,9 @@ class GenericMIDI : public Controller, public MidiIO
|
||||||
|
|
||||||
void process(int nframes);
|
void process(int nframes);
|
||||||
|
|
||||||
|
// for adding bindings from MIDI / GUI event pair
|
||||||
|
void setupBinding( LupppAction eventType, int midiStatus, int midiData, int track );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
STATUS stat;
|
STATUS stat;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,16 @@ void ControllerUpdater::registerController( Controller* controller )
|
||||||
controller->registerComponents();
|
controller->registerComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controller* ControllerUpdater::getController(std::string name)
|
||||||
|
{
|
||||||
|
// FIXME: find controller based on name / ID?
|
||||||
|
LUPPP_WARN("FIXME, returning 0th element!!");
|
||||||
|
if ( c.size() >= 1 )
|
||||||
|
return c.at(0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ControllerUpdater::reset()
|
void ControllerUpdater::reset()
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < c.size(); i++)
|
for(unsigned int i = 0; i < c.size(); i++)
|
||||||
|
|
|
@ -31,6 +31,9 @@ class ControllerUpdater
|
||||||
|
|
||||||
void registerController( Controller* controller );
|
void registerController( Controller* controller );
|
||||||
|
|
||||||
|
// returns a Controller* by its name
|
||||||
|
Controller* getController(std::string name);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
void mute(int t, bool b);
|
void mute(int t, bool b);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Event
|
||||||
INPUT_TO_SIDE_KEY,
|
INPUT_TO_SIDE_KEY,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum EVENT_TYPE {
|
||||||
// default event type
|
// default event type
|
||||||
EVENT_NULL = 0,
|
EVENT_NULL = 0,
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,14 @@ void handleDspEvents()
|
||||||
// recheck the size against the actual event size
|
// recheck the size against the actual event size
|
||||||
if ( availableRead >= e->size() )
|
if ( availableRead >= e->size() )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// MIDI binding creation: sample the Event.
|
||||||
|
if( jack->bindingEventRecordEnable )
|
||||||
|
{
|
||||||
|
printf("event %i\n", e->type() );
|
||||||
|
jack->bindingEventType = e->type();
|
||||||
|
}
|
||||||
|
|
||||||
switch ( e->type() )
|
switch ( e->type() )
|
||||||
{
|
{
|
||||||
case Event::QUIT: {
|
case Event::QUIT: {
|
||||||
|
|
|
@ -52,6 +52,13 @@ Jack::Jack() :
|
||||||
// CAREFUL: setup the size by default: otherwise malloc() is called on push_back
|
// CAREFUL: setup the size by default: otherwise malloc() is called on push_back
|
||||||
midiIO.reserve( CONTROLLERS_PREALLOC );
|
midiIO.reserve( CONTROLLERS_PREALLOC );
|
||||||
|
|
||||||
|
|
||||||
|
// MIDI binding stuff
|
||||||
|
bindingEventRecordEnable = true;
|
||||||
|
bindingTrack = 0;
|
||||||
|
bindingEventType = EVENT_NULL;
|
||||||
|
|
||||||
|
|
||||||
//GenericMIDI* tmp = new GenericMIDI("akai_apc.ctlr");
|
//GenericMIDI* tmp = new GenericMIDI("akai_apc.ctlr");
|
||||||
//tmp->registerComponents();
|
//tmp->registerComponents();
|
||||||
//controllerUpdater->registerController( static_cast<Controller*>(tmp) );
|
//controllerUpdater->registerController( static_cast<Controller*>(tmp) );
|
||||||
|
|
|
@ -74,6 +74,11 @@ class Jack
|
||||||
{
|
{
|
||||||
return client;
|
return client;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// MIDI binding creation
|
||||||
|
bool bindingEventRecordEnable;
|
||||||
|
int bindingTrack;
|
||||||
|
int bindingEventType;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
jack_client_t* client;
|
jack_client_t* client;
|
||||||
|
@ -142,6 +147,7 @@ class Jack
|
||||||
// UI update variables
|
// UI update variables
|
||||||
int uiUpdateCounter;
|
int uiUpdateCounter;
|
||||||
int uiUpdateConstant;
|
int uiUpdateConstant;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LUPPP_JACK_H
|
#endif // LUPPP_JACK_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue