| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 | |
| 3 <html> | |
| 4 <head> | |
| 5 <script src="../resources/js-test.js"></script> | |
| 6 <script src="resources/compatibility.js"></script> | |
| 7 <script src="resources/audit-util.js"></script> | |
| 8 <script src="resources/audio-testing.js"></script> | |
| 9 </head> | |
| 10 | |
| 11 <body> | |
| 12 | |
| 13 <div id="description"></div> | |
| 14 <div id="console"></div> | |
| 15 | |
| 16 <script> | |
| 17 description("This tests that we don't trigger an assertion failure due to AudioN
ode connection order."); | |
| 18 | |
| 19 var sampleRate = 44100.0; | |
| 20 var renderLengthSeconds = 0.125; | |
| 21 var delayTimeSeconds = 0.1; | |
| 22 | |
| 23 function createSinWaveBuffer(context, lengthInSeconds, frequency) { | |
| 24 var audioBuffer = context.createBuffer(1, lengthInSeconds * sampleRate, samp
leRate); | |
| 25 | |
| 26 var n = audioBuffer.length; | |
| 27 var data = audioBuffer.getChannelData(0); | |
| 28 | |
| 29 for (var i = 0; i < n; ++i) { | |
| 30 data[i] = Math.sin(frequency * 2 * Math.PI * i / sampleRate); | |
| 31 } | |
| 32 | |
| 33 return audioBuffer; | |
| 34 } | |
| 35 | |
| 36 function runTest() { | |
| 37 if (window.testRunner) { | |
| 38 testRunner.dumpAsText(); | |
| 39 testRunner.waitUntilDone(); | |
| 40 } | |
| 41 | |
| 42 window.jsTestIsAsync = true; | |
| 43 | |
| 44 // Create offline audio context. | |
| 45 var context = new OfflineAudioContext(1, sampleRate * renderLengthSeconds, s
ampleRate); | |
| 46 var toneBuffer = createSinWaveBuffer(context, renderLengthSeconds, 880); | |
| 47 | |
| 48 var bufferSource = context.createBufferSource(); | |
| 49 bufferSource.buffer = toneBuffer; | |
| 50 bufferSource.connect(context.destination); | |
| 51 | |
| 52 var delay = context.createDelay(); | |
| 53 delay.delayTime.value = delayTimeSeconds; | |
| 54 | |
| 55 // We connect delay node to gain node before anything is connected to delay
node itself. | |
| 56 // We do this because we try to trigger the ASSERT which might be fired due
to AudioNode connection order, | |
| 57 // especially when gain node and delay node is involved e.g. https://bugs.we
bkit.org/show_bug.cgi?id=76685. | |
| 58 | |
| 59 var gain = context.createGain(); | |
| 60 gain.connect(context.destination); | |
| 61 delay.connect(gain); | |
| 62 | |
| 63 bufferSource.start(0); | |
| 64 | |
| 65 context.oncomplete = finishJSTest; | |
| 66 context.startRendering(); | |
| 67 } | |
| 68 | |
| 69 runTest(); | |
| 70 | |
| 71 </script> | |
| 72 | |
| 73 </body> | |
| 74 </html> | |
| OLD | NEW |