mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-24 06:33:33 +03:00
examples(webaudio): allow turning the noise off again
This commit is contained in:
parent
a3e160744e
commit
826619870f
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user