1pub mod format;
2
3#[cfg(feature = "pulseaudio")]
4pub mod pulse;
5
6#[cfg(feature = "file")]
7pub mod file;
8
9#[cfg(feature = "cpal")]
10pub mod cpal;
11
12pub type Matrix<T> = Vec<Vec<T>>;
13
14pub trait DataSource<T> {
15 fn recv(&mut self) -> Option<Matrix<T>>; }
17
18pub fn stream_to_matrix<I, O>(stream: impl Iterator<Item = I>, channels: usize, norm: O) -> Matrix<O>
24where I : Copy + Into<O>, O : Copy + std::ops::Div<Output = O>
25{
26 let mut out = vec![vec![]; channels];
27 let mut channel = 0;
28 for sample in stream {
29 out[channel].push(sample.into() / norm);
30 channel = (channel + 1) % channels;
31 }
32 out
33}