Skip to content

Commit 55bbd2e

Browse files
committed
Rename AudioNode connect/disconnect methods with inputs/outputs
1 parent 9f0613d commit 55bbd2e

File tree

7 files changed

+27
-17
lines changed

7 files changed

+27
-17
lines changed

examples/constant_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn main() {
3333
// left branch
3434
let gain_left = context.create_gain();
3535
gain_left.gain().set_value(0.);
36-
gain_left.connect_at(&merger, 0, 0);
36+
gain_left.connect_from_output_to_input(&merger, 0, 0);
3737

3838
let mut src_left = context.create_oscillator();
3939
src_left.frequency().set_value(200.);
@@ -43,7 +43,7 @@ fn main() {
4343
// right branch
4444
let gain_right = context.create_gain();
4545
gain_right.gain().set_value(0.);
46-
gain_right.connect_at(&merger, 0, 1);
46+
gain_right.connect_from_output_to_input(&merger, 0, 1);
4747

4848
let mut src_right = context.create_oscillator();
4949
src_right.frequency().set_value(300.);

examples/merger.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ fn main() {
4646
let merger = context.create_channel_merger(2);
4747

4848
// connect left osc to left input of the merger
49-
left.connect_at(&merger, 0, 0);
49+
left.connect_from_output_to_input(&merger, 0, 0);
5050
// connect right osc to left input of the merger
51-
right.connect_at(&merger, 0, 1);
51+
right.connect_from_output_to_input(&merger, 0, 1);
5252

5353
// Connect the merger to speakers
5454
merger.connect(&context.destination());

examples/multichannel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn main() {
5757
let now = context.current_time();
5858

5959
let mut osc = context.create_oscillator();
60-
osc.connect_at(&merger, 0, output_channel);
60+
osc.connect_from_output_to_input(&merger, 0, output_channel);
6161
osc.frequency().set_value(200.);
6262
osc.start_at(now);
6363
osc.stop_at(now + 1.);

src/node/audio_node.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub trait AudioNode {
245245
/// This function will panic when
246246
/// - the AudioContext of the source and destination does not match
247247
fn connect<'a>(&self, dest: &'a dyn AudioNode) -> &'a dyn AudioNode {
248-
self.connect_at(dest, 0, 0)
248+
self.connect_from_output_to_input(dest, 0, 0)
249249
}
250250

251251
/// Connect a specific output of this AudioNode to a specific input of another node.
@@ -256,7 +256,7 @@ pub trait AudioNode {
256256
/// - the AudioContext of the source and destination does not match
257257
/// - if the input port is out of bounds for the destination node
258258
/// - if the output port is out of bounds for the source node
259-
fn connect_at<'a>(
259+
fn connect_from_output_to_input<'a>(
260260
&self,
261261
dest: &'a dyn AudioNode,
262262
output: usize,
@@ -340,7 +340,7 @@ pub trait AudioNode {
340340
/// - the AudioContext of the source and destination does not match
341341
/// - if the output port is out of bounds for the source node
342342
/// - the source node was not connected to the destination node
343-
fn disconnect_dest_output(&self, dest: &dyn AudioNode, output: usize) {
343+
fn disconnect_dest_from_output(&self, dest: &dyn AudioNode, output: usize) {
344344
assert!(
345345
self.context() == dest.context(),
346346
"InvalidAccessError - Attempting to disconnect nodes from different contexts"
@@ -370,7 +370,12 @@ pub trait AudioNode {
370370
/// - if the input port is out of bounds for the destination node
371371
/// - if the output port is out of bounds for the source node
372372
/// - the source node was not connected to the destination node
373-
fn disconnect_dest_output_input(&self, dest: &dyn AudioNode, output: usize, input: usize) {
373+
fn disconnect_dest_from_output_to_input(
374+
&self,
375+
dest: &dyn AudioNode,
376+
output: usize,
377+
input: usize,
378+
) {
374379
assert!(
375380
self.context() == dest.context(),
376381
"InvalidAccessError - Attempting to disconnect nodes from different contexts"

src/node/channel_merger.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ mod tests {
213213

214214
let mut src1 = context.create_constant_source();
215215
src1.offset().set_value(2.);
216-
src1.connect_at(&merger, 0, 0);
216+
src1.connect_from_output_to_input(&merger, 0, 0);
217217
src1.start();
218218

219219
let mut src2 = context.create_constant_source();
220220
src2.offset().set_value(3.);
221-
src2.connect_at(&merger, 0, 1);
221+
src2.connect_from_output_to_input(&merger, 0, 1);
222222
src2.start();
223223

224224
let buffer = context.start_rendering_sync();
@@ -242,12 +242,12 @@ mod tests {
242242

243243
let mut src1 = context.create_constant_source();
244244
src1.offset().set_value(2.);
245-
src1.connect_at(&merger, 0, 0);
245+
src1.connect_from_output_to_input(&merger, 0, 0);
246246
src1.start();
247247

248248
let mut src2 = context.create_constant_source();
249249
src2.offset().set_value(3.);
250-
src2.connect_at(&merger, 0, 1);
250+
src2.connect_from_output_to_input(&merger, 0, 1);
251251
src2.start();
252252

253253
context.suspend_sync(disconnect_at, move |_| src2.disconnect());

src/node/channel_splitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ mod tests {
265265
let splitter = context.create_channel_splitter(2);
266266

267267
// connect the 2nd output to the destination
268-
splitter.connect_at(&context.destination(), 1, 0);
268+
splitter.connect_from_output_to_input(&context.destination(), 1, 0);
269269

270270
// create buffer with sample value 1. left, value -1. right
271271
let audio_buffer = AudioBuffer::from(vec![vec![1.], vec![-1.]], 48000.);

src/node/delay.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl AudioNode for DelayNode {
127127
}
128128

129129
/// Connect a specific output of this AudioNode to a specific input of another node.
130-
fn connect_at<'a>(
130+
fn connect_from_output_to_input<'a>(
131131
&self,
132132
dest: &'a dyn AudioNode,
133133
output: usize,
@@ -212,7 +212,7 @@ impl AudioNode for DelayNode {
212212
/// - the AudioContext of the source and destination does not match
213213
/// - if the output port is out of bounds for the source node
214214
/// - the source node was not connected to the destination node
215-
fn disconnect_dest_output(&self, dest: &dyn AudioNode, output: usize) {
215+
fn disconnect_dest_from_output(&self, dest: &dyn AudioNode, output: usize) {
216216
assert!(
217217
self.context() == dest.context(),
218218
"InvalidAccessError - Attempting to disconnect nodes from different contexts"
@@ -242,7 +242,12 @@ impl AudioNode for DelayNode {
242242
/// - if the input port is out of bounds for the destination node
243243
/// - if the output port is out of bounds for the source node
244244
/// - the source node was not connected to the destination node
245-
fn disconnect_dest_output_input(&self, dest: &dyn AudioNode, output: usize, input: usize) {
245+
fn disconnect_dest_from_output_to_input(
246+
&self,
247+
dest: &dyn AudioNode,
248+
output: usize,
249+
input: usize,
250+
) {
246251
assert!(
247252
self.context() == dest.context(),
248253
"InvalidAccessError - Attempting to disconnect nodes from different contexts"

0 commit comments

Comments
 (0)