[][src]Struct kira::manager::AudioManager

pub struct AudioManager { /* fields omitted */ }

Plays and manages audio.

The audio manager is responsible for all communication between the gameplay thread and the audio thread.

Implementations

impl AudioManager[src]

pub fn new(settings: AudioManagerSettings) -> AudioResult<Self>[src]

Creates a new audio manager and starts an audio thread.

pub fn add_sound(&mut self, sound: Sound) -> AudioResult<SoundId>[src]

Sends a sound to the audio thread and returns a handle to the sound.

pub fn load_sound<P: AsRef<Path>>(
    &mut self,
    path: P,
    settings: PlayableSettings
) -> AudioResult<SoundId>
[src]

Loads a sound from a file and returns a handle to the sound.

This is a shortcut for constructing the sound manually and adding it using AudioManager::add_sound.

pub fn remove_sound(&mut self, id: SoundId) -> AudioResult<()>[src]

Removes a sound from the audio thread, allowing its memory to be freed.

pub fn add_arrangement(
    &mut self,
    arrangement: Arrangement
) -> AudioResult<ArrangementId>
[src]

Sends a arrangement to the audio thread and returns a handle to the arrangement.

pub fn remove_arrangement(&mut self, id: ArrangementId) -> AudioResult<()>[src]

Removes a arrangement from the audio thread, allowing its memory to be freed.

pub fn free_unused_resources(&mut self)[src]

Frees resources that are no longer in use, such as unloaded sounds or finished sequences.

pub fn play<P: Into<Playable>>(
    &mut self,
    playable: P,
    settings: InstanceSettings
) -> Result<InstanceId, AudioError>
[src]

Plays a sound or arrangement.

pub fn set_instance_volume<V: Into<Value<f64>>>(
    &mut self,
    id: InstanceId,
    volume: V
) -> Result<(), AudioError>
[src]

Sets the volume of an instance.

pub fn set_instance_pitch<V: Into<Value<f64>>>(
    &mut self,
    id: InstanceId,
    pitch: V
) -> Result<(), AudioError>
[src]

Sets the pitch of an instance.

pub fn set_instance_panning<V: Into<Value<f64>>>(
    &mut self,
    id: InstanceId,
    panning: V
) -> Result<(), AudioError>
[src]

Sets the panning of an instance (0 = hard left, 1 = hard right).

pub fn seek_instance(
    &mut self,
    id: InstanceId,
    offset: f64
) -> Result<(), AudioError>
[src]

Moves the playback position of an instance backward or forward.

pub fn seek_instance_to(
    &mut self,
    id: InstanceId,
    position: f64
) -> Result<(), AudioError>
[src]

Sets the playback position of an instance.

pub fn pause_instance(
    &mut self,
    instance_id: InstanceId,
    settings: PauseInstanceSettings
) -> Result<(), AudioError>
[src]

Pauses a currently playing instance of a sound with an optional fade-out tween.

pub fn resume_instance(
    &mut self,
    instance_id: InstanceId,
    settings: ResumeInstanceSettings
) -> Result<(), AudioError>
[src]

Resumes a currently paused instance of a sound with an optional fade-in tween.

pub fn stop_instance(
    &mut self,
    instance_id: InstanceId,
    settings: StopInstanceSettings
) -> Result<(), AudioError>
[src]

Stops a currently playing instance of a sound with an optional fade-out tween.

Once the instance is stopped, it cannot be restarted.

pub fn pause_instances_of(
    &mut self,
    playable: Playable,
    settings: PauseInstanceSettings
) -> Result<(), AudioError>
[src]

Pauses all currently playing instances of a sound or arrangement with an optional fade-out tween.

pub fn resume_instances_of(
    &mut self,
    playable: Playable,
    settings: ResumeInstanceSettings
) -> Result<(), AudioError>
[src]

Resumes all currently playing instances of a sound or arrangement with an optional fade-in tween.

pub fn stop_instances_of(
    &mut self,
    playable: Playable,
    settings: StopInstanceSettings
) -> Result<(), AudioError>
[src]

Stops all currently playing instances of a sound or arrangement with an optional fade-out tween.

pub fn set_metronome_tempo<T: Into<Value<Tempo>>>(
    &mut self,
    tempo: T
) -> Result<(), AudioError>
[src]

Sets the tempo of the metronome.

pub fn start_metronome(&mut self) -> Result<(), AudioError>[src]

Starts or resumes the metronome.

pub fn pause_metronome(&mut self) -> Result<(), AudioError>[src]

Pauses the metronome.

