From 1422ab277d38e8c2e1909178045f1ffed932b3be Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Fri, 5 Apr 2019 19:23:49 +0200 Subject: [PATCH] Prevent setting playhead from outside for now, only allow reset --- src/looper.cxx | 2 +- src/looperclip.cxx | 17 +++++++---------- src/looperclip.hxx | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/looper.cxx b/src/looper.cxx index 84f5c62..c4e2a52 100644 --- a/src/looper.cxx +++ b/src/looper.cxx @@ -186,7 +186,7 @@ void Looper::process(unsigned int nframes, Buffers* buffers) void Looper::resetTimeState() { for(int i=0; isetPlayHead(0.0); + clips[i]->resetPlayHead(); } void Looper::pitchShift(int count, float* input, float* output) diff --git a/src/looperclip.cxx b/src/looperclip.cxx index 56d29f9..50cf55a 100644 --- a/src/looperclip.cxx +++ b/src/looperclip.cxx @@ -37,8 +37,7 @@ LooperClip::LooperClip(int t, int s) : track(t), scene(s) { - _buffer = new AudioBuffer(); - _buffer->nonRtResize( LOOPER_SAMPLES_UPDATE_SIZE ); + _buffer = new AudioBuffer(LOOPER_SAMPLES_UPDATE_SIZE); init(); #ifdef DEBUG_BUFFER @@ -174,17 +173,16 @@ void LooperClip::recieveSaveBuffer( AudioBuffer* saveBuffer ) } } -void LooperClip::setPlayHead(float ph) +void LooperClip::resetPlayHead() { - // TODO set _barsPlayed correctly, is this a good idea to allow playhead setting from outside? - if(!_recording&&_playing) { - _playhead = ph; - jack->getControllerUpdater()->setTrackSceneProgress(track, scene, getProgress() ); + if (!_recording) + { + _playhead = 0; + _barsPlayed = 0; + updateController(); } } - - void LooperClip::record(int count, float* L, float* R) { if (recordSpaceAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST && !newBufferInTransit()) { @@ -481,7 +479,6 @@ float LooperClip::getProgress() { if ( _buffer && _playing ) { float p = float(_playhead) / _recordhead; - //printf("LooperClip progress %f\n", p ); return p; } return 0.f; diff --git a/src/looperclip.hxx b/src/looperclip.hxx index 84152e9..3d18423 100644 --- a/src/looperclip.hxx +++ b/src/looperclip.hxx @@ -104,7 +104,7 @@ public: void recieveSaveBuffer( AudioBuffer* ab ); ///reset the play head to zero. Does nothing when recording - void setPlayHead(float ph); + void resetPlayHead(); #ifdef BUILD_TESTS // used only in test cases