pub struct StreamController { /* private fields */ }Implementations§
Source§impl StreamController
impl StreamController
Sourcepub fn get_best_sample_rate(requested_rate: f32) -> Result<f32>
pub fn get_best_sample_rate(requested_rate: f32) -> Result<f32>
Get the best available sample rate for audio output
Sourcepub fn play(runtime: Runtime) -> Result<Self>
pub fn play(runtime: Runtime) -> Result<Self>
Examples found in repository?
examples/play_sine.rs (line 27)
8fn main() -> anyhow::Result<()> {
9 // Build a simple sine wave graph
10 let mut graph = Graph::new();
11 let osc = graph.add_node(NodeType::SineOsc { freq: 440.0 });
12 let sink = graph.add_node(NodeType::OutputSink);
13 graph
14 .add_edge(auxide::graph::Edge {
15 from_node: osc,
16 from_port: PortId(0),
17 to_node: sink,
18 to_port: PortId(0),
19 rate: Rate::Audio,
20 })
21 .unwrap();
22
23 let plan = Plan::compile(&graph, 512).unwrap();
24 let runtime = Runtime::new(plan, &graph, 192000.0);
25
26 // Create and start the stream
27 let controller = StreamController::play(runtime)?;
28 controller.start()?;
29
30 println!("Playing 440Hz sine wave for 5 seconds...");
31 thread::sleep(Duration::from_secs(5));
32
33 controller.stop();
34 println!("Stopped.");
35
36 Ok(())
37}More examples
examples/play_tone.rs (line 26)
7fn main() -> anyhow::Result<()> {
8 // Build 440Hz sine
9 let mut graph = Graph::new();
10 let osc = graph.add_node(NodeType::SineOsc { freq: 440.0 });
11 let sink = graph.add_node(NodeType::OutputSink);
12 graph
13 .add_edge(auxide::graph::Edge {
14 from_node: osc,
15 from_port: PortId(0),
16 to_node: sink,
17 to_port: PortId(0),
18 rate: Rate::Audio,
19 })
20 .unwrap();
21
22 let plan = Plan::compile(&graph, 512).unwrap();
23 let runtime = Runtime::new(plan, &graph, 192000.0);
24
25 // Play it
26 let controller = StreamController::play(runtime)?;
27 controller.start()?;
28
29 println!("Playing 440Hz tone. Press Enter to stop...");
30 let mut input = String::new();
31 std::io::stdin().read_line(&mut input)?;
32
33 controller.stop();
34 println!("Stopped.");
35
36 Ok(())
37}examples/audio_mixer.rs (line 65)
15fn main() -> anyhow::Result<()> {
16 println!("Auxide Mixer Demo");
17 println!("Playing a chord: 440Hz (A) + 554Hz (C#)...");
18
19 // Create graph: two oscillators + mixer + output
20 let mut graph = Graph::new();
21
22 // Oscillator 1: 440Hz (A note)
23 let osc1 = graph.add_node(NodeType::SineOsc { freq: 440.0 });
24
25 // Oscillator 2: 554Hz (C# note) - creates a major sixth interval
26 let osc2 = graph.add_node(NodeType::SineOsc { freq: 554.0 });
27
28 // Mixer to combine the two oscillators
29 let mix = graph.add_node(NodeType::Mix);
30
31 // Output sink
32 let sink = graph.add_node(NodeType::OutputSink);
33
34 // Connect: osc1 -> mix (input 0)
35 graph.add_edge(auxide::graph::Edge {
36 from_node: osc1,
37 from_port: PortId(0),
38 to_node: mix,
39 to_port: PortId(0),
40 rate: Rate::Audio,
41 }).unwrap();
42
43 // Connect: osc2 -> mix (input 1)
44 graph.add_edge(auxide::graph::Edge {
45 from_node: osc2,
46 from_port: PortId(0),
47 to_node: mix,
48 to_port: PortId(1),
49 rate: Rate::Audio,
50 }).unwrap();
51
52 // Connect: mix -> output
53 graph.add_edge(auxide::graph::Edge {
54 from_node: mix,
55 from_port: PortId(0),
56 to_node: sink,
57 to_port: PortId(0),
58 rate: Rate::Audio,
59 }).unwrap();
60
61 let plan = Plan::compile(&graph, 512).unwrap();
62 let runtime = Runtime::new(plan, &graph, 44100.0);
63
64 // Play the mixed oscillators
65 let controller = StreamController::play(runtime)?;
66 controller.start()?;
67
68 println!("Playing for 10 seconds...");
69 thread::sleep(Duration::from_secs(10));
70
71 controller.stop();
72 println!("Mixer demo complete!");
73
74 Ok(())
75}Sourcepub fn start(&self) -> Result<()>
pub fn start(&self) -> Result<()>
Examples found in repository?
examples/play_sine.rs (line 28)
8fn main() -> anyhow::Result<()> {
9 // Build a simple sine wave graph
10 let mut graph = Graph::new();
11 let osc = graph.add_node(NodeType::SineOsc { freq: 440.0 });
12 let sink = graph.add_node(NodeType::OutputSink);
13 graph
14 .add_edge(auxide::graph::Edge {
15 from_node: osc,
16 from_port: PortId(0),
17 to_node: sink,
18 to_port: PortId(0),
19 rate: Rate::Audio,
20 })
21 .unwrap();
22
23 let plan = Plan::compile(&graph, 512).unwrap();
24 let runtime = Runtime::new(plan, &graph, 192000.0);
25
26 // Create and start the stream
27 let controller = StreamController::play(runtime)?;
28 controller.start()?;
29
30 println!("Playing 440Hz sine wave for 5 seconds...");
31 thread::sleep(Duration::from_secs(5));
32
33 controller.stop();
34 println!("Stopped.");
35
36 Ok(())
37}More examples
examples/play_tone.rs (line 27)
7fn main() -> anyhow::Result<()> {
8 // Build 440Hz sine
9 let mut graph = Graph::new();
10 let osc = graph.add_node(NodeType::SineOsc { freq: 440.0 });
11 let sink = graph.add_node(NodeType::OutputSink);
12 graph
13 .add_edge(auxide::graph::Edge {
14 from_node: osc,
15 from_port: PortId(0),
16 to_node: sink,
17 to_port: PortId(0),
18 rate: Rate::Audio,
19 })
20 .unwrap();
21
22 let plan = Plan::compile(&graph, 512).unwrap();
23 let runtime = Runtime::new(plan, &graph, 192000.0);
24
25 // Play it
26 let controller = StreamController::play(runtime)?;
27 controller.start()?;
28
29 println!("Playing 440Hz tone. Press Enter to stop...");
30 let mut input = String::new();
31 std::io::stdin().read_line(&mut input)?;
32
33 controller.stop();
34 println!("Stopped.");
35
36 Ok(())
37}examples/audio_mixer.rs (line 66)
15fn main() -> anyhow::Result<()> {
16 println!("Auxide Mixer Demo");
17 println!("Playing a chord: 440Hz (A) + 554Hz (C#)...");
18
19 // Create graph: two oscillators + mixer + output
20 let mut graph = Graph::new();
21
22 // Oscillator 1: 440Hz (A note)
23 let osc1 = graph.add_node(NodeType::SineOsc { freq: 440.0 });
24
25 // Oscillator 2: 554Hz (C# note) - creates a major sixth interval
26 let osc2 = graph.add_node(NodeType::SineOsc { freq: 554.0 });
27
28 // Mixer to combine the two oscillators
29 let mix = graph.add_node(NodeType::Mix);
30
31 // Output sink
32 let sink = graph.add_node(NodeType::OutputSink);
33
34 // Connect: osc1 -> mix (input 0)
35 graph.add_edge(auxide::graph::Edge {
36 from_node: osc1,
37 from_port: PortId(0),
38 to_node: mix,
39 to_port: PortId(0),
40 rate: Rate::Audio,
41 }).unwrap();
42
43 // Connect: osc2 -> mix (input 1)
44 graph.add_edge(auxide::graph::Edge {
45 from_node: osc2,
46 from_port: PortId(0),
47 to_node: mix,
48 to_port: PortId(1),
49 rate: Rate::Audio,
50 }).unwrap();
51
52 // Connect: mix -> output
53 graph.add_edge(auxide::graph::Edge {
54 from_node: mix,
55 from_port: PortId(0),
56 to_node: sink,
57 to_port: PortId(0),
58 rate: Rate::Audio,
59 }).unwrap();
60
61 let plan = Plan::compile(&graph, 512).unwrap();
62 let runtime = Runtime::new(plan, &graph, 44100.0);
63
64 // Play the mixed oscillators
65 let controller = StreamController::play(runtime)?;
66 controller.start()?;
67
68 println!("Playing for 10 seconds...");
69 thread::sleep(Duration::from_secs(10));
70
71 controller.stop();
72 println!("Mixer demo complete!");
73
74 Ok(())
75}Sourcepub fn stop(&self)
pub fn stop(&self)
Examples found in repository?
examples/play_sine.rs (line 33)
8fn main() -> anyhow::Result<()> {
9 // Build a simple sine wave graph
10 let mut graph = Graph::new();
11 let osc = graph.add_node(NodeType::SineOsc { freq: 440.0 });
12 let sink = graph.add_node(NodeType::OutputSink);
13 graph
14 .add_edge(auxide::graph::Edge {
15 from_node: osc,
16 from_port: PortId(0),
17 to_node: sink,
18 to_port: PortId(0),
19 rate: Rate::Audio,
20 })
21 .unwrap();
22
23 let plan = Plan::compile(&graph, 512).unwrap();
24 let runtime = Runtime::new(plan, &graph, 192000.0);
25
26 // Create and start the stream
27 let controller = StreamController::play(runtime)?;
28 controller.start()?;
29
30 println!("Playing 440Hz sine wave for 5 seconds...");
31 thread::sleep(Duration::from_secs(5));
32
33 controller.stop();
34 println!("Stopped.");
35
36 Ok(())
37}More examples
examples/play_tone.rs (line 33)
7fn main() -> anyhow::Result<()> {
8 // Build 440Hz sine
9 let mut graph = Graph::new();
10 let osc = graph.add_node(NodeType::SineOsc { freq: 440.0 });
11 let sink = graph.add_node(NodeType::OutputSink);
12 graph
13 .add_edge(auxide::graph::Edge {
14 from_node: osc,
15 from_port: PortId(0),
16 to_node: sink,
17 to_port: PortId(0),
18 rate: Rate::Audio,
19 })
20 .unwrap();
21
22 let plan = Plan::compile(&graph, 512).unwrap();
23 let runtime = Runtime::new(plan, &graph, 192000.0);
24
25 // Play it
26 let controller = StreamController::play(runtime)?;
27 controller.start()?;
28
29 println!("Playing 440Hz tone. Press Enter to stop...");
30 let mut input = String::new();
31 std::io::stdin().read_line(&mut input)?;
32
33 controller.stop();
34 println!("Stopped.");
35
36 Ok(())
37}examples/audio_mixer.rs (line 71)
15fn main() -> anyhow::Result<()> {
16 println!("Auxide Mixer Demo");
17 println!("Playing a chord: 440Hz (A) + 554Hz (C#)...");
18
19 // Create graph: two oscillators + mixer + output
20 let mut graph = Graph::new();
21
22 // Oscillator 1: 440Hz (A note)
23 let osc1 = graph.add_node(NodeType::SineOsc { freq: 440.0 });
24
25 // Oscillator 2: 554Hz (C# note) - creates a major sixth interval
26 let osc2 = graph.add_node(NodeType::SineOsc { freq: 554.0 });
27
28 // Mixer to combine the two oscillators
29 let mix = graph.add_node(NodeType::Mix);
30
31 // Output sink
32 let sink = graph.add_node(NodeType::OutputSink);
33
34 // Connect: osc1 -> mix (input 0)
35 graph.add_edge(auxide::graph::Edge {
36 from_node: osc1,
37 from_port: PortId(0),
38 to_node: mix,
39 to_port: PortId(0),
40 rate: Rate::Audio,
41 }).unwrap();
42
43 // Connect: osc2 -> mix (input 1)
44 graph.add_edge(auxide::graph::Edge {
45 from_node: osc2,
46 from_port: PortId(0),
47 to_node: mix,
48 to_port: PortId(1),
49 rate: Rate::Audio,
50 }).unwrap();
51
52 // Connect: mix -> output
53 graph.add_edge(auxide::graph::Edge {
54 from_node: mix,
55 from_port: PortId(0),
56 to_node: sink,
57 to_port: PortId(0),
58 rate: Rate::Audio,
59 }).unwrap();
60
61 let plan = Plan::compile(&graph, 512).unwrap();
62 let runtime = Runtime::new(plan, &graph, 44100.0);
63
64 // Play the mixed oscillators
65 let controller = StreamController::play(runtime)?;
66 controller.start()?;
67
68 println!("Playing for 10 seconds...");
69 thread::sleep(Duration::from_secs(10));
70
71 controller.stop();
72 println!("Mixer demo complete!");
73
74 Ok(())
75}pub fn has_error(&self) -> bool
pub fn clear_error(&self)
Auto Trait Implementations§
impl Freeze for StreamController
impl !RefUnwindSafe for StreamController
impl !Send for StreamController
impl !Sync for StreamController
impl Unpin for StreamController
impl !UnwindSafe for StreamController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more