feat(audio): add 32-voice PCM mixing and native music sequencing

Add self-contained SoundBanks and MusicBanks with per-sample PCM16 and IMA ADPCM storage, materialized to resident PCM16. Integrate instrument envelopes, automation, shared DSP and host lifecycle controls while preserving staged real-time execution.
This commit is contained in:
2026-11-20 22:15:24 +00:00
parent a32f834b2b
commit 8510c5b00d
40 changed files with 4708 additions and 509 deletions
+24 -2
View File
@@ -1,13 +1,27 @@
#[derive(Debug)]
pub struct Sample {
pub sample_rate: u32,
pub channels: u8,
pub data: Vec<i16>,
pub loop_start: Option<u32>,
pub loop_end: Option<u32>,
pub default_volume: u8,
pub default_pan: u8,
pub default_pitch: f64,
}
impl Sample {
pub fn new(sample_rate: u32, data: Vec<i16>) -> Self {
Self { sample_rate, data, loop_start: None, loop_end: None }
Self {
sample_rate,
channels: 1,
data,
loop_start: None,
loop_end: None,
default_volume: 255,
default_pan: 128,
default_pitch: 1.0,
}
}
pub fn with_loop(mut self, start: u32, end: u32) -> Self {
@@ -17,6 +31,14 @@ impl Sample {
}
pub fn frames_len(&self) -> usize {
self.data.len()
self.data.len() / self.channels.max(1) as usize
}
pub fn with_channels(mut self, channels: u8) -> Result<Self, String> {
if !(1..=2).contains(&channels) || !self.data.len().is_multiple_of(channels as usize) {
return Err("audio sample channels/frame count".into());
}
self.channels = channels;
Ok(self)
}
}