add audio

This commit is contained in:
Nilton Constantino
2026-01-14 17:55:06 +00:00
parent b0f4a865ad
commit acd09a6468
11 changed files with 861 additions and 49 deletions
+2
View File
@@ -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;
+27
View File
@@ -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()
}
}