@@ -8,6 +8,8 @@ use crate::{
88 SilenceMask , StreamInfo ,
99} ;
1010
11+ pub mod dummy;
12+
1113/// A globally unique identifier for a node.
1214#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
1315pub struct NodeID ( pub thunderdome:: Index ) ;
@@ -107,7 +109,7 @@ impl Into<AudioNodeInfoInner> for AudioNodeInfo {
107109 }
108110}
109111
110- pub trait AudioNodeConstructor {
112+ pub trait AudioNode : ' static {
111113 /// A type representing this constructor's configuration.
112114 ///
113115 /// This is intended as a one-time configuration to be used
@@ -132,26 +134,26 @@ pub trait AudioNodeConstructor {
132134///
133135/// This should be preferred over `()` because it implements
134136/// [`Component`][bevy_ecs::prelude::Component], making the
135- /// [`AudioNodeConstructor `] implementor trivially Bevy-compatible.
137+ /// [`AudioNode `] implementor trivially Bevy-compatible.
136138#[ derive( Debug , Default , Clone , Copy ) ]
137139#[ cfg_attr( feature = "bevy" , derive( bevy_ecs:: prelude:: Component ) ) ]
138140pub struct EmptyConfig ;
139141
140- /// A dyn-compatible [`AudioNodeConstructor `].
141- pub trait AudioNode {
142+ /// A dyn-compatible [`AudioNode `].
143+ pub trait DynAudioNode : ' static {
142144 fn info ( & self ) -> AudioNodeInfo ;
143145 fn processor ( & self , stream_info : & StreamInfo ) -> Box < dyn AudioNodeProcessor > ;
144146}
145147
146148/// Pairs constructors with their configurations.
147149///
148- /// This is useful for type-erasing an [`AudioNodeConstructor `].
150+ /// This is useful for type-erasing an [`AudioNode `].
149151pub struct Constructor < T , C > {
150152 constructor : T ,
151153 configuration : C ,
152154}
153155
154- impl < T : AudioNodeConstructor > Constructor < T , T :: Configuration > {
156+ impl < T : AudioNode > Constructor < T , T :: Configuration > {
155157 pub fn new ( constructor : T , configuration : Option < T :: Configuration > ) -> Self {
156158 Self {
157159 constructor,
@@ -160,7 +162,7 @@ impl<T: AudioNodeConstructor> Constructor<T, T::Configuration> {
160162 }
161163}
162164
163- impl < T : AudioNodeConstructor > AudioNode for Constructor < T , T :: Configuration > {
165+ impl < T : AudioNode > DynAudioNode for Constructor < T , T :: Configuration > {
164166 fn info ( & self ) -> AudioNodeInfo {
165167 self . constructor . info ( & self . configuration )
166168 }
@@ -334,44 +336,3 @@ impl ProcessStatus {
334336 Self :: OutputsModified { out_silence_mask }
335337 }
336338}
337-
338- /// The configuration for a "dummy" node, a node which does nothing.
339- #[ derive( Default , Debug , Clone , Copy , PartialEq , Eq ) ]
340- pub struct DummyConfig {
341- pub channel_config : ChannelConfig ,
342- }
343-
344- impl AudioNodeConstructor for DummyConfig {
345- type Configuration = ( ) ;
346-
347- fn info ( & self , _config : & Self :: Configuration ) -> AudioNodeInfo {
348- AudioNodeInfo {
349- debug_name : "dummy" ,
350- channel_config : self . channel_config ,
351- uses_events : false ,
352- }
353- }
354-
355- fn processor (
356- & self ,
357- _config : & Self :: Configuration ,
358- _stream_info : & StreamInfo ,
359- ) -> impl AudioNodeProcessor {
360- DummyProcessor
361- }
362- }
363-
364- pub struct DummyProcessor ;
365-
366- impl AudioNodeProcessor for DummyProcessor {
367- fn process (
368- & mut self ,
369- _inputs : & [ & [ f32 ] ] ,
370- _outputs : & mut [ & mut [ f32 ] ] ,
371- _events : NodeEventList ,
372- _proc_info : & ProcInfo ,
373- _scratch_buffers : ScratchBuffers ,
374- ) -> ProcessStatus {
375- ProcessStatus :: Bypass
376- }
377- }
0 commit comments