-Updated Looper to use LooperClip::getState() instead of analysing playing() loaded() and recording()

This commit is contained in:
Harry van Haaren 2013-08-22 00:54:40 +01:00
parent 8f71d7411b
commit 9459d0a355
3 changed files with 25 additions and 20 deletions

View file

@ -60,9 +60,11 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
// while another clip records. // while another clip records.
for ( int clip = 0; clip < NSCENES; clip++ ) for ( int clip = 0; clip < NSCENES; clip++ )
{ {
GridLogic::State s = clips[clip]->getState();
// handle state of clip, and do what needs doing: // handle state of clip, and do what needs doing:
// record into buffer, play from buffer, etc // record into buffer, play from buffer, etc
if ( clips[clip]->recording() ) if ( s == GridLogic::STATE_RECORDING )
{ {
if ( clips[clip]->recordSpaceAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST && if ( clips[clip]->recordSpaceAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST &&
!clips[clip]->newBufferInTransit() ) !clips[clip]->newBufferInTransit() )
@ -76,7 +78,7 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
float* input = buffers->audio[Buffers::MASTER_INPUT]; float* input = buffers->audio[Buffers::MASTER_INPUT];
clips[clip]->record( nframes, input, 0 ); clips[clip]->record( nframes, input, 0 );
} }
else if ( clips[clip]->playing() ) else if ( s == GridLogic::STATE_PLAYING )
{ {
// copy data into tmpBuffer, then pitch-stretch into track buffer // copy data into tmpBuffer, then pitch-stretch into track buffer
long targetFrames = clips[clip]->getBeats() * fpb; long targetFrames = clips[clip]->getBeats() * fpb;

View file

@ -187,20 +187,24 @@ void LooperClip::queueRecord()
_playing = false; _playing = false;
} }
GridLogic::State LooperClip::getState()
bool LooperClip::playing()
{ {
return _playing; GridLogic::State s = GridLogic::STATE_EMPTY;
}
if ( _loaded )
bool LooperClip::recording() s = GridLogic::STATE_STOPPED;
{ else if ( _playing )
return _recording; s = GridLogic::STATE_PLAYING;
} else if ( _recording )
s = GridLogic::STATE_RECORDING;
bool LooperClip::loaded() else if ( _queuePlay )
{ s = GridLogic::STATE_PLAY_QUEUED;
return _loaded; else if ( _queueStop )
s = GridLogic::STATE_STOP_QUEUED;
else if ( _queueRecord )
s = GridLogic::STATE_RECORD_QUEUED;
return s;
} }
void LooperClip::newBufferInTransit(bool n) void LooperClip::newBufferInTransit(bool n)

View file

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include "config.hxx" #include "config.hxx"
#include "gridlogic.hxx"
class AudioBuffer; class AudioBuffer;
@ -38,13 +39,12 @@ class LooperClip
/// TimeObserver overrides /// TimeObserver overrides
void bar(); void bar();
/// get clip state /// analyses current _playing _recording vars, returns the current State
bool loaded(); GridLogic::State getState();
bool playing();
bool recording();
/// get buffer details /// get buffer details
int getBeats(); int getBeats();
float getProgress();
long getBufferLenght(); long getBufferLenght();
size_t audioBufferSize(); size_t audioBufferSize();
@ -52,7 +52,6 @@ class LooperClip
void queuePlay(); void queuePlay();
void queueStop(); void queueStop();
void queueRecord(); void queueRecord();
float getProgress();
/// set buffer state /// set buffer state
void setBeats(int beats); void setBeats(int beats);