diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/audioparam.rs | 34 | ||||
-rw-r--r-- | components/script/dom/webidls/AudioParam.webidl | 6 |
2 files changed, 37 insertions, 3 deletions
diff --git a/components/script/dom/audioparam.rs b/components/script/dom/audioparam.rs index 08ab6f32d10..f4e42264225 100644 --- a/components/script/dom/audioparam.rs +++ b/components/script/dom/audioparam.rs @@ -231,6 +231,40 @@ impl AudioParamMethods for AudioParam { Ok(DomRoot::from_ref(self)) } + // https://webaudio.github.io/web-audio-api/#dom-audioparam-setvaluecurveattime + fn SetValueCurveAtTime( + &self, + values: Vec<Finite<f32>>, + start_time: Finite<f64>, + end_time: Finite<f64>, + ) -> Fallible<DomRoot<AudioParam>> { + if *start_time < 0. { + return Err(Error::Range(format!( + "start time {} should not be negative", + *start_time + ))); + } + if values.len() < 2. as usize { + return Err(Error::InvalidState); + } + + if *end_time < 0. { + return Err(Error::Range(format!( + "end time {} should not be negative", + *end_time + ))); + } + self.message_node(AudioNodeMessage::SetParam( + self.param, + UserAutomationEvent::SetValueCurveAtTime( + values.into_iter().map(|v| *v).collect(), + *start_time, + *end_time, + ), + )); + Ok(DomRoot::from_ref(self)) + } + // https://webaudio.github.io/web-audio-api/#dom-audioparam-cancelscheduledvalues fn CancelScheduledValues(&self, cancel_time: Finite<f64>) -> Fallible<DomRoot<AudioParam>> { if *cancel_time < 0. { diff --git a/components/script/dom/webidls/AudioParam.webidl b/components/script/dom/webidls/AudioParam.webidl index f191a6848f3..42f1012539c 100644 --- a/components/script/dom/webidls/AudioParam.webidl +++ b/components/script/dom/webidls/AudioParam.webidl @@ -24,9 +24,9 @@ interface AudioParam { [Throws] AudioParam setTargetAtTime(float target, double startTime, float timeConstant); -// AudioParam setValueCurveAtTime(sequence<float> values, -// double startTime, -// double duration); + [Throws] AudioParam setValueCurveAtTime(sequence<float> values, + double startTime, + double duration); [Throws] AudioParam cancelScheduledValues(double cancelTime); [Throws] AudioParam cancelAndHoldAtTime(double cancelTime); }; |