| Index: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-negative-exponentialRamp.html
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-negative-exponentialRamp.html b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-negative-exponentialRamp.html
|
| index 22fb52857b7497a97c8ab29e5cf4f133f06faaf1..53c0dd1b24da3a436f6ba0c3b542bd3c40c3a8a8 100644
|
| --- a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-negative-exponentialRamp.html
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-negative-exponentialRamp.html
|
| @@ -1,43 +1,43 @@
|
| -<!doctype html>
|
| +<!DOCTYPE html>
|
| <html>
|
| <head>
|
| + <title>
|
| + Test Negative AudioParam.exponentialRampToValueAtTime
|
| + </title>
|
| <script src="../../resources/testharness.js"></script>
|
| - <script src="../../resources/testharnessreport.js"></script>
|
| + <script src="../../resources/testharnessreport.js"></script>
|
| <script src="../resources/audit-util.js"></script>
|
| <script src="../resources/audit.js"></script>
|
| - <title>Test Negative AudioParam.exponentialRampToValueAtTime</title>
|
| </head>
|
| -
|
| <body>
|
| - <script>
|
| -
|
| - var sampleRate = 48000;
|
| + <script id="layout-test-code">
|
| + let sampleRate = 48000;
|
|
|
| - var audit = Audit.createTaskRunner();
|
| + let audit = Audit.createTaskRunner();
|
|
|
| - audit.define("both negative values", (task, should) => {
|
| - var renderDuration = 0.125;
|
| + audit.define('both negative values', (task, should) => {
|
| + let renderDuration = 0.125;
|
|
|
| - // Create context with two channels. Channel 0 contains the positive-valued exponential and
|
| - // channel 1 contains the negative-valued exponential. We'll compare the two channels to
|
| + // Create context with two channels. Channel 0 contains the
|
| + // positive-valued exponential and channel 1 contains the
|
| + // negative-valued exponential. We'll compare the two channels to
|
| // verify that they're the same, as they should be.
|
| - var context = new OfflineAudioContext(2, renderDuration * sampleRate, sampleRate);
|
| - var source = context.createBufferSource();
|
| + let context =
|
| + new OfflineAudioContext(2, renderDuration * sampleRate, sampleRate);
|
| + let source = context.createBufferSource();
|
| source.buffer = createConstantBuffer(context, 1, 1);
|
| source.loop = true;
|
|
|
| - // Gain node gp is for the positive-valued exponential ramp, and gn is for the negative-valued
|
| - // exponential ramp.
|
| - var gp = context.createGain();
|
| - var gn = context.createGain();
|
| - var merger = context.createChannelMerger(2);
|
| + // Gain node gp is for the positive-valued exponential ramp, and gn is
|
| + // for the negative-valued exponential ramp.
|
| + let gp = context.createGain();
|
| + let gn = context.createGain();
|
| + let merger = context.createChannelMerger(2);
|
|
|
| - source.connect(gp)
|
| - .connect(merger, 0, 0);
|
| - source.connect(gn)
|
| - .connect(merger, 0, 1);
|
| + source.connect(gp).connect(merger, 0, 0);
|
| + source.connect(gn).connect(merger, 0, 1);
|
| merger.connect(context.destination);
|
| -
|
| +
|
| gp.gain.setValueAtTime(1, 0);
|
| gp.gain.exponentialRampToValueAtTime(2, renderDuration);
|
|
|
| @@ -46,102 +46,113 @@
|
|
|
| source.start();
|
|
|
| - context.startRendering().then(function (resultBuffer) {
|
| - // Verify that channels have the same values, except for the sign.
|
| - var expected = resultBuffer.getChannelData(0);
|
| - var actual = resultBuffer.getChannelData(1);
|
| - var inverted = expected.map(sample => -sample);
|
| -
|
| - should(actual, "Negative exponential ramp from -1 to -2")
|
| - .beEqualToArray(inverted);
|
| - }).then(() => task.done());
|
| + context.startRendering()
|
| + .then(function(resultBuffer) {
|
| + // Verify that channels have the same values, except for the sign.
|
| + let expected = resultBuffer.getChannelData(0);
|
| + let actual = resultBuffer.getChannelData(1);
|
| + let inverted = expected.map(sample => -sample);
|
| +
|
| + should(actual, 'Negative exponential ramp from -1 to -2')
|
| + .beEqualToArray(inverted);
|
| + })
|
| + .then(() => task.done());
|
| });
|
|
|
| - audit.define("negative-end", (task, should) => {
|
| + audit.define('negative-end', (task, should) => {
|
| // Positive start value and negative end value should just do nothing.
|
| - var renderDuration = 0.125;
|
| - var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
|
| - var source = context.createBufferSource();
|
| + let renderDuration = 0.125;
|
| + let context =
|
| + new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
|
| + let source = context.createBufferSource();
|
| source.buffer = createConstantBuffer(context, 1, 1);
|
| source.loop = true;
|
|
|
| - // Gain node gp is for the positive-valued exponential ramp, and gn is for the negative-valued
|
| - // exponential ramp.
|
| - var g = context.createGain();
|
| -
|
| + // Gain node gp is for the positive-valued exponential ramp, and gn is
|
| + // for the negative-valued exponential ramp.
|
| + let g = context.createGain();
|
| +
|
| g.gain.setValueAtTime(2, 0);
|
| g.gain.exponentialRampToValueAtTime(-1, renderDuration);
|
|
|
| - source.connect(g)
|
| - .connect(context.destination);
|
| + source.connect(g).connect(context.destination);
|
|
|
| source.start();
|
|
|
| - context.startRendering().then(function (resultBuffer) {
|
| - var actual = resultBuffer.getChannelData(0);
|
| + context.startRendering()
|
| + .then(function(resultBuffer) {
|
| + let actual = resultBuffer.getChannelData(0);
|
|
|
| - should(actual, "Exponential ramp from 2 to -1")
|
| - .beConstantValueOf(2);
|
| - }).then(() => task.done());
|
| + should(actual, 'Exponential ramp from 2 to -1')
|
| + .beConstantValueOf(2);
|
| + })
|
| + .then(() => task.done());
|
| });
|
|
|
| - audit.define("positive-end", (task, should) => {
|
| + audit.define('positive-end', (task, should) => {
|
| // Positive start value and negative end value should just do nothing.
|
| - var renderDuration = 0.125;
|
| - var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
|
| - var source = context.createBufferSource();
|
| + let renderDuration = 0.125;
|
| + let context =
|
| + new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
|
| + let source = context.createBufferSource();
|
| source.buffer = createConstantBuffer(context, 1, 1);
|
| source.loop = true;
|
|
|
| - var g = context.createGain();
|
| -
|
| + let g = context.createGain();
|
| +
|
| g.gain.setValueAtTime(-1, 0);
|
| g.gain.exponentialRampToValueAtTime(1, renderDuration);
|
|
|
| - source.connect(g)
|
| - .connect(context.destination);
|
| + source.connect(g).connect(context.destination);
|
| source.start();
|
|
|
| - context.startRendering().then(function (resultBuffer) {
|
| - var actual = resultBuffer.getChannelData(0);
|
| + context.startRendering()
|
| + .then(function(resultBuffer) {
|
| + let actual = resultBuffer.getChannelData(0);
|
|
|
| - should(actual, "Exponential ramp from -1 to 1")
|
| - .beConstantValueOf(-1);
|
| - }).then(() => task.done());
|
| + should(actual, 'Exponential ramp from -1 to 1')
|
| + .beConstantValueOf(-1);
|
| + })
|
| + .then(() => task.done());
|
| });
|
|
|
| - audit.define("propagate", (task, should) => {
|
| - // Test propagation of ramp if the exponential ramp start and end values have opposite sign.
|
| - var renderDuration = 0.125;
|
| - var linearRampEnd = renderDuration / 4;
|
| - var exponentialRampEnd = renderDuration / 2;
|
| + audit.define('propagate', (task, should) => {
|
| + // Test propagation of ramp if the exponential ramp start and end values
|
| + // have opposite sign.
|
| + let renderDuration = 0.125;
|
| + let linearRampEnd = renderDuration / 4;
|
| + let exponentialRampEnd = renderDuration / 2;
|
|
|
| - var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
|
| - var source = context.createBufferSource();
|
| + let context =
|
| + new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
|
| + let source = context.createBufferSource();
|
| source.buffer = createConstantBuffer(context, 1, 1);
|
| source.loop = true;
|
|
|
| - var g = context.createGain();
|
| -
|
| + let g = context.createGain();
|
| +
|
| g.gain.setValueAtTime(2, 0);
|
| g.gain.linearRampToValueAtTime(-1, linearRampEnd);
|
| g.gain.exponentialRampToValueAtTime(1, exponentialRampEnd);
|
|
|
| - source.connect(g)
|
| - .connect(context.destination);
|
| + source.connect(g).connect(context.destination);
|
| source.start();
|
|
|
| - context.startRendering().then(function (resultBuffer) {
|
| - var actual = resultBuffer.getChannelData(0);
|
| -
|
| - // Since the start value of the exponential ramp is -1 and the end value is 1, the ramp
|
| - // should just propagate -1 from the end of the linear ramp "forever".
|
| - var endFrame = Math.ceil(linearRampEnd * sampleRate);
|
| - should(actual.slice(endFrame),
|
| - "Exponential ramp from -1 to 1 after the end of the linear ramp")
|
| - .beConstantValueOf(-1);
|
| - }).then(() => task.done());
|
| -
|
| + context.startRendering()
|
| + .then(function(resultBuffer) {
|
| + let actual = resultBuffer.getChannelData(0);
|
| +
|
| + // Since the start value of the exponential ramp is -1 and the end
|
| + // value is 1, the ramp should just propagate -1 from the end of
|
| + // the linear ramp "forever".
|
| + let endFrame = Math.ceil(linearRampEnd * sampleRate);
|
| + should(
|
| + actual.slice(endFrame),
|
| + 'Exponential ramp from -1 to 1 after the end of the linear ramp')
|
| + .beConstantValueOf(-1);
|
| + })
|
| + .then(() => task.done());
|
| +
|
| });
|
|
|
| audit.run();
|
|
|