Skip to content

Commit

Permalink
Prevent glitches on first loop play
Browse files Browse the repository at this point in the history
  • Loading branch information
georgkrause committed Apr 29, 2019
1 parent c27ad26 commit a488756
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/looperclip.cxx
Expand Up @@ -63,6 +63,8 @@ void LooperClip::init()

resetQueues();

_smoothVolume = 1;

if ( _buffer ) {
_buffer->init();
}
Expand Down Expand Up @@ -366,6 +368,8 @@ void LooperClip::setPlaying()

resetQueues();

_smoothVolume = 0;

_barsPlayed = 0;
_playhead = 0;
} else {
Expand Down Expand Up @@ -477,9 +481,12 @@ LooperClip::getSamples(
for(unsigned int i = 0; i < use; i++) {
if(_playhead > _recordhead)
_playhead = 0;
L[i] = vL[_playhead];
R[i] = vR[_playhead];
L[i] = vL[_playhead] * _smoothVolume;
R[i] = vR[_playhead] * _smoothVolume;
_playhead++;

_smoothVolume += jack->smoothing_value *
(1 - _smoothVolume);
}
stretcher->process(bufs, use, false);
samples_available = stretcher->available();
Expand Down
2 changes: 2 additions & 0 deletions src/looperclip.hxx
Expand Up @@ -151,6 +151,8 @@ private:
float _recordhead;
int _recFpb;

float _smoothVolume;

unsigned int _barsPlayed;
AudioBuffer* _buffer;

Expand Down

0 comments on commit a488756

Please sign in to comment.