This commit is contained in:
Chris Cannam
2022-06-06 14:49:01 +01:00
parent c728a650e9
commit 9a7a977fa0
2 changed files with 13 additions and 34 deletions

View File

@@ -226,19 +226,22 @@ protected:
int fftSize;
FixedVector<double> cepstra;
FixedVector<double> envelope;
FixedVector<double> shifted;
FixedVector<double> spare;
FormantData(int _fftSize) :
enabled(false),
fftSize(_fftSize),
cepstra(_fftSize, 0.0),
envelope(_fftSize, 0.0),
shifted(_fftSize, 0.0) { }
envelope(_fftSize/2 + 1, 0.0),
spare(_fftSize/2 + 1, 0.0) { }
double envelopeAt(double bin) const {
int b0 = int(floor(bin)), b1 = int(ceil(bin));
if (b1 == b0) return envelope.at(b0);
else {
if (b0 < 0 || b0 > fftSize/2) {
return 0.0;
} else if (b1 == b0 || b1 > fftSize/2) {
return envelope.at(b0);
} else {
double diff = bin - double(b0);
return envelope.at(b0) * (1.0 - diff) + envelope.at(b1) * diff;
}