qwac 0.29.0

Rust client crate for making qwac games
Documentation
use super::{Gain, Input, Output, Slot};
use qwac_sys::audio;

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

impl Default for GainNode {
    fn default() -> Self {
        Self::new(1.0)
    }
}

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

impl Input for GainNode {}
impl Output for GainNode {}

impl GainNode {
    pub fn new(gain: f32) -> Self {
        let id = unsafe { audio::create_gain_node(gain) };
        Self { id }
    }
    pub fn gain(&mut self) -> Gain {
        Gain {
            id: unsafe { audio::gain_param(self.id()) },
        }
    }
}

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