Bug 995289 - Use fmod to wrap custom waveform phase. r=padenot
authorRalph Giles <giles@mozilla.com>
Mon, 14 Apr 2014 19:12:13 -0700
changeset 179470 abda9ad7e8897c4cda4f5f3749cef767c348f26e
parent 179469 111a943b2c7a180ec383574062254fd60ba1cebc
child 179471 f854b5d978b59d65eb1b21f379b38338de5b270e
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerspadenot
bugs995289
milestone31.0a1
Bug 995289 - Use fmod to wrap custom waveform phase. r=padenot From 4156df84046e8c0be31f02a9ac0ffac1cb9fe668 Mon Sep 17 00:00:00 2001
content/media/webaudio/OscillatorNode.cpp
--- a/content/media/webaudio/OscillatorNode.cpp
+++ b/content/media/webaudio/OscillatorNode.cpp
@@ -381,19 +381,17 @@ public:
     for (uint32_t i = aStart; i < aEnd; ++i) {
       UpdateParametersIfNeeded(ticks, i);
       mPeriodicWave->waveDataForFundamentalFrequency(mFinalFrequency,
                                                      lowerWaveData,
                                                      higherWaveData,
                                                      tableInterpolationFactor);
       // mPhase runs 0..periodicWaveSize here instead of 0..2*M_PI.
       mPhase += periodicWaveSize * mFinalFrequency * rate;
-      if (mPhase >= periodicWaveSize) {
-        mPhase -= periodicWaveSize;
-      }
+      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] +