Trait bevy_kira_components::sources::AudioSource

source ·
pub trait AudioSource: Asset {
    type Error: Display;
    type Handle: 'static + Send + Sync;
    type Settings: Send + Sync + Default + Component;

    // Required method
    fn create_handle(
        &self,
        manager: &mut AudioManager<AudioBackend>,
        settings: &Self::Settings,
        output_destination: OutputDestination
    ) -> Result<Self::Handle, Self::Error>;
}
Expand description

Trait for implementing an audio source to play in the audio engine.

The audio source needs to provide two things:

  1. An implementation of [kira::sound::Sound] which is going to be sent to the audio engine to generate audio samples
  2. A handle which sets up communication between the aforementioned sound and the rest of the world.

The trait supports a Settings struct, which allows users to customize the sound that will be sent before its creation.

Required Associated Types§

source

type Error: Display

Error type that encompasses possible errors that can happen when creating the audio source

source

type Handle: 'static + Send + Sync

Handle to the audio source, which allows control over the source from a non-audio thread.

This handle will be stored in a component, which you can get by querying for AudioHandle<Self::Handle>.

source

type Settings: Send + Sync + Default + Component

Settings associated with this audio source, and passed in to the source for its creation.

Required Methods§

source

fn create_handle( &self, manager: &mut AudioManager<AudioBackend>, settings: &Self::Settings, output_destination: OutputDestination ) -> Result<Self::Handle, Self::Error>

Create an audio handle by calling the manager to play the sound data.

Object Safety§

This trait is not object safe.

Implementors§