pub struct SamplerNode {
pub sample: Option<ArcGc<dyn SampleResource>>,
pub volume: Volume,
pub play: Notify<bool>,
pub play_from: PlayFrom,
pub repeat_mode: RepeatMode,
pub speed: f64,
pub mono_to_stereo: bool,
pub crossfade_on_seek: bool,
pub min_gain: f32,
}Expand description
A node that plays samples
It supports pausing, resuming, looping, and changing the playback speed.
Fields§
§sample: Option<ArcGc<dyn SampleResource>>The sample resource to use.
volume: VolumeThe volume to play the sample at.
Note, this gain parameter is NOT smoothed! If you need the gain to be
smoothed, please use a VolumeNode or a VolumePanNode.
play: Notify<bool>Whether or not the current sample should start/restart playing (true), or be paused/stopped (false).
play_from: PlayFromDefines where the sampler should start playing from when
SamplerNode::play is set to true.
repeat_mode: RepeatModeHow many times a sample should be repeated.
speed: f64The speed at which to play the sample at. 1.0 means to play the sound at
its original speed, < 1.0 means to play the sound slower (which will make
it lower-pitched), and > 1.0 means to play the sound faster (which will
make it higher-pitched).
mono_to_stereo: boolIf true, then mono samples will be converted to stereo during playback.
By default this is set to true.
crossfade_on_seek: boolIf true, then samples will be crossfaded when the playhead or sample is changed (if a sample was currently playing when the event was sent).
By default this is set to true.
min_gain: f32If the resutling gain (in raw amplitude, not decibels) is less
than or equal to this value, then the gain will be clamped to
0.0 (silence).
By default this is set to 0.00001 (-100 decibels).
Implementations§
Source§impl SamplerNode
impl SamplerNode
Sourcepub fn set_sample(&mut self, sample: ArcGc<dyn SampleResource>)
pub fn set_sample(&mut self, sample: ArcGc<dyn SampleResource>)
Set the parameters to a play a single sample.
Sourcepub fn sync_sample_event(&self) -> NodeEventType
pub fn sync_sample_event(&self) -> NodeEventType
Returns an event type to sync the sample parameter.
Sourcepub fn sync_volume_event(&self) -> NodeEventType
pub fn sync_volume_event(&self) -> NodeEventType
Returns an event type to sync the volume parameter.
Sourcepub fn sync_play_event(&self) -> NodeEventType
pub fn sync_play_event(&self) -> NodeEventType
Returns an event type to sync the play parameter.
Sourcepub fn sync_play_from_event(&self) -> NodeEventType
pub fn sync_play_from_event(&self) -> NodeEventType
Returns an event type to sync the play_from parameter.
Sourcepub fn sync_repeat_mode_event(&self) -> NodeEventType
pub fn sync_repeat_mode_event(&self) -> NodeEventType
Returns an event type to sync the playhead parameter.
Sourcepub fn sync_speed_event(&self) -> NodeEventType
pub fn sync_speed_event(&self) -> NodeEventType
Returns an event type to sync the speed parameter.
Sourcepub fn start_or_restart(&mut self)
pub fn start_or_restart(&mut self)
Start/restart the sample in this node.
If a sample is already playing, then it will restart from the beginning.
Sourcepub fn start_from(&mut self, from: PlayFrom)
pub fn start_from(&mut self, from: PlayFrom)
Play the sample in this node from the given playhead.
Sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Stop sample playback.
Calling SamplerNode::resume after this will restart the sample from
the beginning.
Sourcepub fn start_or_restart_requested(&self) -> bool
pub fn start_or_restart_requested(&self) -> bool
Returns true if the current state is set to restart the sample.
Sourcepub fn resume_requested(&self) -> bool
pub fn resume_requested(&self) -> bool
Returns true if the current state is set to resume the sample.
Sourcepub fn pause_requested(&self) -> bool
pub fn pause_requested(&self) -> bool
Returns true if the current state is set to pause the sample.
Sourcepub fn stop_requested(&self) -> bool
pub fn stop_requested(&self) -> bool
Returns true if the current state is set to stop the sample.
Trait Implementations§
Source§impl AudioNode for SamplerNode
impl AudioNode for SamplerNode
Source§type Configuration = SamplerConfig
type Configuration = SamplerConfig
Source§fn info(&self, config: &Self::Configuration) -> AudioNodeInfo
fn info(&self, config: &Self::Configuration) -> AudioNodeInfo
Source§fn construct_processor(
&self,
config: &Self::Configuration,
cx: ConstructProcessorContext<'_>,
) -> impl AudioNodeProcessor
fn construct_processor( &self, config: &Self::Configuration, cx: ConstructProcessorContext<'_>, ) -> impl AudioNodeProcessor
Source§fn update(&mut self, configuration: &Self::Configuration, cx: UpdateContext<'_>)
fn update(&mut self, configuration: &Self::Configuration, cx: UpdateContext<'_>)
AudioNodeInfo::call_update_method was set to true, then the Firewheel
context will call this method on every update cycle. Read moreSource§impl Clone for SamplerNode
impl Clone for SamplerNode
Source§fn clone(&self) -> SamplerNode
fn clone(&self) -> SamplerNode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for SamplerNode
impl Component for SamplerNode
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§impl Debug for SamplerNode
impl Debug for SamplerNode
Source§impl Default for SamplerNode
impl Default for SamplerNode
Source§impl Diff for SamplerNode
impl Diff for SamplerNode
Source§fn diff<__E: EventQueue>(
&self,
baseline: &Self,
path: PathBuilder,
event_queue: &mut __E,
)
fn diff<__E: EventQueue>( &self, baseline: &Self, path: PathBuilder, event_queue: &mut __E, )
self to baseline and generate events to resolve any differences.Source§impl PartialEq for SamplerNode
impl PartialEq for SamplerNode
Source§impl Patch for SamplerNode
impl Patch for SamplerNode
Source§type Patch = SamplerNodePatch
type Patch = SamplerNodePatch
Source§fn patch(data: &ParamData, path: &[u32]) -> Result<Self::Patch, PatchError>
fn patch(data: &ParamData, path: &[u32]) -> Result<Self::Patch, PatchError>
Source§fn patch_event(event: &NodeEventType) -> Option<Self::Patch>
fn patch_event(event: &NodeEventType) -> Option<Self::Patch>
impl StructuralPartialEq for SamplerNode
Auto Trait Implementations§
impl Freeze for SamplerNode
impl !RefUnwindSafe for SamplerNode
impl Send for SamplerNode
impl Sync for SamplerNode
impl Unpin for SamplerNode
impl !UnwindSafe for SamplerNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ids: &mut impl FnMut(ComponentId), )
Source§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Source§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().