| Index: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-grain-no-duration.html
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-grain-no-duration.html b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-grain-no-duration.html
|
| index cb3c90e5ce67cdb66fe5a12879de44e37b5febfb..6ba7d8afe3b4a1433e1b5add29b2f97e58032823 100644
|
| --- a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-grain-no-duration.html
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-grain-no-duration.html
|
| @@ -1,105 +1,108 @@
|
| <!DOCTYPE html>
|
| <html>
|
| -
|
| -<head>
|
| - <title>Test AudioBufferSourceNode looping without explicit duration</title>
|
| - <script src="../../resources/testharness.js"></script>
|
| - <script src="../../resources/testharnessreport.js"></script>
|
| - <script src="../resources/audit-util.js"></script>
|
| - <script src="../resources/audit.js"></script>
|
| -</head>
|
| -
|
| -<body>
|
| - <script>
|
| -
|
| - // Reasonably low sample rate for the optimum test speed.
|
| - var sampleRate = 4096;
|
| -
|
| - var audit = Audit.createTaskRunner();
|
| -
|
| - // Task: create a short linear ramp and enable looping. The test will
|
| - // verify that the ramp was looped the appropriate number of times.
|
| - audit.define('loop-count', (task, should) => {
|
| - // How many loops of the source we want to render. Any whole number
|
| - // greater than 1 will work.
|
| - var loopCount = 4;
|
| - var sourceFrames = 8;
|
| - var renderFrames = sourceFrames * loopCount;
|
| -
|
| - var context = new OfflineAudioContext(1, renderFrames, sampleRate);
|
| - var source = context.createBufferSource();
|
| - var linearRampBuffer = createLinearRampBuffer(context, sourceFrames);
|
| -
|
| - source.buffer = linearRampBuffer;
|
| - source.connect(context.destination);
|
| -
|
| - // Enable looping and start the source with an offset, but without a
|
| - // duration. In this case, the source should loop "forever".
|
| - // See crbug.com/457009.
|
| - source.loop = true;
|
| - source.start(0, 0);
|
| -
|
| - context.startRendering().then(function (renderedBuffer) {
|
| - var badIndex = -1;
|
| - var success = true;
|
| -
|
| - var actual = renderedBuffer.getChannelData(0);
|
| - var linearRamp = linearRampBuffer.getChannelData(0);
|
| -
|
| - // Manually create a |loopCount| copies of linear ramps.
|
| - var expected = new Float32Array(linearRamp.length * loopCount);
|
| - for (var i = 0; i < loopCount; i++)
|
| - expected.set(linearRamp, linearRamp.length * i);
|
| -
|
| - // The actual output should match the created loop.
|
| - should(actual, 'The output of actual and expected loops')
|
| - .beEqualToArray(expected);
|
| - }).then(() => task.done());
|
| - });
|
| -
|
| - // Task: Test that looping an AudioBufferSource works correctly if the
|
| - // source is started and the buffer is assigned later, but before the source
|
| - // would start.
|
| - audit.define('delayed-start', (task, should) => {
|
| - var renderDuration = 2;
|
| - var context = new OfflineAudioContext(2, sampleRate * renderDuration, sampleRate);
|
| - var linearRampBuffer = createLinearRampBuffer(context, 128);
|
| -
|
| - var normal = context.createBufferSource();
|
| - var delayed = context.createBufferSource();
|
| - var merger = context.createChannelMerger(2);
|
| -
|
| - // Connect the normally started source to the left channel, and the
|
| - // delayed to the right channel.
|
| - normal.connect(merger, 0, 0);
|
| - delayed.connect(merger, 0, 1);
|
| - merger.connect(context.destination);
|
| -
|
| - normal.buffer = linearRampBuffer;
|
| - normal.loop = true;
|
| - delayed.loop = true;
|
| -
|
| - normal.start(1, 0);
|
| - delayed.start(1, 0);
|
| -
|
| - // Assign the buffer to the delayed source node at 0.5 second.
|
| - context.suspend(0.5).then(function () {
|
| - delayed.buffer = linearRampBuffer;
|
| - context.resume();
|
| + <head>
|
| + <title>
|
| + Test AudioBufferSourceNode looping without explicit duration
|
| + </title>
|
| + <script src="../../resources/testharness.js"></script>
|
| + <script src="../../resources/testharnessreport.js"></script>
|
| + <script src="../resources/audit-util.js"></script>
|
| + <script src="../resources/audit.js"></script>
|
| + </head>
|
| + <body>
|
| + <script id="layout-test-code">
|
| + // Reasonably low sample rate for the optimum test speed.
|
| + let sampleRate = 4096;
|
| +
|
| + let audit = Audit.createTaskRunner();
|
| +
|
| + // Task: create a short linear ramp and enable looping. The test will
|
| + // verify that the ramp was looped the appropriate number of times.
|
| + audit.define('loop-count', (task, should) => {
|
| + // How many loops of the source we want to render. Any whole number
|
| + // greater than 1 will work.
|
| + let loopCount = 4;
|
| + let sourceFrames = 8;
|
| + let renderFrames = sourceFrames * loopCount;
|
| +
|
| + let context = new OfflineAudioContext(1, renderFrames, sampleRate);
|
| + let source = context.createBufferSource();
|
| + let linearRampBuffer = createLinearRampBuffer(context, sourceFrames);
|
| +
|
| + source.buffer = linearRampBuffer;
|
| + source.connect(context.destination);
|
| +
|
| + // Enable looping and start the source with an offset, but without a
|
| + // duration. In this case, the source should loop "forever".
|
| + // See crbug.com/457009.
|
| + source.loop = true;
|
| + source.start(0, 0);
|
| +
|
| + context.startRendering()
|
| + .then(function(renderedBuffer) {
|
| + let badIndex = -1;
|
| + let success = true;
|
| +
|
| + let actual = renderedBuffer.getChannelData(0);
|
| + let linearRamp = linearRampBuffer.getChannelData(0);
|
| +
|
| + // Manually create a |loopCount| copies of linear ramps.
|
| + let expected = new Float32Array(linearRamp.length * loopCount);
|
| + for (let i = 0; i < loopCount; i++)
|
| + expected.set(linearRamp, linearRamp.length * i);
|
| +
|
| + // The actual output should match the created loop.
|
| + should(actual, 'The output of actual and expected loops')
|
| + .beEqualToArray(expected);
|
| + })
|
| + .then(() => task.done());
|
| });
|
|
|
| - context.startRendering().then(function (buffer) {
|
| - // The left and right channel must match regardless of the timing
|
| - // of buffer assignment.
|
| - should(buffer.getChannelData(0),
|
| - 'The content of the left and right channel')
|
| - .beEqualToArray(buffer.getChannelData(1));
|
| - })
|
| - .then(() => task.done());
|
| - });
|
| -
|
| - audit.run();
|
| - </script>
|
| -</body>
|
| + // Task: Test that looping an AudioBufferSource works correctly if the
|
| + // source is started and the buffer is assigned later, but before the
|
| + // source would start.
|
| + audit.define('delayed-start', (task, should) => {
|
| + let renderDuration = 2;
|
| + let context =
|
| + new OfflineAudioContext(2, sampleRate * renderDuration, sampleRate);
|
| + let linearRampBuffer = createLinearRampBuffer(context, 128);
|
| +
|
| + let normal = context.createBufferSource();
|
| + let delayed = context.createBufferSource();
|
| + let merger = context.createChannelMerger(2);
|
| +
|
| + // Connect the normally started source to the left channel, and the
|
| + // delayed to the right channel.
|
| + normal.connect(merger, 0, 0);
|
| + delayed.connect(merger, 0, 1);
|
| + merger.connect(context.destination);
|
| +
|
| + normal.buffer = linearRampBuffer;
|
| + normal.loop = true;
|
| + delayed.loop = true;
|
| +
|
| + normal.start(1, 0);
|
| + delayed.start(1, 0);
|
| +
|
| + // Assign the buffer to the delayed source node at 0.5 second.
|
| + context.suspend(0.5).then(function() {
|
| + delayed.buffer = linearRampBuffer;
|
| + context.resume();
|
| + });
|
| +
|
| + context.startRendering()
|
| + .then(function(buffer) {
|
| + // The left and right channel must match regardless of the timing
|
| + // of buffer assignment.
|
| + should(
|
| + buffer.getChannelData(0),
|
| + 'The content of the left and right channel')
|
| + .beEqualToArray(buffer.getChannelData(1));
|
| + })
|
| + .then(() => task.done());
|
| + });
|
|
|
| + audit.run();
|
| + </script>
|
| + </body>
|
| </html>
|
|
|