Skip to main content

Crate bevy_audio

Crate bevy_audio 

Source
Expand description

Audio support for the game engine Bevy

fn main() {
   App::new()
        .add_plugins((MinimalPlugins, AssetPlugin::default(), AudioPlugin::default()))
        .add_systems(Startup, play_background_audio)
        .run();
}

fn play_background_audio(asset_server: Res<AssetServer>, mut commands: Commands) {
    commands.spawn((
        AudioPlayer::new(asset_server.load("background_audio.ogg")),
        PlaybackSettings::LOOP,
    ));
}

Modules§

prelude
The audio prelude.

Structs§

AudioLoader
Loads files as AudioSource Assets
AudioPlayer
A component for playing a sound.
AudioPlayerTemplate
AudioPlugin
Adds support for audio playback to a Bevy Application
AudioSink
Used to control audio during playback.
AudioSource
A source of audio data
DefaultSpatialScale
The default scale factor applied to the positions of audio sources and listeners for spatial audio. Can be overridden for individual sounds in PlaybackSettings.
GlobalVolume
Use this Resource to control the global volume of all audio.
Pitch
A source of sine wave sound
PlaybackSettings
Initial settings to be used when audio starts playing.
SpatialAudioSink
Used to control spatial audio during playback.
SpatialListener
Settings for the listener for spatial audio sources.
SpatialScale
A scale factor applied to the positions of audio sources and listeners for spatial audio.

Enums§

PlaybackMode
The way Bevy manages the sound playback.
SeekError
Occurs when try_seek fails because the underlying decoder has an error or does not support seeking.
Volume
A Volume represents an audio source’s volume level.

Traits§

AddAudioSource
A trait that allows adding a custom audio source to the object. This is implemented for App to allow registering custom Decodable types.
AudioSinkPlayback
Common interactions with an audio sink.
CpalSample
A trait for working generically across different Sample format types.
Decodable
A type implementing this trait can be converted to a rodio::Source type.
Source
A source of samples.

Type Aliases§

ChannelCount
Number of channels in a stream. Can never be Zero
Sample
Represents value of a single sample. Silence corresponds to the value 0.0. The expected amplitude range is -1.0…1.0. Values below and above this range are clipped in conversion to other sample types. Use conversion traits from dasp_sample crate or crate::conversions::SampleTypeConverter to convert between sample types if necessary.
SampleRate
Sample rate (a frame rate or samples per second per channel).