Index: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate-zero.html |
diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate-zero.html b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate-zero.html |
index b4b92dfe712f91cba1986417430860d565cef4b7..cf60ca4a6dc5ebfe2b2d4bf6f62c3c160154aae0 100644 |
--- a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate-zero.html |
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate-zero.html |
@@ -1,78 +1,80 @@ |
<!DOCTYPE html> |
<html> |
+ <head> |
+ <title> |
+ audiobuffersource-playbackrate-zero.html |
+ </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"> |
+ // Sample rate should be power of 128 to observe the change of AudioParam |
+ // at the beginning of rendering quantum. (playbackRate is k-rate) This is |
+ // the minimum sample rate in the valid sample rate range. |
+ let sampleRate = 4096; |
-<head> |
- <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> |
+ // The render duration in seconds, and the length in samples. |
+ let renderDuration = 1.0; |
+ let renderLength = renderDuration * sampleRate; |
-<body> |
- <script> |
+ let context = new OfflineAudioContext(1, renderLength, sampleRate); |
+ let audit = Audit.createTaskRunner(); |
- // Sample rate should be power of 128 to observe the change of AudioParam at |
- // the beginning of rendering quantum. (playbackRate is k-rate) This is the |
- // minimum sample rate in the valid sample rate range. |
- let sampleRate = 4096; |
- // The render duration in seconds, and the length in samples. |
- let renderDuration = 1.0; |
- let renderLength = renderDuration * sampleRate; |
+ // Task: Render the actual buffer and compare with the reference. |
+ audit.define('synthesize-verify', (task, should) => { |
+ let ramp = context.createBufferSource(); |
+ let rampBuffer = createLinearRampBuffer(context, renderLength); |
+ ramp.buffer = rampBuffer; |
- let context = new OfflineAudioContext(1, renderLength, sampleRate); |
- let audit = Audit.createTaskRunner(); |
+ ramp.connect(context.destination); |
+ ramp.start(); |
+ // Leave the playbackRate as 1 for the first half, then change it |
+ // to zero at the exact half. The zero playback rate should hold the |
+ // sample value of the buffer index at the moment. (sample-and-hold) |
+ ramp.playbackRate.setValueAtTime(1.0, 0.0); |
+ ramp.playbackRate.setValueAtTime(0.0, renderDuration / 2); |
- // Task: Render the actual buffer and compare with the reference. |
- audit.define('synthesize-verify', (task, should) => { |
- let ramp = context.createBufferSource(); |
- let rampBuffer = createLinearRampBuffer(context, renderLength); |
- ramp.buffer = rampBuffer; |
+ context.startRendering() |
+ .then(function(renderedBuffer) { |
+ let data = renderedBuffer.getChannelData(0); |
+ let rampData = rampBuffer.getChannelData(0); |
+ let half = rampData.length / 2; |
+ let passed = true; |
+ let i; |
- ramp.connect(context.destination); |
- ramp.start(); |
+ for (i = 1; i < rampData.length; i++) { |
+ if (i < half) { |
+ // Before the half position, the actual should match with the |
+ // original ramp data. |
+ if (data[i] !== rampData[i]) { |
+ passed = false; |
+ break; |
+ } |
+ } else { |
+ // From the half position, the actual value should not change. |
+ if (data[i] !== rampData[half]) { |
+ passed = false; |
+ break; |
+ } |
+ } |
+ } |
- // Leave the playbackRate as 1 for the first half, then change it |
- // to zero at the exact half. The zero playback rate should hold the |
- // sample value of the buffer index at the moment. (sample-and-hold) |
- ramp.playbackRate.setValueAtTime(1.0, 0.0); |
- ramp.playbackRate.setValueAtTime(0.0, renderDuration / 2); |
- |
- context.startRendering().then(function (renderedBuffer) { |
- let data = renderedBuffer.getChannelData(0); |
- let rampData = rampBuffer.getChannelData(0); |
- let half = rampData.length / 2; |
- let passed = true; |
- let i; |
- |
- for (i = 1; i < rampData.length; i++) { |
- if (i < half) { |
- // Before the half position, the actual should match with the |
- // original ramp data. |
- if (data[i] !== rampData[i]) { |
- passed = false; |
- break; |
- } |
- } else { |
- // From the half position, the actual value should not change. |
- if (data[i] !== rampData[half]) { |
- passed = false; |
- break; |
- } |
- } |
- } |
- |
- should(passed, 'The zero playbackRate') |
- .message( |
- 'held the sample value correctly', |
- 'should hold the sample value. ' + 'Expected ' + rampData[half] + |
- ' but got ' + data[i] + ' at the index ' + i); |
- }).then(() => task.done()); |
- }); |
- |
- audit.run(); |
- </script> |
-</body> |
+ should(passed, 'The zero playbackRate') |
+ .message( |
+ 'held the sample value correctly', |
+ 'should hold the sample value. ' + |
+ 'Expected ' + rampData[half] + ' but got ' + data[i] + |
+ ' at the index ' + i); |
+ }) |
+ .then(() => task.done()); |
+ }); |
+ audit.run(); |
+ </script> |
+ </body> |
</html> |