Skip to content

Commit efb2dd8

Browse files
authored
Merge pull request #476 from orottier/feature/rename-channelconfig-audionodeoption
Rename ChannelConfigOptions -> AudioNodeOptions
2 parents 95ebe22 + f22bc22 commit efb2dd8

24 files changed

+157
-158
lines changed

examples/worklet_message_port.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::collections::HashMap;
66
use web_audio_api::context::{
77
AudioContext, AudioContextLatencyCategory, AudioContextOptions, BaseAudioContext,
88
};
9-
use web_audio_api::node::{AudioNode, ChannelConfigOptions};
9+
use web_audio_api::node::{AudioNode, AudioNodeOptions};
1010

1111
use web_audio_api::worklet::{
1212
AudioParamValues, AudioWorkletGlobalScope, AudioWorkletNode, AudioWorkletNodeOptions,
@@ -42,7 +42,7 @@ impl WhiteNoiseNode {
4242
output_channel_count: vec![1],
4343
parameter_data: HashMap::new(),
4444
processor_options: (),
45-
channel_config: ChannelConfigOptions::default(),
45+
audio_node_options: AudioNodeOptions::default(),
4646
};
4747

4848
let node = AudioWorkletNode::new::<WhiteNoiseProcessor>(context.base(), options);

src/context/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::context::{
77
};
88
use crate::decoding::MediaDecoder;
99
use crate::events::{Event, EventHandler, EventType};
10-
use crate::node::{AudioNode, ChannelConfigOptions};
10+
use crate::node::{AudioNode, AudioNodeOptions};
1111
use crate::param::AudioParamDescriptor;
1212
use crate::periodic_wave::{PeriodicWave, PeriodicWaveOptions};
1313
use crate::{node, AudioListener};
@@ -186,7 +186,7 @@ pub trait BaseAudioContext {
186186
#[must_use]
187187
fn create_iir_filter(&self, feedforward: Vec<f64>, feedback: Vec<f64>) -> node::IIRFilterNode {
188188
let options = node::IIRFilterOptions {
189-
channel_config: ChannelConfigOptions::default(),
189+
audio_node_options: AudioNodeOptions::default(),
190190
feedforward,
191191
feedback,
192192
};

src/context/concrete_base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::context::{
66
};
77
use crate::events::{EventDispatch, EventHandler, EventLoop, EventType};
88
use crate::message::ControlMessage;
9-
use crate::node::{AudioDestinationNode, AudioNode, ChannelConfig, ChannelConfigOptions};
9+
use crate::node::{AudioDestinationNode, AudioNode, AudioNodeOptions, ChannelConfig};
1010
use crate::param::AudioParam;
1111
use crate::render::AudioProcessor;
1212
use crate::spatial::AudioListenerParams;
@@ -144,7 +144,7 @@ impl ConcreteBaseAudioContext {
144144
render_channel: RwLock::new(render_channel),
145145
queued_messages: Mutex::new(Vec::new()),
146146
audio_node_id_provider,
147-
destination_channel_config: ChannelConfigOptions::default().into(),
147+
destination_channel_config: AudioNodeOptions::default().into(),
148148
frames_played,
149149
queued_audio_listener_msgs: Mutex::new(Vec::new()),
150150
listener_params: None,

src/context/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ impl From<u8> for AudioContextState {
8585

8686
/// Handle of the [`AudioNode`](crate::node::AudioNode) to its associated [`BaseAudioContext`].
8787
///
88-
/// This allows for communication with the render thread and lifetime management.
88+
/// Only when implementing the AudioNode trait manually, this struct is of any concern.
89+
///
90+
/// This object allows for communication with the render thread and dynamic lifetime management.
8991
//
9092
// The only way to construct this object is by calling [`BaseAudioContext::register`]
9193
pub struct AudioContextRegistration {

src/context/online.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::io::{self, AudioBackendManager, ControlThreadInit, NoneBackend, Rende
88
use crate::media_devices::{enumerate_devices_sync, MediaDeviceInfoKind};
99
use crate::media_streams::{MediaStream, MediaStreamTrack};
1010
use crate::message::{ControlMessage, OneshotNotify};
11-
use crate::node::{self, ChannelConfigOptions};
11+
use crate::node::{self, AudioNodeOptions};
1212
use crate::render::graph::Graph;
1313
use crate::MediaElement;
1414
use crate::{AudioRenderCapacity, Event};
@@ -576,7 +576,7 @@ impl AudioContext {
576576
/// Creates a [`MediaStreamAudioDestinationNode`](node::MediaStreamAudioDestinationNode)
577577
#[must_use]
578578
pub fn create_media_stream_destination(&self) -> node::MediaStreamAudioDestinationNode {
579-
let opts = ChannelConfigOptions::default();
579+
let opts = AudioNodeOptions::default();
580580
node::MediaStreamAudioDestinationNode::new(self, opts)
581581
}
582582

src/node/analyser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::render::{
77
AudioParamValues, AudioProcessor, AudioRenderQuantum, AudioWorkletGlobalScope,
88
};
99

10-
use super::{AudioNode, ChannelConfig, ChannelConfigOptions, ChannelInterpretation};
10+
use super::{AudioNode, AudioNodeOptions, ChannelConfig, ChannelInterpretation};
1111

1212
/// Options for constructing an [`AnalyserNode`]
1313
// dictionary AnalyserOptions : AudioNodeOptions {
@@ -22,7 +22,7 @@ pub struct AnalyserOptions {
2222
pub max_decibels: f64,
2323
pub min_decibels: f64,
2424
pub smoothing_time_constant: f64,
25-
pub channel_config: ChannelConfigOptions,
25+
pub audio_node_options: AudioNodeOptions,
2626
}
2727

2828
impl Default for AnalyserOptions {
@@ -32,7 +32,7 @@ impl Default for AnalyserOptions {
3232
max_decibels: DEFAULT_MAX_DECIBELS,
3333
min_decibels: DEFAULT_MIN_DECIBELS,
3434
smoothing_time_constant: DEFAULT_SMOOTHING_TIME_CONSTANT,
35-
channel_config: ChannelConfigOptions::default(),
35+
audio_node_options: AudioNodeOptions::default(),
3636
}
3737
}
3838
}
@@ -123,7 +123,7 @@ impl AnalyserNode {
123123

124124
let node = AnalyserNode {
125125
registration,
126-
channel_config: options.channel_config.into(),
126+
channel_config: options.audio_node_options.into(),
127127
analyser,
128128
};
129129

src/node/biquad_filter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::render::{
1212
};
1313
use crate::{MAX_CHANNELS, RENDER_QUANTUM_SIZE};
1414

15-
use super::{AudioNode, ChannelConfig, ChannelConfigOptions};
15+
use super::{AudioNode, AudioNodeOptions, ChannelConfig};
1616

1717
fn get_computed_freq(freq: f32, detune: f32, sample_rate: f32) -> f32 {
1818
freq * (detune / 1200.).exp2().clamp(0., sample_rate / 2.)
@@ -235,7 +235,7 @@ pub struct BiquadFilterOptions {
235235
pub frequency: f32,
236236
pub gain: f32,
237237
pub type_: BiquadFilterType,
238-
pub channel_config: ChannelConfigOptions,
238+
pub audio_node_options: AudioNodeOptions,
239239
}
240240

241241
impl Default for BiquadFilterOptions {
@@ -246,7 +246,7 @@ impl Default for BiquadFilterOptions {
246246
frequency: 350.,
247247
gain: 0.,
248248
type_: BiquadFilterType::default(),
249-
channel_config: ChannelConfigOptions::default(),
249+
audio_node_options: AudioNodeOptions::default(),
250250
}
251251
}
252252
}
@@ -351,7 +351,7 @@ impl BiquadFilterNode {
351351
frequency,
352352
gain,
353353
type_,
354-
channel_config,
354+
audio_node_options: channel_config,
355355
} = options;
356356

357357
let q_param_options = AudioParamDescriptor {

src/node/channel_merger.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use crate::render::{
66
};
77
use crate::MAX_CHANNELS;
88

9-
use super::{
10-
AudioNode, ChannelConfig, ChannelConfigOptions, ChannelCountMode, ChannelInterpretation,
11-
};
9+
use super::{AudioNode, AudioNodeOptions, ChannelConfig, ChannelCountMode, ChannelInterpretation};
1210

1311
/// Assert that the given number of channels is valid for a ChannelMergerNode
1412
///
@@ -68,17 +66,17 @@ fn assert_valid_channel_count_mode(mode: ChannelCountMode) {
6866
#[derive(Clone, Debug)]
6967
pub struct ChannelMergerOptions {
7068
pub number_of_inputs: usize,
71-
pub channel_config: ChannelConfigOptions,
69+
pub audio_node_options: AudioNodeOptions,
7270
}
7371

7472
impl Default for ChannelMergerOptions {
7573
fn default() -> Self {
7674
Self {
7775
number_of_inputs: 6,
78-
channel_config: ChannelConfigOptions {
79-
count: 1,
80-
count_mode: ChannelCountMode::Explicit,
81-
interpretation: ChannelInterpretation::Speakers,
76+
audio_node_options: AudioNodeOptions {
77+
channel_count: 1,
78+
channel_count_mode: ChannelCountMode::Explicit,
79+
channel_interpretation: ChannelInterpretation::Speakers,
8280
},
8381
}
8482
}
@@ -126,12 +124,12 @@ impl ChannelMergerNode {
126124
context.base().register(move |registration| {
127125
assert_valid_number_of_channels(options.number_of_inputs);
128126

129-
assert_valid_channel_count(options.channel_config.count);
130-
assert_valid_channel_count_mode(options.channel_config.count_mode);
127+
assert_valid_channel_count(options.audio_node_options.channel_count);
128+
assert_valid_channel_count_mode(options.audio_node_options.channel_count_mode);
131129

132130
let node = ChannelMergerNode {
133131
registration,
134-
channel_config: options.channel_config.into(),
132+
channel_config: options.audio_node_options.into(),
135133
number_of_inputs: options.number_of_inputs,
136134
};
137135

src/node/channel_splitter.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use crate::render::{
66
};
77
use crate::MAX_CHANNELS;
88

9-
use super::{
10-
AudioNode, ChannelConfig, ChannelConfigOptions, ChannelCountMode, ChannelInterpretation,
11-
};
9+
use super::{AudioNode, AudioNodeOptions, ChannelConfig, ChannelCountMode, ChannelInterpretation};
1210

1311
/// Assert that the given number of channels is valid for a ChannelMergerNode
1412
///
@@ -68,17 +66,17 @@ fn assert_valid_channel_interpretation(interpretation: ChannelInterpretation) {
6866
#[derive(Clone, Debug)]
6967
pub struct ChannelSplitterOptions {
7068
pub number_of_outputs: usize,
71-
pub channel_config: ChannelConfigOptions,
69+
pub audio_node_options: AudioNodeOptions,
7270
}
7371

7472
impl Default for ChannelSplitterOptions {
7573
fn default() -> Self {
7674
Self {
7775
number_of_outputs: 6,
78-
channel_config: ChannelConfigOptions {
79-
count: 6, // must be same as number_of_outputs
80-
count_mode: ChannelCountMode::Explicit,
81-
interpretation: ChannelInterpretation::Discrete,
76+
audio_node_options: AudioNodeOptions {
77+
channel_count: 6, // must be same as number_of_outputs
78+
channel_count_mode: ChannelCountMode::Explicit,
79+
channel_interpretation: ChannelInterpretation::Discrete,
8280
},
8381
}
8482
}
@@ -133,14 +131,14 @@ impl ChannelSplitterNode {
133131
pub fn new<C: BaseAudioContext>(context: &C, mut options: ChannelSplitterOptions) -> Self {
134132
context.base().register(move |registration| {
135133
assert_valid_number_of_channels(options.number_of_outputs);
136-
options.channel_config.count = options.number_of_outputs;
134+
options.audio_node_options.channel_count = options.number_of_outputs;
137135

138-
assert_valid_channel_count_mode(options.channel_config.count_mode);
139-
assert_valid_channel_interpretation(options.channel_config.interpretation);
136+
assert_valid_channel_count_mode(options.audio_node_options.channel_count_mode);
137+
assert_valid_channel_interpretation(options.audio_node_options.channel_interpretation);
140138

141139
let node = ChannelSplitterNode {
142140
registration,
143-
channel_config: options.channel_config.into(),
141+
channel_config: options.audio_node_options.into(),
144142
};
145143

146144
let render = ChannelSplitterRenderer {

src/node/convolver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::render::{
1010
};
1111
use crate::RENDER_QUANTUM_SIZE;
1212

13-
use super::{AudioNode, ChannelConfig, ChannelConfigOptions, ChannelInterpretation};
13+
use super::{AudioNode, AudioNodeOptions, ChannelConfig, ChannelInterpretation};
1414

1515
/// Scale buffer by an equal-power normalization
1616
// see - <https://webaudio.github.io/web-audio-api/#dom-convolvernode-normalize>
@@ -65,7 +65,7 @@ pub struct ConvolverOptions {
6565
/// The opposite of the desired initial value for the normalize attribute
6666
pub disable_normalization: bool,
6767
/// AudioNode options
68-
pub channel_config: ChannelConfigOptions,
68+
pub audio_node_options: AudioNodeOptions,
6969
}
7070

7171
/// Processing node which applies a linear convolution effect given an impulse response.
@@ -154,7 +154,7 @@ impl ConvolverNode {
154154
let ConvolverOptions {
155155
buffer,
156156
disable_normalization,
157-
channel_config,
157+
audio_node_options: channel_config,
158158
} = options;
159159

160160
let mut node = context.base().register(move |registration| {

0 commit comments

Comments
 (0)