mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Multiple loopers supported
This commit is contained in:
parent
c9c469858f
commit
d00f988165
6 changed files with 31 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue