OLD | NEW |
1 var context; | 1 var context; |
2 var lengthInSeconds = 2; | 2 var lengthInSeconds = 2; |
3 | 3 |
4 // Skip this many frames before comparing against reference to allow | 4 // Skip this many frames before comparing against reference to allow |
5 // a steady-state to be reached in the up-sampling filters. | 5 // a steady-state to be reached in the up-sampling filters. |
6 var filterStabilizeSkipFrames = 2048; | 6 var filterStabilizeSkipFrames = 2048; |
7 | 7 |
8 var numberOfCurveFrames = 65536; | 8 var numberOfCurveFrames = 65536; |
9 var waveShapingCurve; | 9 var waveShapingCurve; |
10 | 10 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 if (window.testRunner) { | 148 if (window.testRunner) { |
149 testRunner.dumpAsText(); | 149 testRunner.dumpAsText(); |
150 testRunner.waitUntilDone(); | 150 testRunner.waitUntilDone(); |
151 } | 151 } |
152 | 152 |
153 window.jsTestIsAsync = true; | 153 window.jsTestIsAsync = true; |
154 | 154 |
155 // Create offline audio context. | 155 // Create offline audio context. |
156 var numberOfRenderFrames = sampleRate * lengthInSeconds; | 156 var numberOfRenderFrames = sampleRate * lengthInSeconds; |
157 context = new webkitOfflineAudioContext(1, numberOfRenderFrames, sampleRate)
; | 157 context = new OfflineAudioContext(1, numberOfRenderFrames, sampleRate); |
158 | 158 |
159 // source -> waveshaper -> destination | 159 // source -> waveshaper -> destination |
160 var source = context.createBufferSource(); | 160 var source = context.createBufferSource(); |
161 source.buffer = createToneBuffer(context, fundamentalFrequency, lengthInSeco
nds, 1); | 161 source.buffer = createToneBuffer(context, fundamentalFrequency, lengthInSeco
nds, 1); |
162 | 162 |
163 // Apply a non-linear distortion curve. | 163 // Apply a non-linear distortion curve. |
164 waveshaper = context.createWaveShaper(); | 164 waveshaper = context.createWaveShaper(); |
165 waveshaper.curve = generateWaveShapingCurve(); | 165 waveshaper.curve = generateWaveShapingCurve(); |
166 waveshaper.oversample = oversample; | 166 waveshaper.oversample = oversample; |
167 | 167 |
168 source.connect(waveshaper); | 168 source.connect(waveshaper); |
169 waveshaper.connect(context.destination); | 169 waveshaper.connect(context.destination); |
170 | 170 |
171 source.start(0); | 171 source.start(0); |
172 | 172 |
173 context.oncomplete = checkShapedCurve; | 173 context.oncomplete = checkShapedCurve; |
174 context.startRendering(); | 174 context.startRendering(); |
175 } | 175 } |
OLD | NEW |