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

Handle k-rate AudioParam inputs for BiquadFilterNode

In addition to making BiquadFilterNode AudioParams apply the input to
the param, we also needed to fix an issue in
CalculateSampleAccurateValues when the param is k-rate.  We would sum
in all the values for the input instead of just taking one.

Manually ran the new test case with Chrome stable and all the tests fail
as expected.

Bug: 1015760
Test: k-rate-biquad-connections.html

Change-Id: I412f9567909d8dd6d4cf00036138b47a454c431c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083224Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757155}
parent 215b0cd8
......@@ -47,7 +47,8 @@ static bool hasConstantValues(float* values, int frames_to_process) {
}
void BiquadDSPKernel::UpdateCoefficientsIfNecessary(int frames_to_process) {
if (GetBiquadProcessor()->FilterCoefficientsDirty()) {
if (GetBiquadProcessor()->FilterCoefficientsDirty() &&
GetBiquadProcessor()->IsAudioRate()) {
float cutoff_frequency[audio_utilities::kRenderQuantumFrames];
float q[audio_utilities::kRenderQuantumFrames];
float gain[audio_utilities::kRenderQuantumFrames];
......@@ -79,10 +80,10 @@ void BiquadDSPKernel::UpdateCoefficientsIfNecessary(int frames_to_process) {
UpdateCoefficients(isConstant ? 1 : frames_to_process, cutoff_frequency,
q, gain, detune);
} else {
cutoff_frequency[0] = GetBiquadProcessor()->Parameter1().Value();
q[0] = GetBiquadProcessor()->Parameter2().Value();
gain[0] = GetBiquadProcessor()->Parameter3().Value();
detune[0] = GetBiquadProcessor()->Parameter4().Value();
cutoff_frequency[0] = GetBiquadProcessor()->Parameter1().FinalValue();
q[0] = GetBiquadProcessor()->Parameter2().FinalValue();
gain[0] = GetBiquadProcessor()->Parameter3().FinalValue();
detune[0] = GetBiquadProcessor()->Parameter4().FinalValue();
UpdateCoefficients(1, cutoff_frequency, q, gain, detune);
}
}
......
......@@ -63,12 +63,18 @@ void BiquadProcessor::CheckForDirtyCoefficients() {
filter_coefficients_dirty_ = false;
has_sample_accurate_values_ = false;
if (parameter1_->HasSampleAccurateValues() ||
parameter2_->HasSampleAccurateValues() ||
parameter3_->HasSampleAccurateValues() ||
parameter4_->HasSampleAccurateValues()) {
if (parameter1_->HasSampleAccurateValuesTimeline() ||
parameter2_->HasSampleAccurateValuesTimeline() ||
parameter3_->HasSampleAccurateValuesTimeline() ||
parameter4_->HasSampleAccurateValuesTimeline()) {
// Coefficients are dirty if any of them has automations or if there are
// connections to the AudioParam.
filter_coefficients_dirty_ = true;
has_sample_accurate_values_ = true;
// If any parameter is a-rate, then the filter must do a-rate processing for
// everything.
is_audio_rate_ = parameter1_->IsAudioRate() || parameter2_->IsAudioRate() ||
parameter3_->IsAudioRate() || parameter4_->IsAudioRate();
} else {
if (has_just_reset_) {
// Snap to exact values first time after reset, then smooth for subsequent
......
......@@ -82,6 +82,7 @@ class BiquadProcessor final : public AudioDSPKernelProcessor {
bool FilterCoefficientsDirty() const { return filter_coefficients_dirty_; }
bool HasSampleAccurateValues() const { return has_sample_accurate_values_; }
bool IsAudioRate() const { return is_audio_rate_; }
AudioParamHandler& Parameter1() { return *parameter1_; }
AudioParamHandler& Parameter2() { return *parameter2_; }
......@@ -104,6 +105,9 @@ class BiquadProcessor final : public AudioDSPKernelProcessor {
// Set to true if any of the filter parameters are sample-accurate.
bool has_sample_accurate_values_;
// Set to true if any of the filter parameters are a-rate.
bool is_audio_rate_;
};
} // namespace blink
......
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