-Added metronome to APC, updated GUI respond to metro event

main
Harry van Haaren 2013-10-09 00:15:31 +01:00
parent a95ab5d82b
commit 2f88994b2d
9 changed files with 73 additions and 9 deletions

View File

@ -48,6 +48,8 @@ int GenericMIDI::registerComponents()
MidiIO* m = static_cast<MidiIO*>(this);
jack->registerMidiIO( m );
return LUPPP_RETURN_OK;
}
std::string GenericMIDI::getName()
@ -79,6 +81,24 @@ void GenericMIDI::recordArm(int t, bool enabled)
}
}
void GenericMIDI::metronomeEnable(bool enabled)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++)
{
Binding* b = actionToMidi.at(i);
if ( b->action == METRONOME_ACTIVE )
{
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
data[2] = enabled ? 127 : 0;
writeMidi( data );
return;
}
}
}
void GenericMIDI::trackSend(int t, int send, float v)
{
@ -348,7 +368,7 @@ void GenericMIDI::midi(unsigned char* midi)
int data = midi[1];
float value = midi[2] / 127.f;
LUPPP_NOTE("GenericMIDI::midi() %i %i %f", status, data, value );
//LUPPP_NOTE("GenericMIDI::midi() %i %i %f", status, data, value );
// iterate over bindings, execute binding action if matches
for(unsigned int i = 0; i < midiToAction.size(); i++)
@ -357,7 +377,7 @@ void GenericMIDI::midi(unsigned char* midi)
if ( b->status == status && b->data == data )
{
LUPPP_NOTE("Executing action %i, value %f, b->active %i", b->action, value, int(b->active) );
//LUPPP_NOTE("Executing action %i, value %f, b->active %i", b->action, value, int(b->active) );
switch( b->action )
{
@ -384,6 +404,10 @@ void GenericMIDI::midi(unsigned char* midi)
break;
case Event::METRONOME_ACTIVE:
jack->getLogic()->metronomeEnable( b->active );
break;
case Event::MASTER_VOL: jack->getLogic()->trackVolume( -1 , value ); break;
}
}
@ -411,14 +435,12 @@ void GenericMIDI::setSceneState(int t, int scene, GridLogic::State s)
data[1] = b->data;
data[2] = it->second;
LUPPP_NOTE("GenericMIDI::sceneState() writing event %i, %i, %i", data[0],data[1],data[2] );
//LUPPP_NOTE("GenericMIDI::sceneState() writing event %i, %i, %i", data[0],data[1],data[2] );
writeMidi( data );
}
}
}
}
LUPPP_NOTE("GenericMIDI::sceneState()" );
}
@ -460,7 +482,7 @@ void GenericMIDI::launchScene( int scene )
data[0] = b->status;
data[1] = b->data + scene;
data[2] = 127;
LUPPP_NOTE("this = %i GenericMIDI::launchScene()", this );
//LUPPP_NOTE("this = %i GenericMIDI::launchScene()", this );
writeMidi( data );
return;
@ -681,6 +703,9 @@ Binding* GenericMIDI::setupBinding( cJSON* binding )
else if ( strcmp( actionJson->valuestring, "master:volume" ) == 0 ) {
tmp->action = Event::MASTER_VOL;
}
else if ( strcmp( actionJson->valuestring, "metronome:active" ) == 0 ) {
tmp->action = Event::METRONOME_ACTIVE;
}
// check for valid event: otherwise pass
if ( tmp->action != Event::EVENT_NULL )

View File

@ -55,6 +55,8 @@ class GenericMIDI : public Controller, public MidiIO
/// track actions
//void mute(int t, bool b);
void metronomeEnable(bool b);
void launchScene( int scene );
void volume(int t, float f);

View File

@ -21,6 +21,12 @@ void LupppGUI::masterVolume(float f)
writeToGuiRingbuffer( &e );
}
void LupppGUI::metronomeEnable(bool r)
{
EventMetronomeActive e( r );
writeToGuiRingbuffer( &e );
}
void LupppGUI::recordArm(int t, bool r)
{
EventTrackRecordArm e( t, r );

View File

@ -16,6 +16,8 @@ class LupppGUI : public Controller
void masterVolume(float f);
void metronomeEnable(bool b);
void trackSend(int t, int send, float r);
void trackSendActive(int t, int send, bool a);

View File

@ -61,7 +61,7 @@ void handleGuiEvents()
if ( availableRead >= sizeof(EventMetronomeActive) ) {
EventMetronomeActive ev(false);
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventMetronomeActive) );
//gui->getMetronome()->setActive(ev.active);
gui->getMasterTrack()->metronomeEnable(ev.active);
} break; }
case Event::LOOPER_STATE: {
if ( availableRead >= sizeof(EventLooperState) ) {

View File

@ -203,6 +203,11 @@ void GMasterTrack::setBpm( int b )
tempoDial.value( ( bpm - 60 ) / 160.f );
}
void GMasterTrack::metronomeEnable( bool b )
{
metronomeButton.value( b );
}
int GMasterTrack::getBpm()
{
return bpm;

View File

@ -35,6 +35,8 @@ class GMasterTrack : public Fl_Group
void setTapTempo( bool b );
void setBarBeat(int b, int beat);
void metronomeEnable( bool b );
Avtk::Volume* getInputVolume();
Avtk::Volume* getVolume();
Avtk::ClipSelector* getClipSelector();

View File

@ -212,10 +212,10 @@ void Gui::selectLoadSample( int track, int scene )
Gui::Gui() :
samplerate( 0 ),
window(1110,650),
diskReader( new DiskReader() ),
diskWriter( new DiskWriter() ),
samplerate( 0 )
diskWriter( new DiskWriter() )
{
LUPPP_NOTE( "%s", "Gui()" );

View File

@ -9,6 +9,15 @@
"inputBindings" : [
{
"__COMMENT__" : "Metronome button",
"action" : "metronome:active",
"status" : 144,
"data" : 65,
"active" : 1,
"toggle" : 1
},
{
"__COMMENT__" : "Shift key: samples a clip into gridLogic",
"action" : "gridlogic:selectclipenable",
@ -933,6 +942,19 @@
},
{
"__COMMENT__" : "Metronome button",
"action" : "metronome:active",
"status" : 144,
"data" : 65,
"active" : 1
},
{
"action" : "metronome:active",
"status" : 128,
"data" : 65,
"active" : 0
},