pub mod math_source;
pub mod mixer;
pub mod synth;
pub mod output;
pub mod music_engine;
pub mod graph;
pub mod effects;
pub mod synthesis;
pub mod spatial;
use glam::Vec3;
#[derive(Clone, Debug)]
pub enum AudioEvent {
SpawnSource { source: math_source::MathAudioSource, position: Vec3 },
StopTag(String),
SetMasterVolume(f32),
SetMusicVolume(f32),
PlaySfx { name: String, position: Vec3, volume: f32 },
SetMusicVibe(MusicVibe),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MusicVibe {
Title,
Exploration,
Combat,
BossFight,
Death,
Victory,
Silence,
}
pub struct AudioEngine {
sender: std::sync::mpsc::SyncSender<AudioEvent>,
_output: output::AudioOutput,
}
impl AudioEngine {
pub fn try_new() -> Option<Self> {
let (tx, rx) = std::sync::mpsc::sync_channel(512);
let output = output::AudioOutput::try_new(rx)?;
Some(Self { sender: tx, _output: output })
}
pub fn emit(&self, event: AudioEvent) {
let _ = self.sender.try_send(event);
}
}