audiobuffersource-one-sample-loop.html (1419B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title> 5 Test AudioBufferSourceNode With Looping a Single-Sample Buffer 6 </title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/webaudio/resources/audit-util.js"></script> 10 <script src="/webaudio/resources/audit.js"></script> 11 </head> 12 <body> 13 <script id="layout-test-code"> 14 let audit = Audit.createTaskRunner(); 15 16 let sampleRate = 44100; 17 let testDurationSamples = 1000; 18 19 audit.define('one-sample-loop', function(task, should) { 20 // Create the offline context for the test. 21 let context = 22 new OfflineAudioContext(1, testDurationSamples, sampleRate); 23 24 // Create the single sample buffer 25 let buffer = createConstantBuffer(context, 1, 1); 26 27 // Create the source and connect it to the destination 28 let source = context.createBufferSource(); 29 source.buffer = buffer; 30 source.loop = true; 31 source.connect(context.destination); 32 source.start(); 33 34 // Render it! 35 context.startRendering() 36 .then(function(audioBuffer) { 37 should(audioBuffer.getChannelData(0), 'Rendered data') 38 .beConstantValueOf(1); 39 }) 40 .then(task.done.bind(task)); 41 ; 42 }); 43 44 audit.run(); 45 </script> 46 </body> 47 </html>