add sound bank

This commit is contained in:
Nilton Constantino
2026-01-22 12:21:37 +00:00
parent b09922e0ea
commit 9704274707
13 changed files with 359 additions and 140 deletions
+5 -1
View File
@@ -1,5 +1,5 @@
use prometeu_core::hardware::{AudioCommand, Channel, LoopMode, MAX_CHANNELS, OUTPUT_SAMPLE_RATE};
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use prometeu_core::hardware::{AudioCommand, Channel, LoopMode, MAX_CHANNELS, OUTPUT_SAMPLE_RATE};
use ringbuf::traits::{Consumer, Producer, Split};
use ringbuf::HeapRb;
use std::sync::Arc;
@@ -110,6 +110,7 @@ impl AudioMixer {
if voice_id < MAX_CHANNELS {
self.voices[voice_id] = Channel {
sample: Some(sample),
active: true,
pos: 0.0,
pitch,
volume,
@@ -121,6 +122,7 @@ impl AudioMixer {
}
AudioCommand::Stop { voice_id } => {
if voice_id < MAX_CHANNELS {
self.voices[voice_id].active = false;
self.voices[voice_id].sample = None;
}
}
@@ -168,6 +170,7 @@ impl AudioMixer {
let pos_fract = voice.pos - pos_int as f64;
if pos_int >= sample_data.data.len() {
voice.active = false;
voice.sample = None;
break;
}
@@ -197,6 +200,7 @@ impl AudioMixer {
let loop_start = sample_data.loop_start.unwrap_or(0) as f64;
voice.pos = loop_start + (voice.pos - end_pos);
} else {
voice.active = false;
voice.sample = None;
break;
}