mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-04 16:51:37 -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:
|
||||
// record into buffer, play from buffer, etc
|
||||
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 &&
|
||||
!clips[clip]->newBufferInTransit() ) {
|
||||
EventLooperClipRequestBuffer e( track, clip, clips[clip]->audioBufferSize() + LOOPER_SAMPLES_UPDATE_SIZE);
|
||||
|
|
|
@ -51,6 +51,7 @@ void LooperClip::init()
|
|||
_queuePlay = false;
|
||||
_queueStop = false;
|
||||
_queueRecord= false;
|
||||
_wantedBeats= -0;
|
||||
|
||||
if ( _buffer ) {
|
||||
_buffer->init();
|
||||
|
@ -184,14 +185,22 @@ void LooperClip::setPlayHead(float ph)
|
|||
if(!_recording&&_playing) {
|
||||
_playhead = ph;
|
||||
jack->getControllerUpdater()->setTrackSceneProgress(track, scene, getProgress() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LooperClip::setWantedBeats(int beats)
|
||||
{
|
||||
_wantedBeats = beats;
|
||||
}
|
||||
|
||||
int LooperClip::getWantedBeats()
|
||||
{
|
||||
return _wantedBeats;
|
||||
}
|
||||
|
||||
void LooperClip::record(int count, float* L, float* R)
|
||||
{
|
||||
// write "count" samples into current buffer.
|
||||
// write "count" samples into current buffer.
|
||||
if ( _buffer ) {
|
||||
size_t size = _buffer->getSize();
|
||||
|
||||
|
@ -240,8 +249,12 @@ size_t LooperClip::audioBufferSize()
|
|||
void LooperClip::setBeats(int beats)
|
||||
{
|
||||
if ( _buffer ) {
|
||||
if(_buffer->getBeats() == 0)
|
||||
setWantedBeats( beats );
|
||||
_buffer->setBeats( beats );
|
||||
}
|
||||
} else {
|
||||
setWantedBeats( beats );
|
||||
}
|
||||
}
|
||||
|
||||
int LooperClip::getBeats()
|
||||
|
|
|
@ -116,15 +116,19 @@ public:
|
|||
///reset the play head to zero. Does nothing when recording
|
||||
void setPlayHead(float ph);
|
||||
|
||||
void setWantedBeats(int beats);
|
||||
|
||||
int getWantedBeats();
|
||||
|
||||
#ifdef BUILD_TESTS
|
||||
// used only in test cases
|
||||
void setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec );
|
||||
#endif
|
||||
|
||||
private:
|
||||
int track, scene;
|
||||
int track, scene;
|
||||
|
||||
/** Luppp needs more than the current state of the clip to accuratly handle
|
||||
/** Luppp needs more than the current state of the clip to accuratly handle
|
||||
* it. The current state of the grid is kept up-to-date by GridLogic
|
||||
* abstracting detail away, sending GridLogic::State to Controllers.
|
||||
**/
|
||||
|
@ -140,6 +144,7 @@ private:
|
|||
|
||||
float _playhead;
|
||||
float _recordhead;
|
||||
int _wantedBeats;
|
||||
AudioBuffer* _buffer;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue