Bug 1074765 - Use greater weight for nearer sample in PeriodicWave interpolation. r=rillian, a=abillings
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 30 Sep 2014 17:30:30 +1300
changeset 216907 560bb9f18e5a
parent 216906 aaa0553c45c6
child 216908 7a21538bedac
push id3962
push userryanvm@gmail.com
push date2014-10-02 13:26 +0000
treeherdermozilla-beta@abc995cad178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian, abillings
bugs1074765
milestone33.0
Bug 1074765 - Use greater weight for nearer sample in PeriodicWave interpolation. r=rillian, a=abillings
content/media/webaudio/OscillatorNode.cpp
--- a/content/media/webaudio/OscillatorNode.cpp
+++ b/content/media/webaudio/OscillatorNode.cpp
@@ -390,22 +390,22 @@ public:
       mPhase = fmod(mPhase, periodicWaveSize);
       // Bilinear interpolation between adjacent samples in each table.
       uint32_t j1 = floor(mPhase);
       uint32_t j2 = j1 + 1;
       if (j2 >= periodicWaveSize) {
         j2 -= periodicWaveSize;
       }
       float sampleInterpolationFactor = mPhase - j1;
-      float lower = sampleInterpolationFactor * lowerWaveData[j1] +
-                    (1 - sampleInterpolationFactor) * lowerWaveData[j2];
-      float higher = sampleInterpolationFactor * higherWaveData[j1] +
-                    (1 - sampleInterpolationFactor) * higherWaveData[j2];
-      aOutput[i] = tableInterpolationFactor * lower +
-                   (1 - tableInterpolationFactor) * higher;
+      float lower = (1.0f - sampleInterpolationFactor) * lowerWaveData[j1] +
+                    sampleInterpolationFactor * lowerWaveData[j2];
+      float higher = (1.0f - sampleInterpolationFactor) * higherWaveData[j1] +
+                    sampleInterpolationFactor * higherWaveData[j2];
+      aOutput[i] = (1.0f - tableInterpolationFactor) * lower +
+                   tableInterpolationFactor * higher;
 
       mPhase += basePhaseIncrement * mFinalFrequency;
     }
   }
 
   void ComputeSilence(AudioChunk *aOutput)
   {
     aOutput->SetNull(WEBAUDIO_BLOCK_SIZE);