MCPcopy Create free account
hub / github.com/BillyDM/Firewheel / new

Method new

examples/visualizer/src/system.rs:29–96  ·  view source on GitHub ↗
(window_size: u32)

Source from the content-addressed store, hash-verified

27
28impl AudioSystem {
29 pub fn new(window_size: u32) -> Self {
30 let mut cx = FirewheelContext::new(Default::default());
31 let stream = CpalStream::new(&mut cx, Default::default()).unwrap();
32
33 let sample_rate = cx.stream_info().unwrap().sample_rate;
34 let graph_out = cx.graph_out_node_id();
35
36 let probed = symphonium::probe_from_file(
37 SAMPLE_PATH,
38 None, // Custom container probe
39 )
40 .unwrap();
41 let sample = firewheel::dyn_symphonium_resource(
42 symphonium::decode(
43 probed,
44 &symphonium::DecodeConfig::default(),
45 Some(sample_rate), // target sample rate
46 None, // An optional cache
47 None, // Custom codec registry
48 )
49 .unwrap(),
50 );
51
52 let sampler_params = SamplerNode::default();
53 let sampler_node_id = cx
54 .add_node(sampler_params, None)
55 .expect("Sampler node should construct without error");
56 cx.queue_event_for(sampler_node_id, SamplerNode::set_dyn_sample_event(sample));
57
58 let triple_buffer_params = TripleBufferNode {
59 window_size: WindowSize::Samples(window_size),
60 };
61 let triple_buffer_node_id = cx
62 .add_node(
63 triple_buffer_params,
64 Some(TripleBufferConfig {
65 max_window_size: WindowSize::Samples(2048),
66 channels: NonZeroChannelCount::STEREO,
67 }),
68 )
69 .expect("Triple buffer node should construct without error");
70
71 cx.connect(sampler_node_id, graph_out, &[(0, 0), (1, 1)], false)
72 .unwrap();
73 cx.connect(
74 sampler_node_id,
75 triple_buffer_node_id,
76 &[(0, 0), (1, 1)],
77 false,
78 )
79 .unwrap();
80
81 let triple_buffer_state = cx
82 .node_state::<TripleBufferState>(triple_buffer_node_id)
83 .unwrap()
84 .clone();
85
86 Self {

Callers

nothing calls this directly

Calls 7

dyn_symphonium_resourceFunction · 0.85
queue_event_forMethod · 0.80
stream_infoMethod · 0.45
graph_out_node_idMethod · 0.45
add_nodeMethod · 0.45
connectMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected