{"id":19568250,"url":"https://github.com/turtiesocks/bevy_audio_controller","last_synced_at":"2025-04-27T02:32:59.722Z","repository":{"id":260850154,"uuid":"881566341","full_name":"TurtIeSocks/bevy_audio_controller","owner":"TurtIeSocks","description":"Bevy plugin that simplifies channel management and track playback","archived":false,"fork":false,"pushed_at":"2024-12-01T01:52:03.000Z","size":14482,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T23:53:46.943Z","etag":null,"topics":["audio","bevy","bevy-engine","bevy-plugin","game-development"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TurtIeSocks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"TurtIeSocks"}},"created_at":"2024-10-31T20:32:15.000Z","updated_at":"2025-04-15T14:52:24.000Z","dependencies_parsed_at":"2024-12-01T23:16:09.621Z","dependency_job_id":null,"html_url":"https://github.com/TurtIeSocks/bevy_audio_controller","commit_stats":null,"previous_names":["turtiesocks/bevy_audio_controller"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurtIeSocks%2Fbevy_audio_controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurtIeSocks%2Fbevy_audio_controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurtIeSocks%2Fbevy_audio_controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TurtIeSocks%2Fbevy_audio_controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TurtIeSocks","download_url":"https://codeload.github.com/TurtIeSocks/bevy_audio_controller/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251080744,"owners_count":21533142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","bevy","bevy-engine","bevy-plugin","game-development"],"created_at":"2024-11-11T06:03:03.837Z","updated_at":"2025-04-27T02:32:54.712Z","avatar_url":"https://github.com/TurtIeSocks.png","language":"Rust","funding_links":["https://github.com/sponsors/TurtIeSocks"],"categories":[],"sub_categories":[],"readme":"# Bevy Audio Controller\n\n\u003c!--\n[![license](https://img.shields.io/crates/l/bevy_audio_controller)](https://github.com/TurtIeSocks/bevy_audio_controller#license) --\u003e\n\n[![crates.io](https://img.shields.io/crates/v/bevy_audio_controller)](https://crates.io/crates/bevy_audio_controller)\n[![license](https://img.shields.io/crates/l/bevy_audio_controller)](https://github.com/TurtIeSocks/bevy_audio_controller#license)\n\nAn extremely convenient plugin that provides a solid audio controller for Bevy with very minimal boilerplate!\n\n## Features\n\n### Event Orientated\n\n- Playing a sound is usually the result of a trigger, spawning audio via an event feels natural!\n- Avoids unnecessary spawns/inserts of audio components, increasing performance\n- Still includes support for ECS design patterns\n\n### Automatic Audio File Detection at Build Time\n\n- The build script traverses through your Bevy assets folder and builds convenient structs, enums, component markers, and traits based on the audio files that are compatible with the specified Cargo features\n- Removes the need to ever use the `AssetServer` directly and provides a convenient enum so you can avoid \"magic strings\" in your code\n\n### Channels\n\n- Provides `register_audio_channel` trait to allow you to easily add multiple audio channels to your app\n- Each channel gets its own settings, events, and can be controlled independently with convenient APIs\n- `AudioChannel` derive macro adds convenient methods to the channel marker struct\n\n### Tracks\n\n- Defaults for individual tracks can be set per channel\n- Settings can still be overridden on a per event basis\n\n## Usage\n\n```rust\nuse bevy::{prelude::*, audio::PlaybackSettings};\nuse bevy_audio_controller::prelude::*;\n\n#[derive(Component, Default, AudioChannel)]\nstruct SfxChannel;\n\ntype SfxEvent = PlayEvent\u003cSfxChannel\u003e;\n\nfn main() {\n    App::new()\n        .add_plugins(DefaultPlugins)\n        .add_plugins(AudioControllerPlugin)\n        .register_audio_channel::\u003cSfxChannel\u003e()\n        .add_systems(Update, play_fire)\n        .run();\n}\n\nfn play_fire(mut ew: EventWriter\u003cSfxEvent\u003e) {\n    // even though this is called on every frame, it will only be played once the previous clip has finished\n    ew.send(SfxEvent::new(AudioFiles::FireOGG).with_settings(PlaybackSettings::DESPAWN));\n}\n```\n\n## Cargo Features\n\n### `default`\n\nNone\n\n### `inspect`\n\nAdds additional reflection traits to the structs used by this plugin to make them available in `bevy-egui-inspector`\n\n**Requires that channel components must also derive `Reflect`**\n\n```rust\n// If you are using the `inspect` feature conditionally, you can use the following pattern\n#[derive(Component, Default, AudioChannel)]\n#[cfg_attr(feature = \"inspect\", derive(Reflect))]\n#[cfg_attr(feature = \"inspect\", reflect(Component))]\nstruct SfxChannel;\n\n// Otherwise, this is fine\n#[derive(Component, Default, AudioChannel, Reflect)]\n#[reflect(Component)]\nstruct MusicChannel;\n```\n\n### `mp3`\n\nEnables support for MP3 audio files.\n\n### `ogg`\n\nEnables support for OGG audio files\n\n### `flac`\n\nEnables support for FLAC audio files\n\n### `wav`\n\nEnables support for WAV audio files\n\n### `all-codecs`\n\nEnables support for all audio codecs\n\n## Examples\n\nAll examples require `--features=\"ogg\"` flag to work. If you would like to view more details with bevy-egui-inspector, run with `--all-features` instead.\n\n### Basic\n\nDemonstrates:\n\n- Utilizing the global audio channel\n- Playing an audio clip using the plugin\n\nInputs:\n\n- Space Bar: Toggles between using the plugin and the standard Bevy audio spawn\n\n```sh\n  cargo run --example basic --features=\"ogg\"\n```\n\n### Channels\n\nDemonstrates:\n\n- Spawning multiple audio channels\n- Playing an audio clip using the plugin\n\n```sh\n  cargo run --example channels --features=\"ogg\"\n```\n\n### Event Options\n\nDemonstrates:\n\n- Set the volume for a channel\n- Set the default PlaybackSettings for a channel\n- Set individual PlaybackSettings for a track\n- Insert a track into an entity\n- Add a track as a child to another entity\n- Override cache with an immediate play event\n\nInputs:\n\n- Space Bar: Sends an event to ignore the cache and immediate play a track\n\n```sh\n  cargo run --example event_options --features=\"ogg\"\n```\n\n### ECS\n\nDemonstrates:\n\n- How to use this plugin with a more traditional ECS design pattern\n\nInputs:\n\n- Space Bar: Toggles how _not_ to use `DelayMode::Immediate`\n\n```sh\n  cargo run --example ecs --features=\"ogg\"\n```\n\n### Delays\n\nDemonstrates:\n\n- Demonstrates how to use the `Percent` \u0026 `Milliseconds` variations of the `DelayMode` enum for finer control over when a track is played\n\n```sh\n  cargo run --example delays --features=\"ogg\"\n```\n\n### Volume\n\nDemonstrates:\n\n- Includes a full UI for controlling the volumes of individual channels\n\nInputs:\n\n- Clicking buttons to adjust volumes\n\n```sh\n  cargo run --example volume --features=\"ogg\"\n```\n\n### Querying\n\nDemonstrates:\n\n- Query for audio components after they've been inserted if you want to use or modify their components in some way\n- Use the unique markers that are generated by the build script at compile time for each audio file\n\n```sh\n  cargo run --example querying --features=\"ogg\"\n```\n\n## Bevy support table\n\n| bevy | bevy_audio_controller |\n| ---- | --------------------- |\n| 0.14 | 0.2                   |\n\n## Credits\n\n- [bevy_embedded_assets](https://github.com/vleue/bevy_embedded_assets/tree/main) for inspiration with the [build.rs](./build.rs) script\n- [Assets used in the examples](https://yourpalrob.itch.io/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturtiesocks%2Fbevy_audio_controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturtiesocks%2Fbevy_audio_controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturtiesocks%2Fbevy_audio_controller/lists"}