firewheel_pool/
spatial_basic.rs1#[cfg(feature = "scheduled_events")]
2use firewheel_core::clock::EventInstant;
3
4use firewheel_core::{channel_config::NonZeroChannelCount, diff::Diff, node::NodeID};
5use firewheel_graph::{backend::AudioBackend, FirewheelCtx};
6
7use crate::FxChain;
8
9#[derive(Default, Debug, Clone, Copy, PartialEq)]
13pub struct SpatialBasicChain {
14 pub spatial_basic: firewheel_nodes::spatial_basic::SpatialBasicNode,
15}
16
17impl SpatialBasicChain {
18 pub fn set_params<B: AudioBackend>(
25 &mut self,
26 params: firewheel_nodes::spatial_basic::SpatialBasicNode,
27 #[cfg(feature = "scheduled_events")] time: Option<EventInstant>,
28 node_ids: &[NodeID],
29 cx: &mut FirewheelCtx<B>,
30 ) {
31 use firewheel_core::diff::PathBuilder;
32
33 let node_id = node_ids[0];
34
35 self.spatial_basic.diff(
36 ¶ms,
37 PathBuilder::default(),
38 #[cfg(not(feature = "scheduled_events"))]
39 &mut cx.event_queue(node_id),
40 #[cfg(feature = "scheduled_events")]
41 &mut cx.event_queue_scheduled(node_id, time),
42 );
43 }
44}
45
46impl FxChain for SpatialBasicChain {
47 fn construct_and_connect<B: AudioBackend>(
48 &mut self,
49 first_node_id: NodeID,
50 first_node_num_out_channels: NonZeroChannelCount,
51 dst_node_id: NodeID,
52 dst_num_channels: NonZeroChannelCount,
53 cx: &mut FirewheelCtx<B>,
54 ) -> Vec<NodeID> {
55 let spatial_basic_params = firewheel_nodes::spatial_basic::SpatialBasicNode::default();
56
57 let spatial_basic_node_id = cx.add_node(spatial_basic_params, None);
58
59 cx.connect(
60 first_node_id,
61 spatial_basic_node_id,
62 if first_node_num_out_channels.get().get() == 1 {
63 &[(0, 0), (0, 1)]
64 } else {
65 &[(0, 0), (1, 1)]
66 },
67 false,
68 )
69 .unwrap();
70
71 cx.connect(
72 spatial_basic_node_id,
73 dst_node_id,
74 if dst_num_channels.get().get() == 1 {
75 &[(0, 0), (1, 0)]
76 } else {
77 &[(0, 0), (1, 1)]
78 },
79 false,
80 )
81 .unwrap();
82
83 vec![spatial_basic_node_id]
84 }
85}