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);
|
clips[clip]->record( nframes, inputL, inputR);
|
||||||
} else if ( clips[clip]->playing() ) {
|
} else if ( clips[clip]->playing() ) {
|
||||||
// copy data into tmpBuffer, then pitch-stretch into track buffer
|
// copy data into tmpBuffer, then pitch-stretch into track buffer
|
||||||
long targetFrames = clips[clip]->getBeats() * fpb;
|
long targetFrames = fpb;
|
||||||
long actualFrames = clips[clip]->getActualAudioLength();//getBufferLenght();
|
long actualFrames = clips[clip]->getRecFpb();//getBufferLenght();
|
||||||
#ifdef DEBUG_TIME
|
#ifdef DEBUG_TIME
|
||||||
cout << "FPB: " << fpb << "\n";
|
cout << "FPB: " << fpb << "\n";
|
||||||
cout << "Target: " << targetFrames << " - Actual: " << actualFrames << "\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()
|
unsigned long LooperClip::recordSpaceAvailable()
|
||||||
|
@ -254,6 +257,8 @@ void LooperClip::bar()
|
||||||
|
|
||||||
if ( _playing ) {
|
if ( _playing ) {
|
||||||
_barsPlayed++;
|
_barsPlayed++;
|
||||||
|
cout << "Clip " << track << ":" << scene << " " << _playhead
|
||||||
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME assumes 4 beats in a bar
|
// 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 >= _buffer->getSize() ||
|
||||||
_playhead < 0 ) {
|
_playhead < 0 ) {
|
||||||
resetPlayHead();
|
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();
|
std::vector<float>& vL = _buffer->getDataL();
|
||||||
|
|
|
@ -89,6 +89,10 @@ public:
|
||||||
long getActualAudioLength();
|
long getActualAudioLength();
|
||||||
/// Return Size of the Buffer
|
/// Return Size of the Buffer
|
||||||
size_t audioBufferSize();
|
size_t audioBufferSize();
|
||||||
|
int
|
||||||
|
getRecFpb() {
|
||||||
|
return _recFpb;
|
||||||
|
};
|
||||||
|
|
||||||
/// Queue Play
|
/// Queue Play
|
||||||
void queuePlay();
|
void queuePlay();
|
||||||
|
@ -141,6 +145,7 @@ private:
|
||||||
|
|
||||||
long double _playhead;
|
long double _playhead;
|
||||||
float _recordhead;
|
float _recordhead;
|
||||||
|
int _recFpb;
|
||||||
|
|
||||||
unsigned int _barsPlayed;
|
unsigned int _barsPlayed;
|
||||||
AudioBuffer* _buffer;
|
AudioBuffer* _buffer;
|
||||||
|
|
Loading…
Reference in New Issue