Commit 8cb5d7e0 authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

Update BiquadFilter AudioParam limits

The limits for the detune AudioParam have been updated to use the same
limits as OscillatorNode.detune.  The gain AudioParam limits have been
reduced so as not to cause overflow since the gain is in dB.

Tests in audioparam-nominal-range.html updated with new results.  We
also took this opportunity to fix a few minor style issues. (Use
mostPositiveFloat instead of literal value, and add space between
prefix and message for clipped values.

See WebAudio spec issues:
https://github.com/WebAudio/web-audio-api/issues/2113
https://github.com/WebAudio/web-audio-api/issues/2087

Chrome Status: https://www.chromestatus.com/feature/6567195645575168

This CL makes the implementation conform to the spec.

Bug: 1018303
Change-Id: I42c7ec2883fc20dbd59bc6c011ce865159648359
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1968293
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732643}
parent 45060472
......@@ -122,20 +122,23 @@ BiquadFilterNode::BiquadFilterNode(BaseAudioContext& context)
1.0,
AudioParamHandler::AutomationRate::kAudio,
AudioParamHandler::AutomationRateMode::kVariable)),
gain_(
gain_(AudioParam::Create(context,
Uuid(),
AudioParamHandler::kParamTypeBiquadFilterGain,
0.0,
AudioParamHandler::AutomationRate::kAudio,
AudioParamHandler::AutomationRateMode::kVariable,
std::numeric_limits<float>::lowest(),
40 * log10f(std::numeric_limits<float>::max()))),
detune_(
AudioParam::Create(context,
Uuid(),
AudioParamHandler::kParamTypeBiquadFilterGain,
AudioParamHandler::kParamTypeBiquadFilterDetune,
0.0,
AudioParamHandler::AutomationRate::kAudio,
AudioParamHandler::AutomationRateMode::kVariable)),
detune_(AudioParam::Create(
context,
Uuid(),
AudioParamHandler::kParamTypeBiquadFilterDetune,
0.0,
AudioParamHandler::AutomationRate::kAudio,
AudioParamHandler::AutomationRateMode::kVariable)) {
AudioParamHandler::AutomationRateMode::kVariable,
-1200 * log2f(std::numeric_limits<float>::max()),
1200 * log2f(std::numeric_limits<float>::max()))) {
SetHandler(BiquadFilterHandler::Create(*this, context.sampleRate(),
frequency_->Handler(), q_->Handler(),
gain_->Handler(), detune_->Handler()));
......
......@@ -72,8 +72,7 @@
limits: {
playbackRate:
{minValue: -mostPositiveFloat, maxValue: mostPositiveFloat},
detune:
{minValue: -mostPositiveFloat, maxValue: mostPositiveFloat}
detune: {minValue: -mostPositiveFloat, maxValue: mostPositiveFloat}
}
},
{
......@@ -101,11 +100,21 @@
creator: 'createBiquadFilter',
args: [],
limits: {
gain: {minValue: -mostPositiveFloat, maxValue: mostPositiveFloat},
gain: {
minValue: -mostPositiveFloat,
// This complicated expression is used to get all the arithmetic
// to round to the correct single-precision float value for the
// desired max. This also assumes that the implication computes
// the limit as 40 * log10f(std::numeric_limits<float>::max()).
maxValue:
Math.fround(40 * Math.fround(Math.log10(mostPositiveFloat)))
},
Q: {minValue: -mostPositiveFloat, maxValue: mostPositiveFloat},
frequency: {minValue: 0, maxValue: sampleRate / 2},
detune:
{minValue: -mostPositiveFloat, maxValue: mostPositiveFloat}
detune: {
minValue: -Math.fround(1200 * Math.log2(mostPositiveFloat)),
maxValue: Math.fround(1200 * Math.log2(mostPositiveFloat))
}
}
},
{
......@@ -114,9 +123,8 @@
limits: {
frequency: {minValue: -sampleRate / 2, maxValue: sampleRate / 2},
detune: {
// 3.4028..e38 is the most positive single float value.
minValue: -Math.fround(1200 * Math.log2(3.4028234663852886e38)),
maxValue: Math.fround(1200 * Math.log2(3.4028234663852886e38))
minValue: -Math.fround(1200 * Math.log2(mostPositiveFloat)),
maxValue: Math.fround(1200 * Math.log2(mostPositiveFloat))
}
}
},
......@@ -154,8 +162,7 @@
creator: 'createConstantSource',
args: [],
limits: {
offset:
{minValue: -mostPositiveFloat, maxValue: mostPositiveFloat}
offset: {minValue: -mostPositiveFloat, maxValue: mostPositiveFloat}
}
},
// These nodes don't have AudioParams, but we want to test them anyway.
......@@ -420,7 +427,7 @@
if (clippingTested) {
should(
isClipped,
prefix + 'was clipped to lie within the nominal range')
prefix + ' was clipped to lie within the nominal range')
.beEqualTo(true);
}
......
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