use crate::{dx::*, ext::tdx::*};
pub struct Sound {
pub d: bool,
pub h: i32
}
impl Tr for Sound {
fn as_sound(&self) -> Sound { Sound{d: false, h: self.h} }
fn handle(&self) -> i32 { self.h }
fn dispose(&mut self) {
if self.d && self.h != 0 {
unsafe { DeleteSoundMem(self.h, FALSE); }
self.h = 0;
}
}
}
impl Drop for Sound {
fn drop(&mut self) { self.dispose(); }
}
impl Sound {
pub fn load_mem(n: &String) -> Self {
Sound{d: true, h: unsafe { LoadSoundMem(n.as_ptr()) } }
}
pub fn volume(&self, v: i32) { unsafe { ChangeVolumeSoundMem(v, self.h); } }
pub fn stop(&self) { unsafe { StopSoundMem(self.h); } }
pub fn play(&self, t: i32, f: i32) { unsafe { PlaySoundMem(self.h, t, f); } }
}