|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-19 09:48:54
|
Module: editor
Branch: master
Commit: fb73607c6a53df8e63d482a3c4c0cc597bc0feb7
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Jan 19 10:48:41 2011 +0100
Improve pitch analysis response speed
---
pitch.cc | 6 +++---
pitch.hh | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pitch.cc b/pitch.cc
index 566ba72..a5a6c3b 100644
--- a/pitch.cc
+++ b/pitch.cc
@@ -194,13 +194,13 @@ void Analyzer::mergeWithOld(Tones& tones) const {
if (it != tones.end() && *it == *oldit) {
// Merge the old tone into the new tone
it->age = oldit->age + 1;
- it->levelSlow = 0.8 * oldit->levelSlow + 0.2 * it->level;
- it->freqSlow = 0.8 * oldit->freqSlow + 0.2 * it->freq;
+ it->levelSlow = 0.5 * oldit->levelSlow + 0.5 * it->level;
+ it->freqSlow = 0.5 * oldit->freqSlow + 0.5 * it->freq;
} else if (oldit->levelSlow > 1e-8) {
// Insert a decayed version of the old tone into new tones
Tone& t = *tones.insert(it, *oldit);
t.level = 0.0;
- t.levelSlow *= 0.8;
+ t.levelSlow *= 0.01;
}
}
}
diff --git a/pitch.hh b/pitch.hh
index 6061bfc..bfe6240 100644
--- a/pitch.hh
+++ b/pitch.hh
@@ -13,7 +13,7 @@ static inline double dB2level(double db) { return std::pow(10.0, db / 20.0); }
/// A tone is a collection of a base frequency (freq) and all its harmonics
struct Tone {
static const std::size_t MAXHARM = 16; ///< The maximum number of harmonics tracked
- static const std::size_t MINAGE = 6; ///< The minimum age required for a tone to be output
+ static const std::size_t MINAGE = 2; ///< The minimum age required for a tone to be output
double freq; ///< Frequency (Hz)
double freqSlow; ///< Stable frequency
double level; ///< Level (linear)
|