Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

21
vendor/rodio/benches/conversions.rs vendored Normal file
View File

@@ -0,0 +1,21 @@
use cpal::FromSample;
use divan::Bencher;
use rodio::Source;
mod shared;
use shared::TestSource;
fn main() {
divan::main();
}
#[divan::bench(types = [i16, u16, f32])]
fn from_i16_to<T: rodio::Sample + FromSample<i16>>(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav())
.bench_values(|source| {
source
.convert_samples::<T>()
.for_each(divan::black_box_drop)
})
}

87
vendor/rodio/benches/effects.rs vendored Normal file
View File

@@ -0,0 +1,87 @@
use std::time::Duration;
use divan::Bencher;
use rodio::Source;
mod shared;
use shared::TestSource;
fn main() {
divan::main();
}
#[divan::bench]
fn reverb(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav())
.bench_values(|source| {
source
.buffered()
.reverb(Duration::from_secs_f32(0.05), 0.3)
.for_each(divan::black_box_drop)
})
}
#[divan::bench]
fn high_pass(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav().to_f32s())
.bench_values(|source| source.high_pass(200).for_each(divan::black_box_drop))
}
#[divan::bench]
fn fade_out(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav())
.bench_values(|source| {
source
.fade_out(Duration::from_secs(5))
.for_each(divan::black_box_drop)
})
}
#[divan::bench]
fn amplify(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav().to_f32s())
.bench_values(|source| source.amplify(0.8).for_each(divan::black_box_drop))
}
#[divan::bench]
fn agc_enabled(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav().to_f32s())
.bench_values(|source| {
source
.automatic_gain_control(
1.0, // target_level
4.0, // attack_time (in seconds)
0.005, // release_time (in seconds)
5.0, // absolute_max_gain
)
.for_each(divan::black_box_drop)
})
}
#[cfg(feature = "experimental")]
#[divan::bench]
fn agc_disabled(bencher: Bencher) {
bencher
.with_inputs(|| TestSource::music_wav().to_f32s())
.bench_values(|source| {
// Create the AGC source
let amplified_source = source.automatic_gain_control(
1.0, // target_level
4.0, // attack_time (in seconds)
0.005, // release_time (in seconds)
5.0, // absolute_max_gain
);
// Get the control handle and disable AGC
let agc_control = amplified_source.get_agc_control();
agc_control.store(false, std::sync::atomic::Ordering::Relaxed);
// Process the audio stream with AGC disabled
amplified_source.for_each(divan::black_box_drop)
})
}

83
vendor/rodio/benches/shared.rs vendored Normal file
View File

@@ -0,0 +1,83 @@
use std::io::Cursor;
use std::time::Duration;
use std::vec;
use rodio::Source;
pub struct TestSource<T> {
samples: vec::IntoIter<T>,
channels: u16,
sample_rate: u32,
total_duration: Duration,
}
impl<T> Iterator for TestSource<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.samples.next()
}
}
impl<T> ExactSizeIterator for TestSource<T> {
fn len(&self) -> usize {
self.samples.len()
}
}
impl<T: rodio::Sample> Source for TestSource<T> {
fn current_frame_len(&self) -> Option<usize> {
None // forever
}
fn channels(&self) -> u16 {
self.channels
}
fn sample_rate(&self) -> u32 {
self.sample_rate
}
fn total_duration(&self) -> Option<Duration> {
Some(self.total_duration)
}
}
impl TestSource<i16> {
pub fn music_wav() -> Self {
let data = include_bytes!("../assets/music.wav");
let cursor = Cursor::new(data);
let duration = Duration::from_secs(10);
let sound = rodio::Decoder::new(cursor)
.expect("music.wav is correctly encoded & wav is supported")
.take_duration(duration);
TestSource {
channels: sound.channels(),
sample_rate: sound.sample_rate(),
total_duration: duration,
samples: sound.into_iter().collect::<Vec<_>>().into_iter(),
}
}
#[allow(unused, reason = "not everything from shared is used in all libs")]
pub fn to_f32s(self) -> TestSource<f32> {
let TestSource {
samples,
channels,
sample_rate,
total_duration,
} = self;
let samples = samples
.map(|s| cpal::Sample::from_sample(s))
.collect::<Vec<_>>()
.into_iter();
TestSource {
samples,
channels,
sample_rate,
total_duration,
}
}
}