examples(webaudio): allow turning the noise off again

This commit is contained in:
Nick Fitzgerald 2018-09-26 10:37:12 -07:00
parent a3e160744e
commit 826619870f
3 changed files with 10 additions and 1 deletions

View File

@ -3,7 +3,7 @@
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
</head>
<body>
<input id="play" type="button" value="Click me first to turn on audio"/>
<input id="play" type="button" value=""/>
(headphone users, please make sure your volume is not too loud!)
<div>

View File

@ -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;
}
});

View File

@ -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)]