Browse and listen to thousands of radio stations across the globe right from your terminal ๐ŸŒŽ ๐Ÿ“ป ๐ŸŽตโœจ
radio rust tokio web-radio command-line-tool tui
at main 577 B view raw
1pub type Matrix<T> = Vec<Vec<T>>; 2 3/// separate a stream of alternating channels into a matrix of channel streams: 4/// L R L R L R L R L R 5/// becomes 6/// L L L L L 7/// R R R R R 8pub fn stream_to_matrix<I, O>( 9 stream: impl Iterator<Item = I>, 10 channels: usize, 11 norm: O, 12) -> Matrix<O> 13where 14 I: Copy + Into<O>, 15 O: Copy + std::ops::Div<Output = O>, 16{ 17 let mut out = vec![vec![]; channels]; 18 let mut channel = 0; 19 for sample in stream { 20 out[channel].push(sample.into() / norm); 21 channel = (channel + 1) % channels; 22 } 23 out 24}