From bc71739b3a41844c23f24aaab24de28da384adf5 Mon Sep 17 00:00:00 2001 From: Gerald Date: Wed, 21 Sep 2016 22:28:36 +0200 Subject: [PATCH] Fixed issue with glitches on beats/bars --- src/jack.cxx | 11 +++++++++++ src/jack.hxx | 3 +++ src/looperclip.cxx | 2 +- src/timemanager.cxx | 10 ++++++---- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/jack.cxx b/src/jack.cxx index 3acd3f7..e2ba6d6 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -527,6 +527,17 @@ void Jack::processFrames(int nframes) return; } +void Jack::clearInternalBuffers(int nframes) +{ + memset(buffers.audio[Buffers::SEND],0,sizeof(float)*nframes); + memset(buffers.audio[Buffers::SIDECHAIN_KEY],0,sizeof(float)*nframes); + memset(buffers.audio[Buffers::SIDECHAIN_SIGNAL],0,sizeof(float)*nframes); + memset(buffers.audio[Buffers::MASTER_OUT_L],0,sizeof(float)*nframes); + memset(buffers.audio[Buffers::MASTER_OUT_R],0,sizeof(float)*nframes); + for(int i=0;isetAudioFrames( jack->getTimeManager()->getFpb() * _buffer->getBeats() ); } - if ( _playhead > 0.9 * _recordhead ) + if ( _playhead == _recordhead ) { _playhead = 0.f; } diff --git a/src/timemanager.cxx b/src/timemanager.cxx index e606d49..0a6e9ab 100644 --- a/src/timemanager.cxx +++ b/src/timemanager.cxx @@ -186,9 +186,9 @@ void TimeManager::process(Buffers* buffers) if ( beatFrameCountdown < nframes ) { - //length of beat is not multiple of nframes, so need to process last frames *before* - //then set beat (get the queued actions: play, rec etc) - // then process first frames *after* beat + //length of beat is not multiple of nframes, so need to process last frames of last beat *before* setting next beat + //then set new beat (get the queued actions: play, rec etc) + // then process first frames *after* new beat int before=(beatCounter*fpb)%nframes; int after=nframes-before; @@ -230,8 +230,10 @@ void TimeManager::process(Buffers* buffers) } // process after + // we need to clear internal buffers in order to write *after* frames to them + jack->clearInternalBuffers(nframes); jack->processFrames( after ); - + // write new beat to UI (bar info currently not used) EventTimeBarBeat e( barCounter, beatCounter ); writeToGuiRingbuffer( &e );