mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Looping Scene logic added
This commit is contained in:
parent
0c196d14f3
commit
234aea3663
7 changed files with 34 additions and 23 deletions
|
@ -97,30 +97,31 @@ class ClipSelector : public Fl_Button
|
|||
{
|
||||
case Looper::STATE_PLAYING:
|
||||
clips[clipNum].state = ClipState::CLIP_PLAYING;
|
||||
printf("clipSelector setState() clip %i = CLIP_PLAYING\n", clipNum);
|
||||
break;
|
||||
case Looper::STATE_PLAY_QUEUED:
|
||||
clips[clipNum].state = ClipState::CLIP_QUEUED;
|
||||
printf("clipSelector setState() clip %i = CLIP_QUEUED\n", clipNum);
|
||||
break;
|
||||
case Looper::STATE_RECORDING:
|
||||
clips[clipNum].state = ClipState::CLIP_RECORDING;
|
||||
printf("clipSelector setState() clip %i = CLIP_RECORDING\n", clipNum);
|
||||
break;
|
||||
case Looper::STATE_RECORD_QUEUED:
|
||||
clips[clipNum].state = ClipState::CLIP_QUEUED;
|
||||
printf("clipSelector setState() clip %i = CLIP_QUEUED\n", clipNum);
|
||||
break;
|
||||
case Looper::STATE_STOPPED:
|
||||
clips[clipNum].state = ClipState::CLIP_LOADED;
|
||||
printf("clipSelector setState() clip %i = CLIP_LOADED\n", clipNum);
|
||||
break;
|
||||
case Looper::STATE_STOP_QUEUED:
|
||||
clips[clipNum].state = ClipState::CLIP_QUEUED;
|
||||
printf("clipSelector setState() clip %i = CLIP_QUEUED\n", clipNum);
|
||||
break;
|
||||
}
|
||||
redraw();
|
||||
}
|
||||
void setState( int clipNum, ClipState::State s )
|
||||
{
|
||||
clips[clipNum].state = s;
|
||||
redraw();
|
||||
}
|
||||
|
||||
int ID;
|
||||
|
||||
|
@ -306,7 +307,7 @@ class ClipSelector : public Fl_Button
|
|||
}
|
||||
else if ( strcmp(m->label(), "Load") == 0 )
|
||||
{
|
||||
clipSelectorLoad( ID );
|
||||
clipSelectorLoad( ID, clipNum );
|
||||
clips[clipNum].state = ClipState::CLIP_LOADED;
|
||||
}
|
||||
else if ( strcmp(m->label(), "1") == 0 ) {
|
||||
|
@ -331,7 +332,7 @@ class ClipSelector : public Fl_Button
|
|||
else if ( strcmp(m->label(), "Record") == 0 )
|
||||
{
|
||||
clips[clipNum].state = ClipState::CLIP_RECORDING;
|
||||
EventLooperState e = EventLooperState( ID, 0, Looper::STATE_RECORD_QUEUED);
|
||||
EventLooperState e = EventLooperState( ID, clipNum, Looper::STATE_RECORD_QUEUED);
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
}
|
||||
|
@ -342,13 +343,13 @@ class ClipSelector : public Fl_Button
|
|||
case ClipState::CLIP_EMPTY:
|
||||
clips[clipNum].state = ClipState::CLIP_RECORDING;
|
||||
{
|
||||
EventLooperState e = EventLooperState( ID, 0, Looper::STATE_RECORD_QUEUED);
|
||||
EventLooperState e = EventLooperState( ID, clipNum, Looper::STATE_RECORD_QUEUED);
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
break;
|
||||
case ClipState::CLIP_LOADED:
|
||||
{
|
||||
EventLooperState e = EventLooperState( ID, 0, Looper::STATE_PLAY_QUEUED);
|
||||
EventLooperState e = EventLooperState( ID, clipNum, Looper::STATE_PLAY_QUEUED);
|
||||
writeToDspRingbuffer( &e );
|
||||
clips[clipNum].state = ClipState::CLIP_QUEUED;
|
||||
}
|
||||
|
@ -358,14 +359,14 @@ class ClipSelector : public Fl_Button
|
|||
break;
|
||||
case ClipState::CLIP_PLAYING:
|
||||
{
|
||||
EventLooperState e = EventLooperState( ID, 0, Looper::STATE_STOP_QUEUED);
|
||||
EventLooperState e = EventLooperState( ID, clipNum, Looper::STATE_STOP_QUEUED);
|
||||
writeToDspRingbuffer( &e );
|
||||
clips[clipNum].state = ClipState::CLIP_QUEUED;
|
||||
}
|
||||
break;
|
||||
case ClipState::CLIP_RECORDING: {
|
||||
clips[clipNum].state = ClipState::CLIP_QUEUED;
|
||||
EventLooperState e = EventLooperState( ID, 0, Looper::STATE_STOP_QUEUED);
|
||||
EventLooperState e = EventLooperState( ID, clipNum, Looper::STATE_STOP_QUEUED);
|
||||
writeToDspRingbuffer( &e ); }
|
||||
break;
|
||||
case ClipState::CLIP_STOPPING:
|
||||
|
|
|
@ -22,7 +22,6 @@ namespace Event
|
|||
TRACK_SIGNAL_LEVEL,
|
||||
|
||||
LOOPER_LOAD,
|
||||
LOOPER_PLAY,
|
||||
LOOPER_STATE,
|
||||
LOOPER_PROGRESS,
|
||||
LOOPER_LOOP_LENGTH,
|
||||
|
|
|
@ -43,9 +43,7 @@ void handleDspEvents()
|
|||
EventLooperLoad ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperLoad) );
|
||||
Looper* l = jack->getLooper( ev.track );
|
||||
//assert(l);
|
||||
l->setSample( ev.clip, (AudioBuffer*)ev.audioBuffer );
|
||||
//jack->setLooperState( ev.track, ev.state );
|
||||
} break; }
|
||||
case Event::METRONOME_ACTIVE: {
|
||||
if ( availableRead >= sizeof(EventMetronomeActive) ) {
|
||||
|
@ -57,7 +55,7 @@ void handleDspEvents()
|
|||
if ( availableRead >= sizeof(EventLooperState) ) {
|
||||
EventLooperState ev;
|
||||
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperState) );
|
||||
jack->setLooperState( ev.track, ev.state );
|
||||
jack->setLooperState( ev.track, ev.scene, ev.state );
|
||||
} break; }
|
||||
case Event::LOOPER_LOOP_LENGTH: {
|
||||
if ( availableRead >= sizeof(EventLooperLoopLength) ) {
|
||||
|
|
|
@ -30,10 +30,10 @@ static string choose_file()
|
|||
return path;
|
||||
}
|
||||
|
||||
static void clipSelectorLoad(int track)
|
||||
static void clipSelectorLoad(int track, int scene)
|
||||
{
|
||||
AudioBuffer* ab = Worker::loadSample( choose_file() );
|
||||
EventLooperLoad e = EventLooperLoad( track, 0, ab );
|
||||
EventLooperLoad e = EventLooperLoad( track, scene, ab );
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,10 @@ class Jack
|
|||
int getBuffersize();
|
||||
int getSamplerate();
|
||||
|
||||
void setLooperState(int t, Looper::State s)
|
||||
void setLooperState(int t, int sc, Looper::State s)
|
||||
{
|
||||
loopers.at(t)->setState(s);
|
||||
loopers.at(t)->setScene(sc);
|
||||
}
|
||||
void setLooperLoopLength(int t, float l)
|
||||
{
|
||||
|
|
|
@ -80,14 +80,20 @@ void Looper::midi(unsigned char* data)
|
|||
|
||||
}
|
||||
|
||||
void Looper::setState(State s)
|
||||
void Looper::setScene( int sc )
|
||||
{
|
||||
// update Looper to play different scene
|
||||
scene = sc;
|
||||
sample = samples[scene];
|
||||
}
|
||||
|
||||
void Looper::setState( State s)
|
||||
{
|
||||
// quantize recording to next bar event
|
||||
if ( state == STATE_RECORDING )
|
||||
{
|
||||
stopRecordOnBar = true;
|
||||
}
|
||||
|
||||
state = s;
|
||||
updateControllers();
|
||||
}
|
||||
|
@ -130,7 +136,7 @@ void Looper::updateControllers()
|
|||
}
|
||||
}
|
||||
|
||||
void Looper::setSample(int scene, AudioBuffer* ab)
|
||||
void Looper::setSample(int sc, AudioBuffer* ab)
|
||||
{
|
||||
vector<float>& buf = ab->get();
|
||||
if ( buf.size() > SAMPLE_SIZE )
|
||||
|
@ -140,8 +146,13 @@ void Looper::setSample(int scene, AudioBuffer* ab)
|
|||
}
|
||||
else
|
||||
{
|
||||
char buffer [50];
|
||||
sprintf (buffer, "Looper setSample() writing to scene %i",scene);
|
||||
EventGuiPrint e( buffer );
|
||||
writeToGuiRingbuffer( &e );
|
||||
|
||||
numBeats = ab->getBeats();
|
||||
float* s = &sample[0];
|
||||
float* s = &sample[sc];
|
||||
float* b = &buf[0];
|
||||
for (int i = 0; i < buf.size(); i++)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,8 @@ class Looper : public Observer // for notifications
|
|||
|
||||
void setFpb(int f) { fpb = f; }
|
||||
|
||||
void setState(State s);
|
||||
void setScene( int sc );
|
||||
void setState( State s);
|
||||
void setLoopLength(float l);
|
||||
|
||||
void updateControllers();
|
||||
|
|
Loading…
Add table
Reference in a new issue