mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 12:44:11 -10:00
47 lines
1.5 KiB
Rust
47 lines
1.5 KiB
Rust
//! This example demonstrates how to process input from a microphone or
|
|
//! other input device. This example grabs the system default, panicking
|
|
//! if no device is available.
|
|
//!
|
|
//! Note that this may result in positive feedback on some setups.
|
|
//! I recommend starting with low volume!
|
|
|
|
use bevy::{log::LogPlugin, prelude::*};
|
|
use bevy_seedling::{context::AudioContextConfig, prelude::*};
|
|
use firewheel::cpal::{CpalConfig, CpalInputConfig};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins((
|
|
MinimalPlugins,
|
|
LogPlugin::default(),
|
|
AssetPlugin::default(),
|
|
SeedlingPlugins,
|
|
))
|
|
.insert_resource(AudioContextConfig(FirewheelConfig {
|
|
// Ensure the graph has an input
|
|
num_graph_inputs: ChannelCount::MONO,
|
|
..Default::default()
|
|
}))
|
|
.insert_resource(AudioStreamConfig(CpalConfig {
|
|
// Ensure we provide an input config
|
|
input: Some(CpalInputConfig::default()),
|
|
..Default::default()
|
|
}))
|
|
.add_systems(Startup, route_input)
|
|
.run();
|
|
}
|
|
|
|
/// Here we route the input node, `AudioGraphInput`, to the `MainBus`.
|
|
fn route_input(input: Single<Entity, With<AudioGraphInput>>, mut commands: Commands) {
|
|
commands
|
|
.entity(*input)
|
|
// route the input through a ton of reverb
|
|
.chain_node(FreeverbNode {
|
|
room_size: 0.9,
|
|
damping: 0.8,
|
|
width: 0.8,
|
|
..Default::default()
|
|
})
|
|
.connect(MainBus);
|
|
}
|