66 lines
1.9 KiB
Rust
66 lines
1.9 KiB
Rust
use crate::sample::Sample;
|
|
use std::sync::Arc;
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum LoopMode {
|
|
Off,
|
|
On,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
#[repr(i32)]
|
|
pub enum AudioOpStatus {
|
|
Ok = 0,
|
|
VoiceInvalid = 1,
|
|
SampleNotFound = 2,
|
|
ArgRangeInvalid = 3,
|
|
AssetNotFound = 4,
|
|
NoEffect = 5,
|
|
BankInvalid = 6,
|
|
CommandLimit = 7,
|
|
}
|
|
|
|
pub trait AudioBridge {
|
|
#[allow(clippy::too_many_arguments)]
|
|
fn play(
|
|
&mut self,
|
|
bank_id: u8,
|
|
sample_id: u16,
|
|
voice_id: usize,
|
|
volume: u8,
|
|
pan: u8,
|
|
pitch: f64,
|
|
priority: u8,
|
|
loop_mode: LoopMode,
|
|
) -> AudioOpStatus;
|
|
#[allow(clippy::too_many_arguments)]
|
|
fn play_sample(
|
|
&mut self,
|
|
sample: Arc<Sample>,
|
|
voice_id: usize,
|
|
volume: u8,
|
|
pan: u8,
|
|
pitch: f64,
|
|
priority: u8,
|
|
loop_mode: LoopMode,
|
|
) -> AudioOpStatus;
|
|
fn stop(&mut self, voice_id: usize) -> AudioOpStatus;
|
|
fn set_volume(&mut self, voice_id: usize, volume: u8) -> AudioOpStatus;
|
|
fn set_pan(&mut self, voice_id: usize, pan: u8) -> AudioOpStatus;
|
|
fn set_pitch(&mut self, voice_id: usize, pitch: f64) -> AudioOpStatus;
|
|
/// Pending publication must be consumed before starting another guest frame.
|
|
fn ready(&self) -> bool;
|
|
fn begin_frame(&mut self);
|
|
fn finish_frame(&mut self);
|
|
fn abort_frame(&mut self);
|
|
/// Lifecycle has independent bounded staging/publication, even with a pending frame.
|
|
fn lifecycle_ready(&self) -> bool;
|
|
fn begin_lifecycle(&mut self);
|
|
/// Success publishes the interrupted frame prefix before callback commands,
|
|
/// without replenishing frame quota. Failure cancels both unpublished parts.
|
|
fn finish_lifecycle(&mut self, success: bool);
|
|
fn set_session(&mut self, session: Option<u32>);
|
|
fn reset(&mut self);
|
|
fn set_paused(&mut self, paused: bool);
|
|
}
|