diff --git a/examples/webaudio/index.html b/examples/webaudio/index.html index 23a1ed93..4ae95001 100644 --- a/examples/webaudio/index.html +++ b/examples/webaudio/index.html @@ -3,7 +3,7 @@ - + (headphone users, please make sure your volume is not too loud!)
diff --git a/examples/webaudio/index.js b/examples/webaudio/index.js index 98be8c0c..3801959e 100644 --- a/examples/webaudio/index.js +++ b/examples/webaudio/index.js @@ -9,6 +9,9 @@ import('./webaudio').then(rust_module => { fm.set_fm_frequency(0); fm.set_fm_amount(0); fm.set_gain(0.8); + } else { + fm.free(); + fm = null; } }); diff --git a/examples/webaudio/src/lib.rs b/examples/webaudio/src/lib.rs index 73d17c6a..9cbc3836 100644 --- a/examples/webaudio/src/lib.rs +++ b/examples/webaudio/src/lib.rs @@ -36,6 +36,12 @@ pub struct FmOsc { fm_gain_ratio: f32, } +impl Drop for FmOsc { + fn drop(&mut self) { + let _ = self.ctx.close(); + } +} + #[wasm_bindgen] impl FmOsc { #[wasm_bindgen(constructor)]