Skip to content

Commit

Permalink
Reset vocoder phase buffer on pitch shifting factor change #45
Browse files Browse the repository at this point in the history
  • Loading branch information
jurihock committed Dec 11, 2023
1 parent 8f64741 commit b5b1f69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions cpp/StftPitchShift/StftPitchShiftCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace stftpitchshift
void factors(const std::vector<double>& factors)
{
pitcher.factors(factors);
vocoder.reset(); // #45
}

double quefrency() const
Expand Down
7 changes: 7 additions & 0 deletions cpp/StftPitchShift/Vocoder.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
Expand Down Expand Up @@ -45,6 +46,12 @@ namespace stftpitchshift
}
}

void reset()
{
// zero decode phase buffer according to #45
std::fill(decode_phase_buffer.begin(), decode_phase_buffer.end(), 0);
}

void encode(const std::span<std::complex<T>> dft)
{
assert(dft.size() == encode_phase_buffer.size());
Expand Down

0 comments on commit b5b1f69

Please sign in to comment.