mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Loops can be used as tempo, and Luppp will guess the amount of beats, its tempo based on beats, and start running at that tempo.
This commit is contained in:
parent
1be433f4c7
commit
f7fce45d4a
8 changed files with 70 additions and 4 deletions
|
@ -336,6 +336,7 @@ class ClipSelector : public Fl_Button
|
|||
{"32"},
|
||||
{0},
|
||||
{ "Record" },
|
||||
{ "Use as tempo" },
|
||||
{ 0 }
|
||||
};
|
||||
Fl_Menu_Item *m = (Fl_Menu_Item*) rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0);
|
||||
|
@ -367,6 +368,11 @@ class ClipSelector : public Fl_Button
|
|||
EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,32);
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
else if ( strcmp(m->label(), "Use as tempo") == 0 )
|
||||
{
|
||||
EventLooperUseAsTempo e (ID, clipNum);
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
else if ( strcmp(m->label(), "Record") == 0 )
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace Event
|
|||
LOOPER_STATE,
|
||||
LOOPER_PROGRESS,
|
||||
LOOPER_LOOP_LENGTH,
|
||||
LOOPER_LOOP_USE_AS_TEMPO,
|
||||
|
||||
METRONOME_ACTIVE,
|
||||
|
||||
|
@ -196,6 +197,19 @@ class EventLooperLoopLength : public EventBase
|
|||
EventLooperLoopLength(int t, int s, int b) : track(t), scene(s), beats(b) {}
|
||||
};
|
||||
|
||||
class EventLooperUseAsTempo : public EventBase
|
||||
{
|
||||
public:
|
||||
int type() { return int(LOOPER_LOOP_USE_AS_TEMPO); }
|
||||
uint32_t size() { return sizeof(EventLooperUseAsTempo); }
|
||||
|
||||
int track;
|
||||
int scene;
|
||||
int beats;
|
||||
EventLooperUseAsTempo(){}
|
||||
EventLooperUseAsTempo(int t, int s) : track(t), scene(s){}
|
||||
};
|
||||
|
||||
class EventLooperLoad : public EventBase
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -78,6 +78,17 @@ void handleDspEvents()
|
|||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperLoopLength) );
|
||||
jack->getLogic()->looperClipLenght( ev.track, ev.scene, ev.beats );
|
||||
} break; }
|
||||
|
||||
|
||||
case Event::LOOPER_LOOP_USE_AS_TEMPO: {
|
||||
if ( availableRead >= sizeof(EventLooperUseAsTempo) ) {
|
||||
EventLooperUseAsTempo ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperUseAsTempo) );
|
||||
jack->getLogic()->looperUseAsTempo( ev.track, ev.scene );
|
||||
} break; }
|
||||
|
||||
|
||||
|
||||
case Event::TIME_BPM: {
|
||||
if ( availableRead >= sizeof(EventTimeBPM) ) {
|
||||
EventTimeBPM ev;
|
||||
|
|
|
@ -230,8 +230,8 @@ int Jack::process (jack_nframes_t nframes)
|
|||
tmp += buffers.audio[Buffers::TRACK_0 + t][i];
|
||||
}
|
||||
|
||||
buffers.audio[Buffers::JACK_MASTER_OUT_L][i] = tmp + buffers.audio[Buffers::MASTER_OUT_L][i];
|
||||
buffers.audio[Buffers::JACK_MASTER_OUT_R][i] = tmp + buffers.audio[Buffers::MASTER_OUT_R][i];
|
||||
buffers.audio[Buffers::JACK_MASTER_OUT_L][i] = tmp; // + buffers.audio[Buffers::MASTER_OUT_L][i];
|
||||
buffers.audio[Buffers::JACK_MASTER_OUT_R][i] = tmp; // + buffers.audio[Buffers::MASTER_OUT_R][i];
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -38,3 +38,37 @@ void Logic::looperClipLenght(int t, int s, int l)
|
|||
{
|
||||
jack->getLooper( t )->getClip( s )->setBeats(l);
|
||||
}
|
||||
|
||||
|
||||
void Logic::looperUseAsTempo(int t, int s)
|
||||
{
|
||||
size_t l = jack->getLooper( t )->getClip( s )->getBufferLenght();
|
||||
printf("lenght = %zu\n", l );
|
||||
|
||||
int beats = 1;
|
||||
|
||||
int four = l / 4;
|
||||
int eight = l / 8;
|
||||
int sixteen = l / 16;
|
||||
int tirty2 = l / 32;
|
||||
int sixty4 = l / 64;
|
||||
|
||||
printf("%i\n%i\n%i\n%i\n", four, eight, sixteen, tirty2 );
|
||||
|
||||
size_t res = l;
|
||||
|
||||
while ( res > 22050 / 2 )
|
||||
{
|
||||
res = l / beats;
|
||||
|
||||
if ( res - 22050 < jack->getTimeManager()->getFpb() / 2.f )
|
||||
{
|
||||
printf("using beats %i\n", beats);
|
||||
jack->getTimeManager()->setFpb(res);
|
||||
}
|
||||
|
||||
beats = beats + beats;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ class Logic
|
|||
void trackRecordArm(int t, bool v);
|
||||
void trackSend(int t, int send, float v);
|
||||
|
||||
void looperUseAsTempo(int t, int s);
|
||||
void looperClipLenght(int t, int s, int l);
|
||||
};
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ class LooperClip
|
|||
if ( _buffer && _playing )
|
||||
{
|
||||
float p = float(_playhead) / _recordhead;
|
||||
printf("LooperClip progress %f\n", p );
|
||||
//printf("LooperClip progress %f\n", p );
|
||||
return p;
|
||||
}
|
||||
return 0.f;
|
||||
|
|
|
@ -27,7 +27,7 @@ class TimeManager
|
|||
|
||||
cout << "TimeManager() done" << endl;
|
||||
}
|
||||
|
||||
int getFpb(){return fpb;}
|
||||
void setBpm(float bpm)
|
||||
{
|
||||
//cout << "setBpm() " << bpm << endl;
|
||||
|
|
Loading…
Add table
Reference in a new issue