mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
Auto stop after selected number of beats ()
This commit is contained in:
parent
097d52757e
commit
0efe0731d1
3 changed files with 26 additions and 5 deletions
|
@ -110,6 +110,9 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
|
||||||
// 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 ( clips[clip]->recording() ) {
|
||||||
|
if(clips[clip]->getWantedBeats() > 0 && clips[clip]->getBeats() >= clips[clip]->getWantedBeats() - 4)
|
||||||
|
clips[clip]->queuePlay(true);
|
||||||
|
|
||||||
if ( clips[clip]->recordSpaceAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST &&
|
if ( clips[clip]->recordSpaceAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST &&
|
||||||
!clips[clip]->newBufferInTransit() ) {
|
!clips[clip]->newBufferInTransit() ) {
|
||||||
EventLooperClipRequestBuffer e( track, clip, clips[clip]->audioBufferSize() + LOOPER_SAMPLES_UPDATE_SIZE);
|
EventLooperClipRequestBuffer e( track, clip, clips[clip]->audioBufferSize() + LOOPER_SAMPLES_UPDATE_SIZE);
|
||||||
|
|
|
@ -51,6 +51,7 @@ void LooperClip::init()
|
||||||
_queuePlay = false;
|
_queuePlay = false;
|
||||||
_queueStop = false;
|
_queueStop = false;
|
||||||
_queueRecord= false;
|
_queueRecord= false;
|
||||||
|
_wantedBeats= -0;
|
||||||
|
|
||||||
if ( _buffer ) {
|
if ( _buffer ) {
|
||||||
_buffer->init();
|
_buffer->init();
|
||||||
|
@ -187,7 +188,15 @@ void LooperClip::setPlayHead(float ph)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LooperClip::setWantedBeats(int beats)
|
||||||
|
{
|
||||||
|
_wantedBeats = beats;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LooperClip::getWantedBeats()
|
||||||
|
{
|
||||||
|
return _wantedBeats;
|
||||||
|
}
|
||||||
|
|
||||||
void LooperClip::record(int count, float* L, float* R)
|
void LooperClip::record(int count, float* L, float* R)
|
||||||
{
|
{
|
||||||
|
@ -240,7 +249,11 @@ size_t LooperClip::audioBufferSize()
|
||||||
void LooperClip::setBeats(int beats)
|
void LooperClip::setBeats(int beats)
|
||||||
{
|
{
|
||||||
if ( _buffer ) {
|
if ( _buffer ) {
|
||||||
|
if(_buffer->getBeats() == 0)
|
||||||
|
setWantedBeats( beats );
|
||||||
_buffer->setBeats( beats );
|
_buffer->setBeats( beats );
|
||||||
|
} else {
|
||||||
|
setWantedBeats( beats );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,10 @@ public:
|
||||||
///reset the play head to zero. Does nothing when recording
|
///reset the play head to zero. Does nothing when recording
|
||||||
void setPlayHead(float ph);
|
void setPlayHead(float ph);
|
||||||
|
|
||||||
|
void setWantedBeats(int beats);
|
||||||
|
|
||||||
|
int getWantedBeats();
|
||||||
|
|
||||||
#ifdef BUILD_TESTS
|
#ifdef BUILD_TESTS
|
||||||
// used only in test cases
|
// used only in test cases
|
||||||
void setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec );
|
void setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec );
|
||||||
|
@ -140,6 +144,7 @@ private:
|
||||||
|
|
||||||
float _playhead;
|
float _playhead;
|
||||||
float _recordhead;
|
float _recordhead;
|
||||||
|
int _wantedBeats;
|
||||||
AudioBuffer* _buffer;
|
AudioBuffer* _buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue