diff --git a/src/event.hxx b/src/event.hxx index 1395365..9828d80 100644 --- a/src/event.hxx +++ b/src/event.hxx @@ -57,9 +57,10 @@ class EventLooperState : public EventBase int type() { return int(LOOPER_STATE); } uint32_t size() { return sizeof(EventLooperState); } + int track; Looper::State state; EventLooperState(){} - EventLooperState(Looper::State s) : state(s){} + EventLooperState(int t, Looper::State s) : track(t), state(s){} }; class EventLoadSample : public EventBase diff --git a/src/eventhandlerdsp.cxx b/src/eventhandlerdsp.cxx index d979ebb..d733034 100644 --- a/src/eventhandlerdsp.cxx +++ b/src/eventhandlerdsp.cxx @@ -60,7 +60,7 @@ void handleDspEvents() if ( availableRead >= sizeof(EventLooperState) ) { EventLooperState ev; jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperState) ); - jack->setLooperState( 0, ev.state ); + jack->setLooperState( ev.track, ev.state ); } break; } default: { diff --git a/src/gtrack.hxx b/src/gtrack.hxx index 2ef04c9..4e5be1f 100644 --- a/src/gtrack.hxx +++ b/src/gtrack.hxx @@ -18,23 +18,28 @@ using namespace std; static void button_callback(Fl_Widget *w, void *data) { - cout << "Button " << w->label() << " clicked" << endl; + int track = *(int*)data; + cout << "Button " << *(int*)data << w->label() << " clicked" << endl; if ( strcmp( w->label() , "Rec" ) == 0 ) { - EventLooperState e = EventLooperState(Looper::STATE_RECORDING); + EventLooperState e = EventLooperState(track,Looper::STATE_RECORDING); writeToDspRingbuffer( &e ); } else if ( strcmp( w->label() , "Play" ) == 0 ) { - EventLooperState e = EventLooperState(Looper::STATE_PLAYING); + EventLooperState e = EventLooperState(track,Looper::STATE_PLAYING); writeToDspRingbuffer( &e ); } else if ( strcmp( w->label() , "Stop" ) == 0 ) { - EventLooperState e = EventLooperState(Looper::STATE_STOPPED); + EventLooperState e = EventLooperState(track,Looper::STATE_STOPPED); writeToDspRingbuffer( &e ); } + else + { + cout << __FILE__ << __LINE__ << " Error: unknown command string" << endl; + } } class GTrack : public Fl_Group @@ -56,12 +61,14 @@ class GTrack : public Fl_Group dial2(x+45, y +155, 24, 24, "B"), dial3(x+75, y +155, 24, 24, "C") { - button1.callback( button_callback, 0 ); - button2.callback( button_callback, 0 ); - button3.callback( button_callback, 0 ); - button4.callback( button_callback, 0 ); - button5.callback( button_callback, 0 ); - button6.callback( button_callback, 0 ); + ID = privateID++; + + button1.callback( button_callback, &ID ); + button2.callback( button_callback, &ID ); + button3.callback( button_callback, &ID ); + button4.callback( button_callback, &ID ); + button5.callback( button_callback, &ID ); + button6.callback( button_callback, &ID ); end(); // close the group } @@ -73,6 +80,8 @@ class GTrack : public Fl_Group private: + int ID; + char* title; Avtk::Background bg; diff --git a/src/jack.cxx b/src/jack.cxx index ea1b98a..b6bf114 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -47,8 +47,8 @@ Jack::Jack() cerr << "Jack() error setting timebase callback" << endl; } - - loopers.push_back( new Looper() ); + for(int i = 0; i < 5; i++) + loopers.push_back( new Looper(i) ); jack_transport_start(client); } @@ -72,8 +72,8 @@ int Jack::process (jack_nframes_t nframes) // pre-zero output buffers memset( buffers.audio[Buffers::MASTER_OUTPUT], 0, sizeof(float) * nframes ); - - loopers.at(0)->process(nframes, &buffers ); + for(int i = 0; i < loopers.size(); i++) + loopers.at(i)->process( nframes, &buffers ); /* float* input = buffers.audio[Buffers::MASTER_INPUT]; diff --git a/src/jack.hxx b/src/jack.hxx index fabfbc0..cae95e8 100644 --- a/src/jack.hxx +++ b/src/jack.hxx @@ -31,9 +31,9 @@ class Jack int getBuffersize(); int getSamplerate(); - void setLooperState(int, Looper::State s) + void setLooperState(int t, Looper::State s) { - loopers.at(0)->setState(s); + loopers.at(t)->setState(s); } private: diff --git a/src/looper.hxx b/src/looper.hxx index 1026a67..5cabad2 100644 --- a/src/looper.hxx +++ b/src/looper.hxx @@ -17,7 +17,8 @@ class Looper STATE_STOPPED, }; - Looper() : + Looper(int t) : + track(t), state(STATE_STOPPED), endPoint (0), playPoint (0) @@ -83,6 +84,7 @@ class Looper } private: + int track; State state; int endPoint, playPoint, lastWrittenSampleIndex;