-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.
for ( int clip = 0; clip < NSCENES; clip++ )
{
GridLogic::State s = clips[clip]->getState();
// handle state of clip, and do what needs doing:
// record into buffer, play from buffer, etc
if ( clips[clip]->recording() )
if ( s == GridLogic::STATE_RECORDING )
{
if ( clips[clip]->recordSpaceAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST &&
!clips[clip]->newBufferInTransit() )
@ -76,7 +78,7 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
float* input = buffers->audio[Buffers::MASTER_INPUT];
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
long targetFrames = clips[clip]->getBeats() * fpb;

View file

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

View file

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