pub fn stop_metronome(&mut self) -> Result<(), AudioError>[src]

Stops and resets the metronome.

pub fn start_sequence<CustomEvent: Clone + Eq + Hash>(
    &mut self,
    sequence: Sequence<CustomEvent>,
    settings: SequenceInstanceSettings
) -> Result<(SequenceInstanceId, EventReceiver<CustomEvent>), AudioError>
[src]

Starts a sequence.

pub fn mute_sequence(
    &mut self,
    id: SequenceInstanceId
) -> Result<(), AudioError>
[src]

Mutes a sequence.

When a sequence is muted, it will continue waiting for durations and intervals, but it will not play sounds, emit events, or perform any other actions.

pub fn unmute_sequence(
    &mut self,
    id: SequenceInstanceId
) -> Result<(), AudioError>
[src]

Unmutes a sequence.

pub fn pause_sequence(
    &mut self,
    id: SequenceInstanceId
) -> Result<(), AudioError>
[src]

Pauses a sequence.

pub fn resume_sequence(
    &mut self,
    id: SequenceInstanceId
) -> Result<(), AudioError>
[src]

Resumes a sequence.

pub fn stop_sequence(
    &mut self,
    id: SequenceInstanceId
) -> Result<(), AudioError>
[src]

Stops a sequence.

pub fn pause_sequence_and_instances(
    &mut self,
    id: SequenceInstanceId,
    settings: PauseInstanceSettings
) -> Result<(), AudioError>
[src]

Pauses a sequence and any instances played by that sequence.

pub fn resume_sequence_and_instances(
    &mut self,
    id: SequenceInstanceId,
    settings: ResumeInstanceSettings
) -> Result<(), AudioError>
[src]

Resumes a sequence and any instances played by that sequence.

pub fn stop_sequence_and_instances(
    &mut self,
    id: SequenceInstanceId,
    settings: StopInstanceSettings
) -> Result<(), AudioError>
[src]

Stops a sequence and any instances played by that sequence.

pub fn add_parameter(&mut self, value: f64) -> AudioResult<ParameterId>[src]

Creates a parameter with the specified starting value.

pub fn remove_parameter(&mut self, id: ParameterId) -> AudioResult<()>[src]

Removes a parameter.

pub fn set_parameter(
    &mut self,
    id: ParameterId,
    value: f64,
    tween: Option<Tween>
) -> AudioResult<()>
[src]

Sets the value of a parameter with an optional tween to smoothly change the value.

pub fn add_sub_track(
    &mut self,
    settings: TrackSettings
) -> AudioResult<SubTrackId>
[src]

Creates a mixer sub-track.

pub fn remove_sub_track(&mut self, id: SubTrackId) -> AudioResult<()>[src]

Removes a sub-track from the mixer.

pub fn add_effect_to_track<T: Into<TrackIndex> + Copy, E: Effect + 'static>(
    &mut self,
    track_index: T,
    effect: E,
    settings: EffectSettings
) -> AudioResult<EffectId>
[src]

Adds an effect to a track.

pub fn remove_effect(&mut self, effect_id: EffectId) -> AudioResult<()>[src]

Removes an effect from the mixer.

pub fn add_stream<T: Into<TrackIndex>, S: AudioStream>(
    &mut self,
    track_index: T,
    stream: S
) -> AudioResult<AudioStreamId>
[src]

Starts an audio stream on the specified track.

pub fn remove_stream(&mut self, stream_id: AudioStreamId) -> AudioResult<()>[src]

Stops and drops the specified audio stream.

pub fn add_group<T: Into<Vec<GroupId>>>(
    &mut self,
    parent_groups: T
) -> AudioResult<GroupId>
[src]

Adds a group.

pub fn remove_group(&mut self, id: GroupId) -> AudioResult<()>[src]

Removes a group.

pub fn pause_group(
    &mut self,
    id: GroupId,
    settings: PauseInstanceSettings
) -> AudioResult<()>
[src]

Pauses all instances of sounds, arrangements, and sequences in a group.

pub fn resume_group(
    &mut self,
    id: GroupId,
    settings: ResumeInstanceSettings
) -> AudioResult<()>
[src]

Resumes all instances of sounds, arrangements, and sequences in a group.

pub fn stop_group(
    &mut self,
    id: GroupId,
    settings: StopInstanceSettings
) -> AudioResult<()>
[src]

Stops all instances of sounds, arrangements, and sequences in a group.

pub fn pop_event(&mut self) -> Option<Event>[src]

Pops an event that was sent by the audio thread.

Trait Implementations

impl Drop for AudioManager[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.