use crate::runtime;
#[derive(Debug, Clone, PartialEq)]
pub struct SoundClip {
pub file: String,
pub at: f64,
pub volume: f32,
pub fade_in: f64,
pub fade_out: f64,
pub trim_start: f64,
pub trim_end: Option<f64>,
pub priority: bool,
pub speech: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub struct VoiceLine {
pub text: String,
pub at: f64,
pub seconds: f64,
}
pub fn record_sound(clip: SoundClip) -> usize {
runtime::with(|rt| {
let mut sounds = rt.sounds.borrow_mut();
sounds.push(clip);
sounds.len() - 1
})
}
pub fn end_sound(index: usize, trim_end: f64) {
runtime::with(|rt| {
if let Some(clip) = rt.sounds.borrow_mut().get_mut(index) {
clip.trim_end = Some(trim_end.max(clip.trim_start));
}
});
}
pub fn record_voice(line: VoiceLine) {
runtime::with(|rt| rt.voices.borrow_mut().push(line));
}