1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use super::*;
use crate::utils::mono_resampler::*;
#[derive(Clone)]
pub struct MonoWav {
resam: MonoResampler,
}
impl MonoWav {
pub fn from_source(s: &mut dyn std::io::Read) -> Self {
let (h, t) = utils::read_wav(s)
.expect("File could not be read");
MonoWav::from_track(h.sampling_rate as MathT, t.first().expect("No audio data read").clone())
}
pub fn from_track(sampling_rate: MathT, t: TrackT) -> Self {
MonoWav{
resam: MonoResampler::new(t, sampling_rate, 0, 0)
}
}
pub fn get(&self) -> &MonoResampler {
&self.resam
}
pub fn get_mut(&mut self) -> &mut MonoResampler {
&mut self.resam
}
}
impl Generator for MonoWav {
fn process(&mut self) -> SampleT {
self.resam.process()
}
}