mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
and back into 1 crate
This commit is contained in:
parent
307dab8686
commit
5e2e0438a4
99 changed files with 934 additions and 938 deletions
|
|
@ -1,41 +0,0 @@
|
|||
#[derive(Debug, Default)]
|
||||
pub enum MixingMode {
|
||||
#[default]
|
||||
Summing,
|
||||
Average,
|
||||
}
|
||||
|
||||
pub fn mix_summing <const N: usize> (
|
||||
buffer: &mut [Vec<f32>], gain: f32, frames: usize, mut next: impl FnMut()->Option<[f32;N]>,
|
||||
) -> bool {
|
||||
let channels = buffer.len();
|
||||
for index in 0..frames {
|
||||
if let Some(frame) = next() {
|
||||
for (channel, sample) in frame.iter().enumerate() {
|
||||
let channel = channel % channels;
|
||||
buffer[channel][index] += sample * gain;
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub fn mix_average <const N: usize> (
|
||||
buffer: &mut [Vec<f32>], gain: f32, frames: usize, mut next: impl FnMut()->Option<[f32;N]>,
|
||||
) -> bool {
|
||||
let channels = buffer.len();
|
||||
for index in 0..frames {
|
||||
if let Some(frame) = next() {
|
||||
for (channel, sample) in frame.iter().enumerate() {
|
||||
let channel = channel % channels;
|
||||
let value = buffer[channel][index];
|
||||
buffer[channel][index] = (value + sample * gain) / 2.0;
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue