Add a node to the audio graph.
(
&mut self,
node: T,
config: Option<T::Configuration>,
)
| 194 | |
| 195 | /// Add a node to the audio graph. |
| 196 | pub fn add_node<T: AudioNode + 'static>( |
| 197 | &mut self, |
| 198 | node: T, |
| 199 | config: Option<T::Configuration>, |
| 200 | ) -> Result<NodeID, NodeError> { |
| 201 | let constructor = Constructor::new(node, config); |
| 202 | let info: AudioNodeInfoInner = constructor.info()?.into(); |
| 203 | let call_update_method = info.call_update_method; |
| 204 | |
| 205 | let new_id = NodeID( |
| 206 | self.nodes |
| 207 | .insert(NodeEntry::new(info, Box::new(constructor))), |
| 208 | ); |
| 209 | self.nodes[new_id.0].id = new_id; |
| 210 | |
| 211 | if call_update_method { |
| 212 | self.nodes_to_call_update_method.push(new_id); |
| 213 | } |
| 214 | |
| 215 | self.needs_compile = true; |
| 216 | |
| 217 | if let Some(guard) = self.modify_guard_stack.last_mut() { |
| 218 | guard.new_nodes.push(new_id); |
| 219 | } |
| 220 | |
| 221 | Ok(new_id) |
| 222 | } |
| 223 | |
| 224 | /// Add a node to the audio graph which implements the type-erased [`DynAudioNode`] trait. |
| 225 | pub fn add_dyn_node<T: DynAudioNode + 'static>( |
no test coverage detected