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); }
|
int type() { return int(LOOPER_STATE); }
|
||||||
uint32_t size() { return sizeof(EventLooperState); }
|
uint32_t size() { return sizeof(EventLooperState); }
|
||||||
|
|
||||||
|
int track;
|
||||||
Looper::State state;
|
Looper::State state;
|
||||||
EventLooperState(){}
|
EventLooperState(){}
|
||||||
EventLooperState(Looper::State s) : state(s){}
|
EventLooperState(int t, Looper::State s) : track(t), state(s){}
|
||||||
};
|
};
|
||||||
|
|
||||||
class EventLoadSample : public EventBase
|
class EventLoadSample : public EventBase
|
||||||
|
|
|
@ -60,7 +60,7 @@ void handleDspEvents()
|
||||||
if ( availableRead >= sizeof(EventLooperState) ) {
|
if ( availableRead >= sizeof(EventLooperState) ) {
|
||||||
EventLooperState ev;
|
EventLooperState ev;
|
||||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperState) );
|
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperState) );
|
||||||
jack->setLooperState( 0, ev.state );
|
jack->setLooperState( ev.track, ev.state );
|
||||||
} break; }
|
} break; }
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,23 +18,28 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static void button_callback(Fl_Widget *w, void *data) {
|
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 )
|
if ( strcmp( w->label() , "Rec" ) == 0 )
|
||||||
{
|
{
|
||||||
EventLooperState e = EventLooperState(Looper::STATE_RECORDING);
|
EventLooperState e = EventLooperState(track,Looper::STATE_RECORDING);
|
||||||
writeToDspRingbuffer( &e );
|
writeToDspRingbuffer( &e );
|
||||||
}
|
}
|
||||||
else if ( strcmp( w->label() , "Play" ) == 0 )
|
else if ( strcmp( w->label() , "Play" ) == 0 )
|
||||||
{
|
{
|
||||||
EventLooperState e = EventLooperState(Looper::STATE_PLAYING);
|
EventLooperState e = EventLooperState(track,Looper::STATE_PLAYING);
|
||||||
writeToDspRingbuffer( &e );
|
writeToDspRingbuffer( &e );
|
||||||
}
|
}
|
||||||
else if ( strcmp( w->label() , "Stop" ) == 0 )
|
else if ( strcmp( w->label() , "Stop" ) == 0 )
|
||||||
{
|
{
|
||||||
EventLooperState e = EventLooperState(Looper::STATE_STOPPED);
|
EventLooperState e = EventLooperState(track,Looper::STATE_STOPPED);
|
||||||
writeToDspRingbuffer( &e );
|
writeToDspRingbuffer( &e );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cout << __FILE__ << __LINE__ << " Error: unknown command string" << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GTrack : public Fl_Group
|
class GTrack : public Fl_Group
|
||||||
|
@ -56,12 +61,14 @@ class GTrack : public Fl_Group
|
||||||
dial2(x+45, y +155, 24, 24, "B"),
|
dial2(x+45, y +155, 24, 24, "B"),
|
||||||
dial3(x+75, y +155, 24, 24, "C")
|
dial3(x+75, y +155, 24, 24, "C")
|
||||||
{
|
{
|
||||||
button1.callback( button_callback, 0 );
|
ID = privateID++;
|
||||||
button2.callback( button_callback, 0 );
|
|
||||||
button3.callback( button_callback, 0 );
|
button1.callback( button_callback, &ID );
|
||||||
button4.callback( button_callback, 0 );
|
button2.callback( button_callback, &ID );
|
||||||
button5.callback( button_callback, 0 );
|
button3.callback( button_callback, &ID );
|
||||||
button6.callback( button_callback, 0 );
|
button4.callback( button_callback, &ID );
|
||||||
|
button5.callback( button_callback, &ID );
|
||||||
|
button6.callback( button_callback, &ID );
|
||||||
|
|
||||||
end(); // close the group
|
end(); // close the group
|
||||||
}
|
}
|
||||||
|
@ -73,6 +80,8 @@ class GTrack : public Fl_Group
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int ID;
|
||||||
|
|
||||||
char* title;
|
char* title;
|
||||||
|
|
||||||
Avtk::Background bg;
|
Avtk::Background bg;
|
||||||
|
|
|
@ -47,8 +47,8 @@ Jack::Jack()
|
||||||
cerr << "Jack() error setting timebase callback" << endl;
|
cerr << "Jack() error setting timebase callback" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < 5; i++)
|
||||||
loopers.push_back( new Looper() );
|
loopers.push_back( new Looper(i) );
|
||||||
|
|
||||||
jack_transport_start(client);
|
jack_transport_start(client);
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,8 @@ int Jack::process (jack_nframes_t nframes)
|
||||||
// pre-zero output buffers
|
// pre-zero output buffers
|
||||||
memset( buffers.audio[Buffers::MASTER_OUTPUT], 0, sizeof(float) * nframes );
|
memset( buffers.audio[Buffers::MASTER_OUTPUT], 0, sizeof(float) * nframes );
|
||||||
|
|
||||||
|
for(int i = 0; i < loopers.size(); i++)
|
||||||
loopers.at(0)->process(nframes, &buffers );
|
loopers.at(i)->process( nframes, &buffers );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
float* input = buffers.audio[Buffers::MASTER_INPUT];
|
float* input = buffers.audio[Buffers::MASTER_INPUT];
|
||||||
|
|
|
@ -31,9 +31,9 @@ class Jack
|
||||||
int getBuffersize();
|
int getBuffersize();
|
||||||
int getSamplerate();
|
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:
|
private:
|
||||||
|
|
|
@ -17,7 +17,8 @@ class Looper
|
||||||
STATE_STOPPED,
|
STATE_STOPPED,
|
||||||
};
|
};
|
||||||
|
|
||||||
Looper() :
|
Looper(int t) :
|
||||||
|
track(t),
|
||||||
state(STATE_STOPPED),
|
state(STATE_STOPPED),
|
||||||
endPoint (0),
|
endPoint (0),
|
||||||
playPoint (0)
|
playPoint (0)
|
||||||
|
@ -83,6 +84,7 @@ class Looper
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int track;
|
||||||
State state;
|
State state;
|
||||||
|
|
||||||
int endPoint, playPoint, lastWrittenSampleIndex;
|
int endPoint, playPoint, lastWrittenSampleIndex;
|
||||||
|
|
Loading…
Add table
Reference in a new issue