delay-time-clamping.html (1536B)
1 <!DOCTYPE html> 2 <html class="a"> 3 <head> 4 <title>Delay time clamping in cycles</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 </head> 8 <body> 9 <script> 10 function doTest() { 11 let off = new OfflineAudioContext(1, 512, 48000); 12 let b = new AudioBuffer({sampleRate: off.sampleRate, length: 1}); 13 b.getChannelData(0)[0] = 1; 14 let impulse = new AudioBufferSourceNode(off, {buffer: b}); 15 impulse.start(0); 16 // This delayTime of 64 samples MUST be clamped to 128 samples when 17 // in a cycle. 18 let delay = new DelayNode(off, {delayTime: 64 / 48000}); 19 let fb = new GainNode(off); 20 impulse.connect(fb).connect(delay).connect(fb).connect(off.destination); 21 return off.startRendering().then((b) => { 22 return Promise.resolve(b.getChannelData(0)); 23 }) 24 } 25 26 promise_test(() => { 27 return doTest().then(samples => { 28 for (var i = 0; i < samples.length; i++) { 29 if ((i % 128) != 0) { 30 assert_equals( 31 samples[i], 0.0, 32 'Non-silent audio found in between delayed impulses'); 33 } else { 34 assert_equals( 35 samples[i], 1.0, 36 'Silent audio found instead of a delayed impulse'); 37 } 38 } 39 }); 40 }, 'Test that a DelayNode allows a feedback loop of a single rendering quantum'); 41 </script> 42 </body> 43 </html>