4 <title>Test AudioBufferSourceNode With Looping a Single-Sample Buffer
</title>
5 <script src=
"resources/compatibility.js"></script>
6 <script src=
"resources/audio-testing.js"></script>
7 <script src=
"../resources/js-test.js"></script>
12 description("Test AudioBufferSourceNode With Looping a Single-Sample Buffer");
19 var sampleRate
= 44100;
20 var testDurationSamples
= 1000;
22 function checkResult (event
) {
25 renderedData
= event
.renderedBuffer
.getChannelData(0);
26 // Check that the rendered data is all ones, like the buffer source.
27 for (k
= 0; k
< renderedData
.length
; ++k
) {
28 if (renderedData
[k
] != 1) {
30 testFailed("Expected all ones, but sample " + k
+ " is " + renderedData
[k
]);
35 testPassed("All samples equal to 1");
40 window
.jsTestIsAsync
= true;
42 // Create the offline context for the test.
43 context
= new OfflineAudioContext(1, testDurationSamples
, sampleRate
);
44 context
.oncomplete
= checkResult
;
46 // Create the single sample buffer
47 buffer
= createConstantBuffer(context
, 1, 1);
49 // Create the source and connect it to the destination
50 source
= context
.createBufferSource();
51 source
.buffer
= buffer
;
53 source
.connect(context
.destination
);
57 context
.startRendering();
61 succesfullyParsed
= true;