Commit cb14e9a6 authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

Propagate end value of exponentialRampToValueAtTime

When the exponential ramp event ends, we must propagate the end value,
even if the previous event ended with a value with the opposite sign
as the end value of the exponential ramp.

Previously, we just propagated the value of the preview event forever.
This is wrong.  We should propagate that value until we reach the end
of the exponential ramp, and then propagate the end value of the
exponential ramp.

Bug: 992682
Test: webaudio/AudioParam/audioparam-negative-exponentialRamp.html
Change-Id: I97ebad4303a94074cc625d528b1785b8a4b28da9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1747734Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686238}
parent d83ecc53
......@@ -1036,16 +1036,10 @@ float AudioParamTimeline::ValuesForFrameRangeImpl(size_t start_frame,
case ParamEvent::kExponentialRampToValue: {
current_frame = fill_to_end_frame;
// If we're here, we've reached the end of the ramp. If we can
// (because the start and end values have the same sign, and neither
// is 0), use the actual end value. If not, we have to propagate
// whatever we have.
if (i >= 1 && ((events_[i - 1]->Value() * event->Value()) > 0))
value = event->Value();
// Simply stay at a constant value from the last time. We don't want
// to use the value of the event in case value1 * value2 < 0. In this
// case we should propagate the previous value, which is in |value|.
// If we're here, we've reached the end of the ramp. For
// the values after the end of the ramp, we just want to
// continue with the ramp end value.
value = event->Value();
write_index =
FillWithDefault(values, value, fill_to_frame, write_index);
......
......@@ -143,16 +143,21 @@
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);
// value is 1, the ramp should just propagate -1 to the end of
// the exponential ramp, and then propagate the exponential ramp
// value "forever" afterwards.
const linearEndFrame = Math.ceil(linearRampEnd * sampleRate);
const expoEndFrame = Math.ceil(exponentialRampEnd * sampleRate);
should(
actual.slice(endFrame),
actual.slice(linearEndFrame, expoEndFrame),
'Exponential ramp from -1 to 1 after the end of the linear ramp')
.beConstantValueOf(-1);
should(
actual.slice(expoEndFrame),
'Exponential ramp after end of ramp')
.beConstantValueOf(1);
})
.then(() => task.done());
});
audit.run();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment