This implements a proof-of-concept for an improved audio frontend. The largest change is the introduction of events and event handling: both by time elapsed and by track events, such as ending or looping. Following on from this, the library now includes a basic, event-driven track queue system (which people seem to ask for unusually often). A new sample, `examples/13_voice_events`, demonstrates both the `TrackQueue` system and some basic events via the `~queue` and `~play_fade` commands. Locks are removed from around the control of `Audio` objects, which should allow the backend to be moved to a more granular futures-based backend solution in a cleaner way.
31 lines
965 B
Rust
31 lines
965 B
Rust
use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion};
|
|
use songbird::{constants::*, input::Input};
|
|
|
|
pub fn mix_one_frame(c: &mut Criterion) {
|
|
let floats = utils::make_sine(STEREO_FRAME_SIZE, true);
|
|
let mut raw_buf = [0f32; STEREO_FRAME_SIZE];
|
|
|
|
c.bench_function("Mix stereo source", |b| {
|
|
b.iter_batched_ref(
|
|
|| black_box(Input::float_pcm(true, floats.clone().into())),
|
|
|input| {
|
|
input.mix(black_box(&mut raw_buf), black_box(1.0));
|
|
},
|
|
BatchSize::SmallInput,
|
|
)
|
|
});
|
|
|
|
c.bench_function("Mix mono source", |b| {
|
|
b.iter_batched_ref(
|
|
|| black_box(Input::float_pcm(false, floats.clone().into())),
|
|
|input| {
|
|
input.mix(black_box(&mut raw_buf), black_box(1.0));
|
|
},
|
|
BatchSize::SmallInput,
|
|
)
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, mix_one_frame);
|
|
criterion_main!(benches);
|