Fix audio example

This commit is contained in:
Alex Crichton
2018-08-30 13:45:05 -07:00
parent e283093997
commit 90fce8c9d4
3 changed files with 8 additions and 5 deletions

View File

@ -8,3 +8,6 @@ cargo +nightly build --target wasm32-unknown-unknown
cargo +nightly run --manifest-path ../../crates/cli/Cargo.toml \ cargo +nightly run --manifest-path ../../crates/cli/Cargo.toml \
--bin wasm-bindgen -- \ --bin wasm-bindgen -- \
../../target/wasm32-unknown-unknown/debug/webaudio.wasm --out-dir . ../../target/wasm32-unknown-unknown/debug/webaudio.wasm --out-dir .
npm install
npm run serve

View File

@ -1,6 +1,6 @@
{ {
"scripts": { "scripts": {
"serve": "webpack-serve ./webpack.config.js" "serve": "webpack-dev-server"
}, },
"devDependencies": { "devDependencies": {
"webpack": "^4.16.5", "webpack": "^4.16.5",

View File

@ -81,16 +81,16 @@ impl FmOsc {
// connect them up: // connect them up:
// The primary oscillator is routed through the gain node, so that it can control the overall output volume // The primary oscillator is routed through the gain node, so that it can control the overall output volume
primary_node.connect_with_destination_and_output_and_input(gain.as_ref()).unwrap(); primary_node.connect_with_audio_node(gain.as_ref()).unwrap();
// Then connect the gain node to the AudioContext destination (aka your speakers) // Then connect the gain node to the AudioContext destination (aka your speakers)
gain_node.connect_with_destination_and_output_and_input(destination_node).unwrap(); gain_node.connect_with_audio_node(destination_node).unwrap();
// the FM oscillator is connected to its own gain node, so it can control the amount of modulation // the FM oscillator is connected to its own gain node, so it can control the amount of modulation
fm_osc_node.connect_with_destination_and_output_and_input(fm_gain.as_ref()).unwrap(); fm_osc_node.connect_with_audio_node(fm_gain.as_ref()).unwrap();
// Connect the FM oscillator to the frequency parameter of the main oscillator, so that the // Connect the FM oscillator to the frequency parameter of the main oscillator, so that the
// FM node can modulate its frequency // FM node can modulate its frequency
fm_gain_node.connect_with_destination_and_output(&primary.frequency()).unwrap(); fm_gain_node.connect_with_audio_param(&primary.frequency()).unwrap();
} }