qwac 0.29.0

Rust client crate for making qwac games
Documentation
use super::{detune::Detune, Frequency, Input, Slot, Source};
use qwac_sys::audio;
pub use qwac_sys::audio::OscillatorType;

#[derive(Debug)]
pub struct OscillatorNode {
    id: i32,
}

impl Slot for OscillatorNode {
    fn id(&self) -> i32 {
        self.id
    }
}

impl Input for OscillatorNode {}
impl Source for OscillatorNode {}

impl OscillatorNode {
    pub fn new(oscillator_type: OscillatorType) -> Self {
        Self {
            id: unsafe { audio::create_oscillator_node(oscillator_type) },
        }
    }
    pub fn detune(&mut self) -> Detune {
        Detune {
            id: unsafe { audio::detune_param(self.id()) },
        }
    }
    pub fn frequency(&mut self) -> Frequency {
        Frequency {
            id: unsafe { audio::frequency_param(self.id()) },
        }
    }
}

impl Drop for OscillatorNode {
    fn drop(&mut self) {
        unsafe {
            audio::drop(self.id());
        }
    }
}