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
46
47
48
49
50
51
52
53
#![warn(missing_docs)]
use std::vec::Vec;
pub type MathT = f64;
pub type SampleT = f32;
pub type TrackT = Vec<SampleT>;
pub const SAMPLE_RATE:u64 = 48_000;
pub const INV_SAMPLE_RATE:MathT = 1.0/(SAMPLE_RATE as MathT);
pub fn lerp<T>(x:T, x1:T, x2:T, y1:T, y2:T) -> T
where T: Copy + Sized + std::ops::Add<Output=T> + std::ops::Sub<Output=T> + std::ops::Mul<Output=T> + std::ops::Div<Output=T>
{
((y2 - y1) / (x2 - x1)) * (x - x1) + y1
}
pub fn samples_to_seconds(s: usize) -> std::time::Duration {
std::time::Duration::from_secs_f64(s as f64 * SAMPLE_RATE as f64)
}
pub fn seconds_to_samples(s: std::time::Duration) -> usize {
(s.as_secs_f64() * SAMPLE_RATE as f64).round() as usize
}
#[cfg(test)]
pub trait Name {
fn get_name(&self) -> &str;
}
pub mod core;
pub mod generators;
pub mod modifiers;
pub mod sounds;
pub mod sample_format;
pub mod tools;
pub use sample_format::*;