1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! This example demonstrates how to route audio to a send.
use bevy::{log::LogPlugin, prelude::*};
use bevy_seedling::prelude::*;
fn main() {
App::new()
.add_plugins((
MinimalPlugins,
LogPlugin::default(),
AssetPlugin::default(),
SeedlingPlugin::default(),
))
.add_systems(Startup, create_send)
.run();
}
fn create_send(server: Res<AssetServer>, mut commands: Commands) {
// Effects like reverb are generally CPU hungry, so
// you should prefer routing audio to a single reverb,
// rather than creating many instances for each sample.
let send = commands
.spawn(FreeverbNode {
room_size: 0.9,
width: 0.75,
damping: 0.5,
..Default::default()
})
.id();
// On the other hand, `Send`s are cheap, so we can insert
// them anywhere (like directly on a sampler) to send
// audio to expensive processing chains.
commands.spawn((
SamplePlayer::new(server.load("caw.ogg")),
// Here we send some of the signal to the reverb.
sample_effects![SendNode::new(Volume::Linear(0.70), send)],
));
}