calculate playspead based on fpd & fix wrong clip reset
This commit calculates the play speed for a looperclip based on the frames per beat, this avoids displacement due to different clip length Also there was a wrong clip reset when the playhead gets reset in getSample because of the end of buffer. This is not really a nice fix but works for further testing of clipsyncmain
parent
d00e582f49
commit
b196c3667e
|
@ -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";
|
||||
|
|
|
@ -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<float>& vL = _buffer->getDataL();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue