From 431ad807d24c2c167d50ec9463a85cbd77ab353c Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 19 Sep 2018 14:11:08 +0530 Subject: [PATCH 1/4] Update servo-media --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26b04bfb46a..e2c1277a2e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2856,7 +2856,7 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3279,7 +3279,7 @@ dependencies = [ [[package]] name = "servo-media" version = "0.1.0" -source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" +source = "git+https://github.com/servo/media#3292937b8bec7daed12b2f1b5739eb293610f5a2" dependencies = [ "servo-media-audio 0.1.0 (git+https://github.com/servo/media)", "servo-media-gstreamer 0.1.0 (git+https://github.com/servo/media)", @@ -3289,7 +3289,7 @@ dependencies = [ [[package]] name = "servo-media-audio" version = "0.1.0" -source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" +source = "git+https://github.com/servo/media#3292937b8bec7daed12b2f1b5739eb293610f5a2" dependencies = [ "boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3305,7 +3305,7 @@ dependencies = [ [[package]] name = "servo-media-gstreamer" version = "0.1.0" -source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" +source = "git+https://github.com/servo/media#3292937b8bec7daed12b2f1b5739eb293610f5a2" dependencies = [ "byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3323,7 +3323,7 @@ dependencies = [ [[package]] name = "servo-media-player" version = "0.1.0" -source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" +source = "git+https://github.com/servo/media#3292937b8bec7daed12b2f1b5739eb293610f5a2" dependencies = [ "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3418,7 +3418,7 @@ dependencies = [ [[package]] name = "servo_media_derive" version = "0.1.0" -source = "git+https://github.com/servo/media#8f65e32617b068e8a0d152236848fd98cc08a3ae" +source = "git+https://github.com/servo/media#3292937b8bec7daed12b2f1b5739eb293610f5a2" dependencies = [ "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", From 1be41686d30aed8385750cc6fc323972515e07ed Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 19 Sep 2018 21:37:32 +0530 Subject: [PATCH 2/4] Implement BiquadFilterNode --- components/script/dom/baseaudiocontext.rs | 7 + components/script/dom/biquadfilternode.rs | 184 ++++++++++++++++++ components/script/dom/mod.rs | 1 + .../dom/webidls/BiquadFilterNode.webidl | 39 ++++ .../webaudio/idlharness.https.window.js.ini | 123 ------------ .../ctor-biquadfilter.html.ini | 1 - tests/wpt/mozilla/meta/MANIFEST.json | 2 +- .../wpt/mozilla/tests/mozilla/interfaces.html | 1 + 8 files changed, 233 insertions(+), 125 deletions(-) create mode 100644 components/script/dom/biquadfilternode.rs create mode 100644 components/script/dom/webidls/BiquadFilterNode.webidl diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index 514a51f113b..86a715d1b5b 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -18,6 +18,7 @@ use dom::bindings::codegen::Bindings::BaseAudioContextBinding::AudioContextState use dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContextMethods; use dom::bindings::codegen::Bindings::BaseAudioContextBinding::DecodeErrorCallback; use dom::bindings::codegen::Bindings::BaseAudioContextBinding::DecodeSuccessCallback; +use dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterOptions; use dom::bindings::codegen::Bindings::ChannelMergerNodeBinding::ChannelMergerOptions; use dom::bindings::codegen::Bindings::GainNodeBinding::GainOptions; use dom::bindings::codegen::Bindings::OscillatorNodeBinding::OscillatorOptions; @@ -28,6 +29,7 @@ use dom::bindings::num::Finite; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; use dom::bindings::root::{DomRoot, MutNullableDom}; +use dom::biquadfilternode::BiquadFilterNode; use dom::channelmergernode::ChannelMergerNode; use dom::domexception::{DOMErrorName, DOMException}; use dom::eventtarget::EventTarget; @@ -344,6 +346,11 @@ impl BaseAudioContextMethods for BaseAudioContext { AnalyserNode::new(&self.global().as_window(), &self, &AnalyserOptions::empty()) } + /// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbiquadfilter + fn CreateBiquadFilter(&self) -> Fallible> { + BiquadFilterNode::new(&self.global().as_window(), &self, &BiquadFilter::empty()) + } + /// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelmerger fn CreateChannelMerger(&self, count: u32) -> Fallible> { let mut opts = ChannelMergerOptions::empty(); diff --git a/components/script/dom/biquadfilternode.rs b/components/script/dom/biquadfilternode.rs new file mode 100644 index 00000000000..77c39ca7d04 --- /dev/null +++ b/components/script/dom/biquadfilternode.rs @@ -0,0 +1,184 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use dom::audionode::AudioNode; +use dom::audioparam::AudioParam; +use dom::baseaudiocontext::BaseAudioContext; +use dom::bindings::codegen::Bindings::AudioNodeBinding::{ChannelCountMode, ChannelInterpretation}; +use dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; +use dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::{self, BiquadFilterNodeMethods}; +use dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterOptions; +use dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterType; +use dom::bindings::error::Fallible; +use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot}; +use dom::window::Window; +use dom_struct::dom_struct; +use servo_media::audio::biquad_filter_node::{BiquadFilterNodeOptions, FilterType}; +use servo_media::audio::biquad_filter_node::BiquadFilterNodeMessage; +use servo_media::audio::node::{AudioNodeInit, AudioNodeMessage}; +use servo_media::audio::param::ParamType; +use std::cell::Cell; +use std::f32; + +#[dom_struct] +pub struct BiquadFilterNode { + node: AudioNode, + gain: Dom, + frequency: Dom, + q: Dom, + detune: Dom, + filter: Cell, +} + +impl BiquadFilterNode { + #[allow(unrooted_must_root)] + pub fn new_inherited( + window: &Window, + context: &BaseAudioContext, + options: &BiquadFilterOptions, + ) -> Fallible { + let node_options = options.parent + .unwrap_or(2, ChannelCountMode::Max, + ChannelInterpretation::Speakers); + let filter = Cell::new(options.type_); + let options = options.into(); + let node = AudioNode::new_inherited( + AudioNodeInit::BiquadFilterNode(options), + context, + node_options, + 1, // inputs + 1, // outputs + )?; + let gain = AudioParam::new( + window, + context, + node.node_id(), + ParamType::Gain, + AutomationRate::A_rate, + options.gain, // default value + f32::MIN, // min value + f32::MAX, // max value + ); + let q = AudioParam::new( + window, + context, + node.node_id(), + ParamType::Q, + AutomationRate::A_rate, + options.q, // default value + f32::MIN, // min value + f32::MAX, // max value + ); + let frequency = AudioParam::new( + window, + context, + node.node_id(), + ParamType::Frequency, + AutomationRate::A_rate, + options.frequency, // default value + f32::MIN, // min value + f32::MAX, // max value + ); + let detune = AudioParam::new( + window, + context, + node.node_id(), + ParamType::Detune, + AutomationRate::A_rate, + options.detune, // default value + f32::MIN, // min value + f32::MAX, // max value + ); + Ok(BiquadFilterNode { + node, + filter, + gain: Dom::from_ref(&gain), + q: Dom::from_ref(&q), + frequency: Dom::from_ref(&frequency), + detune: Dom::from_ref(&detune), + }) + } + + #[allow(unrooted_must_root)] + pub fn new( + window: &Window, + context: &BaseAudioContext, + options: &BiquadFilterOptions, + ) -> Fallible> { + let node = BiquadFilterNode::new_inherited(window, context, options)?; + Ok(reflect_dom_object(Box::new(node), window, BiquadFilterNodeBinding::Wrap)) + } + + pub fn Constructor( + window: &Window, + context: &BaseAudioContext, + options: &BiquadFilterOptions, + ) -> Fallible> { + BiquadFilterNode::new(window, context, options) + } +} + +impl BiquadFilterNodeMethods for BiquadFilterNode { + // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-gain + fn Gain(&self) -> DomRoot { + DomRoot::from_ref(&self.gain) + } + + // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-q + fn Q(&self) -> DomRoot { + DomRoot::from_ref(&self.gain) + } + + // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-detune + fn Detune(&self) -> DomRoot { + DomRoot::from_ref(&self.gain) + } + + // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-frequency + fn Frequency(&self) -> DomRoot { + DomRoot::from_ref(&self.gain) + } + + // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-type + fn Type(&self) -> BiquadFilterType { + self.filter.get() + } + + // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-type + fn SetType(&self, filter: BiquadFilterType) { + self.filter.set(filter); + self.node + .message(AudioNodeMessage::BiquadFilterNode( + BiquadFilterNodeMessage::SetFilterType(filter.into()), + )); + } +} + +impl<'a> From<&'a BiquadFilterOptions> for BiquadFilterNodeOptions { + fn from(options: &'a BiquadFilterOptions) -> Self { + Self { + gain: *options.gain, + q: *options.Q, + frequency: *options.frequency, + detune: *options.detune, + filter: options.type_.into() + } + } +} + +impl From for FilterType { + fn from(filter: BiquadFilterType) -> FilterType { + match filter { + BiquadFilterType::Lowpass => FilterType::LowPass, + BiquadFilterType::Highpass => FilterType::HighPass, + BiquadFilterType::Bandpass => FilterType::BandPass, + BiquadFilterType::Lowshelf => FilterType::LowShelf, + BiquadFilterType::Highshelf => FilterType::HighShelf, + BiquadFilterType::Peaking => FilterType::Peaking, + BiquadFilterType::Allpass => FilterType::AllPass, + BiquadFilterType::Notch => FilterType::Notch, + } + } +} diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 54b9adcc422..07425cccae1 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -228,6 +228,7 @@ pub mod audioscheduledsourcenode; pub mod baseaudiocontext; pub mod beforeunloadevent; pub mod bindings; +pub mod biquadfilternode; pub mod blob; pub mod bluetooth; pub mod bluetoothadvertisingevent; diff --git a/components/script/dom/webidls/BiquadFilterNode.webidl b/components/script/dom/webidls/BiquadFilterNode.webidl new file mode 100644 index 00000000000..24e993f5aa4 --- /dev/null +++ b/components/script/dom/webidls/BiquadFilterNode.webidl @@ -0,0 +1,39 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* + * The origin of this IDL file is + * https://webaudio.github.io/web-audio-api/#biquadfilternode + */ + +enum BiquadFilterType { + "lowpass", + "highpass", + "bandpass", + "lowshelf", + "highshelf", + "peaking", + "notch", + "allpass" +}; + +dictionary BiquadFilterOptions : AudioNodeOptions { + BiquadFilterType type = "lowpass"; + float Q = 1; + float detune = 0; + float frequency = 350; + float gain = 0; +}; + +[Exposed=Window, + Constructor (BaseAudioContext context, optional BiquadFilterOptions options)] +interface BiquadFilterNode : AudioNode { + attribute BiquadFilterType type; + readonly attribute AudioParam frequency; + readonly attribute AudioParam detune; + readonly attribute AudioParam Q; + readonly attribute AudioParam gain; + // the AudioParam model of https://github.com/servo/servo/issues/21659 needs to + // be implemented before we implement this + // void getFrequencyResponse (Float32Array frequencyHz, Float32Array magResponse, Float32Array phaseResponse); +}; diff --git a/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini b/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini index 50e3231ac0c..e9f5094764f 100644 --- a/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini +++ b/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini @@ -275,138 +275,15 @@ [AudioProcessingEvent interface: new AudioProcessingEvent('', {\n playbackTime: 0, inputBuffer: buffer, outputBuffer: buffer\n }) must inherit property "outputBuffer" with the proper type] expected: FAIL - [BiquadFilterNode interface: existence and properties of interface object] - expected: FAIL - - [BiquadFilterNode interface object length] - expected: FAIL - - [BiquadFilterNode interface object name] - expected: FAIL - - [BiquadFilterNode interface: existence and properties of interface prototype object] - expected: FAIL - - [BiquadFilterNode interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [BiquadFilterNode interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [BiquadFilterNode interface: attribute type] - expected: FAIL - - [BiquadFilterNode interface: attribute frequency] - expected: FAIL - - [BiquadFilterNode interface: attribute detune] - expected: FAIL - - [BiquadFilterNode interface: attribute Q] - expected: FAIL - - [BiquadFilterNode interface: attribute gain] - expected: FAIL - [BiquadFilterNode interface: operation getFrequencyResponse(Float32Array, Float32Array, Float32Array)] expected: FAIL - [BiquadFilterNode must be primary interface of new BiquadFilterNode(context)] - expected: FAIL - - [Stringification of new BiquadFilterNode(context)] - expected: FAIL - - [BiquadFilterNode interface: new BiquadFilterNode(context) must inherit property "type" with the proper type] - expected: FAIL - - [BiquadFilterNode interface: new BiquadFilterNode(context) must inherit property "frequency" with the proper type] - expected: FAIL - - [BiquadFilterNode interface: new BiquadFilterNode(context) must inherit property "detune" with the proper type] - expected: FAIL - - [BiquadFilterNode interface: new BiquadFilterNode(context) must inherit property "Q" with the proper type] - expected: FAIL - - [BiquadFilterNode interface: new BiquadFilterNode(context) must inherit property "gain" with the proper type] - expected: FAIL - [BiquadFilterNode interface: new BiquadFilterNode(context) must inherit property "getFrequencyResponse(Float32Array, Float32Array, Float32Array)" with the proper type] expected: FAIL [BiquadFilterNode interface: calling getFrequencyResponse(Float32Array, Float32Array, Float32Array) on new BiquadFilterNode(context) with too few arguments must throw TypeError] expected: FAIL - [AudioNode interface: new BiquadFilterNode(context) must inherit property "connect(AudioNode, unsigned long, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling connect(AudioNode, unsigned long, unsigned long) on new BiquadFilterNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "connect(AudioParam, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling connect(AudioParam, unsigned long) on new BiquadFilterNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "disconnect()" with the proper type] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "disconnect(unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(unsigned long) on new BiquadFilterNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "disconnect(AudioNode)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioNode) on new BiquadFilterNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioNode, unsigned long) on new BiquadFilterNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new BiquadFilterNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "disconnect(AudioParam)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioParam) on new BiquadFilterNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type] - expected: FAIL - - [AudioNode interface: calling disconnect(AudioParam, unsigned long) on new BiquadFilterNode(context) with too few arguments must throw TypeError] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "context" with the proper type] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "numberOfInputs" with the proper type] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "numberOfOutputs" with the proper type] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "channelCount" with the proper type] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "channelCountMode" with the proper type] - expected: FAIL - - [AudioNode interface: new BiquadFilterNode(context) must inherit property "channelInterpretation" with the proper type] - expected: FAIL - [ChannelSplitterNode interface: existence and properties of interface object] expected: FAIL diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter.html.ini index 74f212f13ee..cf399bc62be 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter.html.ini @@ -1,5 +1,4 @@ [ctor-biquadfilter.html] - expected: ERROR [X node0 = new BiquadFilterNode(context) incorrectly threw TypeError: "window[name\] is not a constructor".] expected: FAIL diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 3388ffd2562..de3bc22eaeb 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -27038,7 +27038,7 @@ "testharness" ], "mozilla/interfaces.html": [ - "840c233a14c3d041e43a125a6d1452670aa4fbb4", + "4863f4d1036e945cfaae1f112981fac3367b2e49", "testharness" ], "mozilla/interfaces.js": [ diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.html b/tests/wpt/mozilla/tests/mozilla/interfaces.html index 840c233a14c..4863f4d1036 100644 --- a/tests/wpt/mozilla/tests/mozilla/interfaces.html +++ b/tests/wpt/mozilla/tests/mozilla/interfaces.html @@ -23,6 +23,7 @@ test_interfaces([ "AudioScheduledSourceNode", "BaseAudioContext", "BeforeUnloadEvent", + "BiquadFilterNode", "Blob", "CanvasGradient", "CanvasRenderingContext2D", From bb61487d8fb4340fd232bd4960fe0912438a68d0 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 19 Sep 2018 22:41:24 +0530 Subject: [PATCH 3/4] Add createBiquadFilter() --- components/script/dom/baseaudiocontext.rs | 2 +- components/script/dom/biquadfilternode.rs | 6 +++--- .../script/dom/webidls/BaseAudioContext.webidl | 2 +- .../webaudio/idlharness.https.window.js.ini | 9 --------- .../biquad-allpass.html.ini | 10 +++++++++- .../biquad-automation.html.ini | 2 +- .../biquad-bandpass.html.ini | 10 +++++++++- .../biquad-basic.html.ini | 13 ++++++++++++- .../biquad-highpass.html.ini | 10 +++++++++- .../biquad-highshelf.html.ini | 10 +++++++++- .../biquad-lowpass.html.ini | 10 +++++++++- .../biquad-lowshelf.html.ini | 10 +++++++++- .../biquad-notch.html.ini | 10 +++++++++- .../biquad-peaking.html.ini | 10 +++++++++- .../biquadfilternode-basic.html.ini | 2 -- 15 files changed, 90 insertions(+), 26 deletions(-) delete mode 100644 tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquadfilternode-basic.html.ini diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index 86a715d1b5b..e4d8ee01dcc 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -348,7 +348,7 @@ impl BaseAudioContextMethods for BaseAudioContext { /// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbiquadfilter fn CreateBiquadFilter(&self) -> Fallible> { - BiquadFilterNode::new(&self.global().as_window(), &self, &BiquadFilter::empty()) + BiquadFilterNode::new(&self.global().as_window(), &self, &BiquadFilterOptions::empty()) } /// https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createchannelmerger diff --git a/components/script/dom/biquadfilternode.rs b/components/script/dom/biquadfilternode.rs index 77c39ca7d04..2ee309498be 100644 --- a/components/script/dom/biquadfilternode.rs +++ b/components/script/dom/biquadfilternode.rs @@ -128,17 +128,17 @@ impl BiquadFilterNodeMethods for BiquadFilterNode { // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-q fn Q(&self) -> DomRoot { - DomRoot::from_ref(&self.gain) + DomRoot::from_ref(&self.q) } // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-detune fn Detune(&self) -> DomRoot { - DomRoot::from_ref(&self.gain) + DomRoot::from_ref(&self.detune) } // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-frequency fn Frequency(&self) -> DomRoot { - DomRoot::from_ref(&self.gain) + DomRoot::from_ref(&self.frequency) } // https://webaudio.github.io/web-audio-api/#dom-biquadfilternode-type diff --git a/components/script/dom/webidls/BaseAudioContext.webidl b/components/script/dom/webidls/BaseAudioContext.webidl index 9b8d8c5efa1..2883e60ffd8 100644 --- a/components/script/dom/webidls/BaseAudioContext.webidl +++ b/components/script/dom/webidls/BaseAudioContext.webidl @@ -38,7 +38,7 @@ interface BaseAudioContext : EventTarget { [Throws] AnalyserNode createAnalyser(); [Throws] GainNode createGain(); // DelayNode createDelay(optional double maxDelayTime = 1); - // BiquadFilterNode createBiquadFilter(); + [Throws] BiquadFilterNode createBiquadFilter(); // IIRFilterNode createIIRFilter(sequence feedforward, // sequence feedback); // WaveShaperNode createWaveShaper(); diff --git a/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini b/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini index e9f5094764f..224dbbac2b4 100644 --- a/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini +++ b/tests/wpt/metadata/webaudio/idlharness.https.window.js.ini @@ -8,9 +8,6 @@ [BaseAudioContext interface: attribute audioWorklet] expected: FAIL - [BaseAudioContext interface: operation createBiquadFilter()] - expected: FAIL - [BaseAudioContext interface: operation createChannelSplitter(unsigned long)] expected: FAIL @@ -89,9 +86,6 @@ [BaseAudioContext interface: context must inherit property "audioWorklet" with the proper type] expected: FAIL - [BaseAudioContext interface: context must inherit property "createBiquadFilter()" with the proper type] - expected: FAIL - [BaseAudioContext interface: context must inherit property "createChannelSplitter(unsigned long)" with the proper type] expected: FAIL @@ -155,9 +149,6 @@ [BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "audioWorklet" with the proper type] expected: FAIL - [BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "createBiquadFilter()" with the proper type] - expected: FAIL - [BaseAudioContext interface: new OfflineAudioContext(1, 1, sample_rate) must inherit property "createChannelSplitter(unsigned long)" with the proper type] expected: FAIL diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-allpass.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-allpass.html.ini index e5aa83654f5..6ef6c3f2d0b 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-allpass.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-allpass.html.ini @@ -1,2 +1,10 @@ [biquad-allpass.html] - expected: ERROR + [X Max error in Allpass filter response is not less than or equal to 3.9337e-8. Got 2.805464744567871.] + expected: FAIL + + [< [test\] 1 out of 3 assertions were failed.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-automation.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-automation.html.ini index ac3dec84f13..287d87750d4 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-automation.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-automation.html.ini @@ -1,2 +1,2 @@ [biquad-automation.html] - expected: ERROR + expected: CRASH diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-bandpass.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-bandpass.html.ini index fcc3d0f21a5..8bf03b63dd8 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-bandpass.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-bandpass.html.ini @@ -1,2 +1,10 @@ [biquad-bandpass.html] - expected: ERROR + [< [test\] 1 out of 3 assertions were failed.] + expected: FAIL + + [X Max error in Bandpass filter response is not less than or equal to 2.2501e-8. Got 1.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-basic.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-basic.html.ini index bce6dd3eb04..ab13bf5ce1a 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-basic.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-basic.html.ini @@ -1,8 +1,19 @@ [biquad-basic.html] - expected: ERROR [< [existence\] 1 out of 1 assertions were failed.] expected: FAIL [X context.createBiquadFilter does not exist. Got undefined.] expected: FAIL + [X getFrequencyResponse(new Float32Array(10), new Float32Array(1), new Float32Array(20)) threw "TypeError" instead of InvalidAccessError.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 5 tasks were failed.] + expected: FAIL + + [X getFrequencyResponse(new Float32Array(10), new Float32Array(20), new Float32Array(1)) threw "TypeError" instead of InvalidAccessError.] + expected: FAIL + + [< [exceptions-getFrequencyData\] 2 out of 5 assertions were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-highpass.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-highpass.html.ini index 3e4776a430c..6270a74e10f 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-highpass.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-highpass.html.ini @@ -1,2 +1,10 @@ [biquad-highpass.html] - expected: ERROR + [< [test\] 1 out of 3 assertions were failed.] + expected: FAIL + + [X Max error in Highpass filter response is not less than or equal to 1.5487e-8. Got 1.9329860210418701.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-highshelf.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-highshelf.html.ini index 041e10d010e..9f5e0b56c3b 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-highshelf.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-highshelf.html.ini @@ -1,2 +1,10 @@ [biquad-highshelf.html] - expected: ERROR + [< [test\] 1 out of 3 assertions were failed.] + expected: FAIL + + [X Max error in Highshelf filter response is not less than or equal to 6.2577e-8. Got 2.3278465244357536.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-lowpass.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-lowpass.html.ini index a61dc595e90..c92fde14eba 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-lowpass.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-lowpass.html.ini @@ -1,2 +1,10 @@ [biquad-lowpass.html] - expected: ERROR + [< [test\] 1 out of 3 assertions were failed.] + expected: FAIL + + [X Max error in Lowpass filter response is not less than or equal to 9.7869e-8. Got 1.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-lowshelf.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-lowshelf.html.ini index eb11b1317ec..0b0025a76fc 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-lowshelf.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-lowshelf.html.ini @@ -1,2 +1,10 @@ [biquad-lowshelf.html] - expected: ERROR + [< [test\] 1 out of 3 assertions were failed.] + expected: FAIL + + [X Max error in Lowshelf filter response is not less than or equal to 3.8349e-8. Got 3.162277660168379.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-notch.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-notch.html.ini index 29576262c6e..de2ff5cb0c8 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-notch.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-notch.html.ini @@ -1,2 +1,10 @@ [biquad-notch.html] - expected: ERROR + [< [test\] 1 out of 3 assertions were failed.] + expected: FAIL + + [X Max error in Notch filter response is not less than or equal to 1.9669e-8. Got 2.9027323722839355.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-peaking.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-peaking.html.ini index 13f1c9c4824..7b26daf7b82 100644 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-peaking.html.ini +++ b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-peaking.html.ini @@ -1,2 +1,10 @@ [biquad-peaking.html] - expected: ERROR + [< [test\] 1 out of 3 assertions were failed.] + expected: FAIL + + [X Max error in Peaking filter response is not less than or equal to 5.8234e-8. Got 3.162277660168379.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed.] + expected: FAIL + diff --git a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquadfilternode-basic.html.ini b/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquadfilternode-basic.html.ini deleted file mode 100644 index 68f54dbc496..00000000000 --- a/tests/wpt/metadata/webaudio/the-audio-api/the-biquadfilternode-interface/biquadfilternode-basic.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[biquadfilternode-basic.html] - expected: ERROR From daf85918e39a7fa1c47a69732711a2c35194eba2 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 19 Sep 2018 23:21:28 +0530 Subject: [PATCH 4/4] Fix GainNode constructor for gain audioparam --- components/script/dom/gainnode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/gainnode.rs b/components/script/dom/gainnode.rs index 1b4859e28e5..577deba8f54 100644 --- a/components/script/dom/gainnode.rs +++ b/components/script/dom/gainnode.rs @@ -47,7 +47,7 @@ impl GainNode { node.node_id(), ParamType::Gain, AutomationRate::A_rate, - 1., // default value + *options.gain, // default value f32::MIN, // min value f32::MAX, // max value );