euphony_dsp/
sample.rs

1pub use dasp_sample::*;
2use euphony_units::ratio::Ratio;
3
4pub type DefaultSample = f64;
5pub type DefaultRate = Rate48000;
6
7pub trait Rate: 'static + Send + Sync {
8    const PERIOD: f64;
9    const VALUE: f64;
10    const COUNT: u64;
11    const NANOS_PER_SAMPLE: Ratio<u64>;
12}
13
14pub struct Rate44100;
15
16impl Rate for Rate44100 {
17    const PERIOD: f64 = 1.0f64 / 44100.0;
18    const VALUE: f64 = 44100.0;
19    const COUNT: u64 = 44100;
20    const NANOS_PER_SAMPLE: Ratio<u64> = Ratio(10000000, 441);
21}
22
23pub struct Rate48000;
24
25impl Rate for Rate48000 {
26    const PERIOD: f64 = 1.0f64 / 48000.0;
27    const VALUE: f64 = 48000.0;
28    const COUNT: u64 = 48000;
29    const NANOS_PER_SAMPLE: Ratio<u64> = Ratio(62500, 3);
30}