Chromium Code Reviews| Index: LayoutTests/webaudio/audiobuffersource-loop-grain-no-duration.html |
| diff --git a/LayoutTests/webaudio/audiobuffersource-loop-grain-no-duration.html b/LayoutTests/webaudio/audiobuffersource-loop-grain-no-duration.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0387a99352c71d3b2cdf56511f74ecc79ac9a233 |
| --- /dev/null |
| +++ b/LayoutTests/webaudio/audiobuffersource-loop-grain-no-duration.html |
| @@ -0,0 +1,72 @@ |
| +<!doctype html> |
| +<html> |
| + <head> |
| + <title>Test AudioBufferSourceNode looping without explicit duration</title> |
| + <script src="resources/compatibility.js"></script> |
| + <script src="resources/audio-testing.js"></script> |
| + <script src="../resources/js-test.js"></script> |
| + </head> |
| + |
| + <body> |
| + <script> |
| + description("Test AudioBufferSourceNode looping without explicit duration"); |
| + |
| + var context; |
| + var buffer; |
| + var output; |
| + var expected; |
| + var sampleRate = 44100; |
| + var sourceFrames = 8; |
| + // How many loops of the source we want to render. |
| + var loopCount = 4; |
|
hongchan
2015/02/20 22:49:46
Out of curiosity, why 4?
|
| + var renderFrames = sourceFrames * loopCount; |
| + |
| + |
| + function checkResult(renderedBuffer) { |
| + var badIndex = -1; |
| + var success = true; |
| + |
| + expected = buffer.getChannelData(0); |
| + output = renderedBuffer.getChannelData(0); |
| + |
| + // Verify the output has the expected data. |
| + for (var k = 0; k < loopCount; ++k) { |
| + for (var n = 0; n < sourceFrames; ++n) { |
| + if (expected[n] != output[n + k * sourceFrames]) { |
| + if (success) |
| + badIndex = n + k * sourceFrames; |
| + success = false; |
| + } |
| + } |
| + } |
| + |
| + if (success) { |
| + testPassed("Source looped correctly"); |
| + } else { |
| + testFailed("First incorrect sample at index " + badIndex); |
| + } |
| + } |
| + |
| + function runTest() { |
| + window.jsTestIsAsync = true; |
| + |
| + context = new OfflineAudioContext(1, renderFrames, sampleRate); |
|
hongchan
2015/02/20 22:49:46
Can you provide informative comments here? What do
Raymond Toy
2015/02/20 23:06:18
Is the description in lines 59-61 not enough? Or a
hongchan
2015/02/20 23:15:44
I thought more explicit comments about how/why two
|
| + buffer = createLinearRampBuffer(context, sourceFrames); |
| + var source = context.createBufferSource(); |
| + source.buffer = buffer; |
| + source.connect(context.destination); |
| + |
| + // Loop the source, and start the source with an offset, but without a duration. In this |
| + // case, the source should loop "forever". See crbug.com/457009. The case where the |
| + // duration is given is covered in other tests. |
| + source.loop = true; |
| + source.start(0, 0); |
| + context.startRendering() |
| + .then(checkResult) |
| + .then(function () { finishJSTest(); }); |
|
hongchan
2015/02/20 22:49:46
Can't this be |.then(finishJSTest);| ?
|
| + } |
| + |
| + runTest(); |
| + </script> |
| + </body> |
| +</html> |