mirror of
https://github.com/RPCS3/soundtouch.git
synced 2024-11-08 12:02:28 +01:00
Floating point patch in PeakFinder
This commit is contained in:
parent
d44723ea57
commit
4bc115df86
@ -192,11 +192,21 @@ double PeakFinder::getPeakCenter(const float *data, int peakpos) const
|
|||||||
gp1 = findGround(data, peakpos, -1);
|
gp1 = findGround(data, peakpos, -1);
|
||||||
gp2 = findGround(data, peakpos, 1);
|
gp2 = findGround(data, peakpos, 1);
|
||||||
|
|
||||||
groundLevel = 0.5f * (data[gp1] + data[gp2]);
|
|
||||||
peakLevel = data[peakpos];
|
peakLevel = data[peakpos];
|
||||||
|
|
||||||
// calculate 70%-level of the peak
|
if (gp1 == gp2)
|
||||||
cutLevel = 0.70f * peakLevel + 0.30f * groundLevel;
|
{
|
||||||
|
// avoid rounding errors when all are equal
|
||||||
|
assert(gp1 == peakpos);
|
||||||
|
cutLevel = groundLevel = peakLevel;
|
||||||
|
} else {
|
||||||
|
// get average of the ground levels
|
||||||
|
groundLevel = 0.5f * (data[gp1] + data[gp2]);
|
||||||
|
|
||||||
|
// calculate 70%-level of the peak
|
||||||
|
cutLevel = 0.70f * peakLevel + 0.30f * groundLevel;
|
||||||
|
}
|
||||||
|
|
||||||
// find mid-level crossings
|
// find mid-level crossings
|
||||||
crosspos1 = findCrossingLevel(data, cutLevel, peakpos, -1);
|
crosspos1 = findCrossingLevel(data, cutLevel, peakpos, -1);
|
||||||
crosspos2 = findCrossingLevel(data, cutLevel, peakpos, 1);
|
crosspos2 = findCrossingLevel(data, cutLevel, peakpos, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user