add audio
This commit is contained in:
@@ -4,6 +4,7 @@ mod tile;
|
||||
mod tile_layer;
|
||||
mod tile_bank;
|
||||
mod sprite;
|
||||
mod sample;
|
||||
|
||||
pub use button::Button;
|
||||
pub use color::Color;
|
||||
@@ -11,3 +12,4 @@ pub use tile::Tile;
|
||||
pub use tile_bank::{TileBank, TileSize};
|
||||
pub use tile_layer::{HudTileLayer, ScrollableTileLayer, TileMap};
|
||||
pub use sprite::Sprite;
|
||||
pub use sample::Sample;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user