Skip to content

Commit

Permalink
fix(ps splitter): clear buffer when samplerate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zsliu98 committed Dec 25, 2024
1 parent 9f5a9b9 commit 56609ba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/dsp/splitter/psteady/ps_splitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace zlSplitter {
sBuffer.setSize(1, static_cast<int>(spec.maximumBlockSize));
sampleRate.store(static_cast<FloatType>(spec.sampleRate));
peakBuffer.set_capacity(static_cast<size_t>(spec.sampleRate * .001));
peakBuffer.clear();
steadyBuffer.set_capacity(static_cast<size_t>(spec.sampleRate * 1.));
steadyBuffer.clear();
toUpdate.store(true);
}

Expand Down Expand Up @@ -70,7 +72,7 @@ namespace zlSplitter {
peakBufferSize = peakBuffer.capacity();
peakBufferSizeInverse = FloatType(1) / static_cast<FloatType>(peakBufferSize);
steadyBufferSize = static_cast<size_t>(currentSmooth * static_cast<FloatType>(steadyBuffer.capacity()));
steadyBufferSize = std::max(steadyBufferSize, size_t(1));
steadyBufferSize = std::max(steadyBufferSize, peakBufferSize);
steadyBufferSizeInverse = FloatType(1) / static_cast<FloatType>(steadyBufferSize);
}

Expand Down

0 comments on commit 56609ba

Please sign in to comment.