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

Method new

examples/sampler_test/src/system.rs:38–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37impl AudioSystem {
38 pub fn new() -> Self {
39 let mut cx = FirewheelContext::new(Default::default());
40 let stream = CpalStream::new(&mut cx, Default::default()).unwrap();
41
42 let sample_rate = cx.stream_info().unwrap().sample_rate;
43
44 let cache = SymphoniumCache::default();
45
46 let graph_out = cx.graph_out_node_id();
47
48 let peak_meter_node = PeakMeterNode::<2> { enabled: true };
49 let peak_meter_smoother = PeakMeterSmoother::<2>::new(Default::default());
50
51 let peak_meter_id = cx
52 .add_node(peak_meter_node, None)
53 .expect("Peak meter node should construct without error");
54
55 cx.connect(peak_meter_id, graph_out, &[(0, 0), (1, 1)], false)
56 .unwrap();
57
58 let samplers = SAMPLE_PATHS
59 .iter()
60 .map(|path| {
61 let probed = symphonium::probe_from_file(
62 path, None, // Custom container probe
63 )
64 .unwrap();
65 let sample = firewheel::dyn_symphonium_resource(
66 symphonium::decode(
67 probed,
68 &symphonium::DecodeConfig::default(),
69 Some(sample_rate), // target sample rate
70 Some(&cache), // An optional cache
71 None, // Custom codec registry
72 )
73 .unwrap(),
74 );
75
76 let params = SamplerNode::default();
77
78 let node_id = cx
79 .add_node(params, None)
80 .expect("Sampler node should construct without error");
81
82 cx.queue_event_for(node_id, SamplerNode::set_dyn_sample_event(sample));
83
84 cx.connect(node_id, peak_meter_id, &[(0, 0), (1, 1)], false)
85 .unwrap();
86
87 Sampler {
88 params: Memo::new(params),
89 node_id,
90 }
91 })
92 .collect();
93
94 Self {
95 cx,

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected