()
| 22 | |
| 23 | impl AudioSystem { |
| 24 | pub fn new() -> Self { |
| 25 | let mut cx = FirewheelContext::new(Default::default()); |
| 26 | let stream = CpalStream::new(&mut cx, Default::default()).unwrap(); |
| 27 | |
| 28 | let sample_rate = cx.stream_info().unwrap().sample_rate; |
| 29 | |
| 30 | let probed = symphonium::probe_from_file( |
| 31 | "assets/test_files/dpren_very-lush-and-swag-loop.ogg", |
| 32 | None, // Custom container probe |
| 33 | ) |
| 34 | .unwrap(); |
| 35 | let sample = firewheel::dyn_symphonium_resource( |
| 36 | symphonium::decode( |
| 37 | probed, |
| 38 | &symphonium::DecodeConfig::default(), |
| 39 | Some(sample_rate), // target sample rate |
| 40 | None, // An optional cache |
| 41 | None, // Custom codec registry |
| 42 | ) |
| 43 | .unwrap(), |
| 44 | ); |
| 45 | |
| 46 | let graph_out_node_id = cx.graph_out_node_id(); |
| 47 | |
| 48 | let mut sampler_node = SamplerNode { |
| 49 | repeat_mode: RepeatMode::RepeatEndlessly, |
| 50 | ..Default::default() |
| 51 | }; |
| 52 | sampler_node.start_or_restart(); |
| 53 | |
| 54 | let sampler_node_id = cx |
| 55 | .add_node(sampler_node, None) |
| 56 | .expect("Sampler node should construct without error"); |
| 57 | |
| 58 | cx.queue_event_for(sampler_node_id, SamplerNode::set_dyn_sample_event(sample)); |
| 59 | |
| 60 | let spatial_basic_node = SpatialBasicNode::default(); |
| 61 | let spatial_basic_node_id = cx |
| 62 | .add_node(spatial_basic_node, None) |
| 63 | .expect("Spatial basic node should construct without error"); |
| 64 | |
| 65 | cx.connect( |
| 66 | sampler_node_id, |
| 67 | spatial_basic_node_id, |
| 68 | &[(0, 0), (1, 1)], |
| 69 | false, |
| 70 | ) |
| 71 | .unwrap(); |
| 72 | cx.connect( |
| 73 | spatial_basic_node_id, |
| 74 | graph_out_node_id, |
| 75 | &[(0, 0), (1, 1)], |
| 76 | false, |
| 77 | ) |
| 78 | .unwrap(); |
| 79 | |
| 80 | Self { |
| 81 | cx, |
nothing calls this directly
no test coverage detected