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

Handle k-rate AudioParam inputs for OscillatorNode

As with other fixes, use HasSampleAccurateValuesTimeline() to determine
if there are sample-accurate values which is either caused by timeline
events or connected inputs to the AudioParam.

Tests added to handle possible different combinations of a-rate and
k-rate frequency and detune AudioParams.

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

Change-Id: I0d90d19b3cafbe353bc9495aa7e493bd20eb9e97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2111412
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758009}
parent b4b17a43
...@@ -192,7 +192,8 @@ bool OscillatorHandler::CalculateSampleAccuratePhaseIncrements( ...@@ -192,7 +192,8 @@ bool OscillatorHandler::CalculateSampleAccuratePhaseIncrements(
float final_scale = periodic_wave_->RateScale(); float final_scale = periodic_wave_->RateScale();
if (frequency_->HasSampleAccurateValues()) { if (frequency_->HasSampleAccurateValuesTimeline() &&
frequency_->IsAudioRate()) {
has_sample_accurate_values = true; has_sample_accurate_values = true;
has_frequency_changes = true; has_frequency_changes = true;
...@@ -202,11 +203,11 @@ bool OscillatorHandler::CalculateSampleAccuratePhaseIncrements( ...@@ -202,11 +203,11 @@ bool OscillatorHandler::CalculateSampleAccuratePhaseIncrements(
frames_to_process); frames_to_process);
} else { } else {
// Handle ordinary parameter changes if there are no scheduled changes. // Handle ordinary parameter changes if there are no scheduled changes.
float frequency = frequency_->Value(); float frequency = frequency_->FinalValue();
final_scale *= frequency; final_scale *= frequency;
} }
if (detune_->HasSampleAccurateValues()) { if (detune_->HasSampleAccurateValuesTimeline() && detune_->IsAudioRate()) {
has_sample_accurate_values = true; has_sample_accurate_values = true;
// Get the sample-accurate detune values. // Get the sample-accurate detune values.
...@@ -230,7 +231,7 @@ bool OscillatorHandler::CalculateSampleAccuratePhaseIncrements( ...@@ -230,7 +231,7 @@ bool OscillatorHandler::CalculateSampleAccuratePhaseIncrements(
} else { } else {
// Handle ordinary parameter changes if there are no scheduled // Handle ordinary parameter changes if there are no scheduled
// changes. // changes.
float detune = detune_->Value(); float detune = detune_->FinalValue();
float detune_scale = DetuneToFrequencyMultiplier(detune); float detune_scale = DetuneToFrequencyMultiplier(detune);
final_scale *= detune_scale; final_scale *= detune_scale;
} }
...@@ -410,8 +411,8 @@ void OscillatorHandler::Process(uint32_t frames_to_process) { ...@@ -410,8 +411,8 @@ void OscillatorHandler::Process(uint32_t frames_to_process) {
float table_interpolation_factor = 0; float table_interpolation_factor = 0;
if (!has_sample_accurate_values) { if (!has_sample_accurate_values) {
frequency = frequency_->Value(); frequency = frequency_->FinalValue();
float detune = detune_->Value(); float detune = detune_->FinalValue();
float detune_scale = DetuneToFrequencyMultiplier(detune); float detune_scale = DetuneToFrequencyMultiplier(detune);
frequency *= detune_scale; frequency *= detune_scale;
ClampFrequency(&frequency, 1, Context()->sampleRate() / 2); ClampFrequency(&frequency, 1, Context()->sampleRate() / 2);
......
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