From 24bf1347360a01082a08e8d8111a35f0db24ce60 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Mon, 13 May 2013 22:20:00 +0100 Subject: [PATCH] -Looper has Stop functionality --- src/gtrack.hxx | 11 ++++++++++- src/looper.hxx | 14 +++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/gtrack.hxx b/src/gtrack.hxx index 9810427..2ef04c9 100644 --- a/src/gtrack.hxx +++ b/src/gtrack.hxx @@ -30,6 +30,11 @@ static void button_callback(Fl_Widget *w, void *data) { EventLooperState e = EventLooperState(Looper::STATE_PLAYING); writeToDspRingbuffer( &e ); } + else if ( strcmp( w->label() , "Stop" ) == 0 ) + { + EventLooperState e = EventLooperState(Looper::STATE_STOPPED); + writeToDspRingbuffer( &e ); + } } class GTrack : public Fl_Group @@ -42,7 +47,7 @@ class GTrack : public Fl_Group button1(x + 5, y + 24, 100, 18,"Rec"), button2(x + 5, y + 44, 100, 18,"Play"), - button3(x + 5, y + 64, 18, 18,"3"), + button3(x + 5, y + 64, 100, 18,"Stop"), button4(x + 5, y + 84, 18, 18,"4"), button5(x + 5, y +104, 18, 18,"5"), button6(x + 5, y +124, 18, 18,"6"), @@ -53,6 +58,10 @@ class GTrack : public Fl_Group { 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 ); end(); // close the group } diff --git a/src/looper.hxx b/src/looper.hxx index d2cb23b..1026a67 100644 --- a/src/looper.hxx +++ b/src/looper.hxx @@ -14,10 +14,11 @@ class Looper enum State { STATE_PLAYING = 0, STATE_RECORDING, + STATE_STOPPED, }; Looper() : - state(STATE_PLAYING), + state(STATE_STOPPED), endPoint (0), playPoint (0) { @@ -33,15 +34,19 @@ class Looper { endPoint = lastWrittenSampleIndex; playPoint = 0; - cout << "State = PLAYING, endPoint = " << endPoint << endl; + //cout << "State = PLAYING, endPoint = " << endPoint << endl; } else if ( state == STATE_RECORDING ) // setup REC { - cout << "State = RECORDING" << endl; + //cout << "State = RECORDING" << endl; playPoint = 0; endPoint = 0; lastWrittenSampleIndex = 0; } + else if ( state == STATE_STOPPED ) // + { + //cout << "State = STOPPED" << endl; + } } @@ -72,6 +77,9 @@ class Looper } } } + + // buffers pre-zeroed, so just do nothing + else if ( state == STATE_STOPPED ){} } private: