зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1424906 - Fix PeriodicWave disableNormalization false behaviour; r=padenot
This adds a scaling factor of 0.5 even when normalization is disabled, which is required for correct results. MozReview-Commit-ID: J0VbMcaacGc --HG-- extra : rebase_source : 1a8e2dd21a6a48a02fbafda994e42b59c5761ea4
This commit is contained in:
Родитель
eda8e08e68
Коммит
1907956909
|
@ -274,7 +274,11 @@ void PeriodicWave::createBandLimitedTables(float fundamentalFrequency,
|
|||
|
||||
// For the first range (which has the highest power), calculate
|
||||
// its peak value then compute normalization scale.
|
||||
if (!m_disableNormalization && !rangeIndex) {
|
||||
if (m_disableNormalization) {
|
||||
// See Bug 1424906, results need to be scaled by 0.5 even
|
||||
// when normalization is disabled.
|
||||
m_normalizationScale = 0.5;
|
||||
} else if (!rangeIndex) {
|
||||
float maxValue;
|
||||
maxValue = AudioBufferPeakValue(data, m_periodicWaveSize);
|
||||
|
||||
|
@ -283,9 +287,7 @@ void PeriodicWave::createBandLimitedTables(float fundamentalFrequency,
|
|||
}
|
||||
|
||||
// Apply normalization scale.
|
||||
if (!m_disableNormalization) {
|
||||
AudioBufferInPlaceScale(data, m_normalizationScale, m_periodicWaveSize);
|
||||
}
|
||||
AudioBufferInPlaceScale(data, m_normalizationScale, m_periodicWaveSize);
|
||||
}
|
||||
|
||||
void PeriodicWave::generateBasicWaveform(OscillatorType shape)
|
||||
|
|
|
@ -81,9 +81,7 @@ var gTest = {
|
|||
|
||||
buffer.getChannelData(1)[i] = buffer.getChannelData(0)[i];
|
||||
|
||||
// TODO: We need to scale by a factor of two to make the results work
|
||||
// out here. This seems suspicious, see Bug 1266737.
|
||||
buffer.getChannelData(2)[i] = 2.0 *
|
||||
buffer.getChannelData(2)[i] =
|
||||
(real[1] * Math.cos(2 * Math.PI * realFundamental * i /
|
||||
context.sampleRate) +
|
||||
real[realMax] * Math.cos(2 * Math.PI * realMax * realFundamental * i /
|
||||
|
|
Загрузка…
Ссылка в новой задаче