diff --git a/src/looper.cxx b/src/looper.cxx index c4e2a52..a513905 100644 --- a/src/looper.cxx +++ b/src/looper.cxx @@ -127,8 +127,8 @@ void Looper::process(unsigned int nframes, Buffers* buffers) clips[clip]->record( nframes, inputL, inputR); } else if ( clips[clip]->playing() ) { // copy data into tmpBuffer, then pitch-stretch into track buffer - long targetFrames = clips[clip]->getBeats() * fpb; - long actualFrames = clips[clip]->getActualAudioLength();//getBufferLenght(); + long targetFrames = fpb; + long actualFrames = clips[clip]->getRecFpb();//getBufferLenght(); #ifdef DEBUG_TIME cout << "FPB: " << fpb << "\n"; cout << "Target: " << targetFrames << " - Actual: " << actualFrames << "\n"; diff --git a/src/looperclip.cxx b/src/looperclip.cxx index a36a742..70e37ec 100644 --- a/src/looperclip.cxx +++ b/src/looperclip.cxx @@ -200,6 +200,9 @@ void LooperClip::record(int count, float* L, float* R) } } } + + _loaded = true; + _recFpb = jack->getTimeManager()->getFpb(); } unsigned long LooperClip::recordSpaceAvailable() @@ -254,6 +257,8 @@ void LooperClip::bar() if ( _playing ) { _barsPlayed++; + cout << "Clip " << track << ":" << scene << " " << _playhead + << "\n"; } // FIXME assumes 4 beats in a bar @@ -444,6 +449,15 @@ void LooperClip::getSample(long double playSpeed, float* L, float* R) _playhead >= _buffer->getSize() || _playhead < 0 ) { resetPlayHead(); + + // FIXME is there a better way than just output 0 if frames are missing? + *L = 0.f; + *R = 0.f; + _playhead += playSpeed; + return; + + EventGuiPrint e( "LooperClip resetting _playhead" ); + //writeToGuiRingbuffer( &e ); } std::vector& vL = _buffer->getDataL(); diff --git a/src/looperclip.hxx b/src/looperclip.hxx index 34dde6a..db61ffa 100644 --- a/src/looperclip.hxx +++ b/src/looperclip.hxx @@ -89,6 +89,10 @@ public: long getActualAudioLength(); /// Return Size of the Buffer size_t audioBufferSize(); + int + getRecFpb() { + return _recFpb; + }; /// Queue Play void queuePlay(); @@ -141,6 +145,7 @@ private: long double _playhead; float _recordhead; + int _recFpb; unsigned int _barsPlayed; AudioBuffer* _buffer;