23 lines
515 B
Rust
23 lines
515 B
Rust
pub struct Sample {
|
|
pub sample_rate: u32,
|
|
pub data: Vec<i16>,
|
|
pub loop_start: Option<u32>,
|
|
pub loop_end: Option<u32>,
|
|
}
|
|
|
|
impl Sample {
|
|
pub fn new(sample_rate: u32, data: Vec<i16>) -> Self {
|
|
Self { sample_rate, data, loop_start: None, loop_end: None }
|
|
}
|
|
|
|
pub fn with_loop(mut self, start: u32, end: u32) -> Self {
|
|
self.loop_start = Some(start);
|
|
self.loop_end = Some(end);
|
|
self
|
|
}
|
|
|
|
pub fn frames_len(&self) -> usize {
|
|
self.data.len()
|
|
}
|
|
}
|