Remove nll feature from webaudio example

This commit is contained in:
Alex Crichton 2018-08-19 14:42:25 -07:00
parent d4297ad2d3
commit 305ecb7910

View File

@ -1,5 +1,3 @@
#![feature(nll)]
extern crate wasm_bindgen;
extern crate web_sys;
@ -45,13 +43,20 @@ impl FmOsc {
// TODO, how to throw from a constructor?
let ctx = web_sys::AudioContext::new().unwrap();
let base: &BaseAudioContext = ctx.as_ref();
let primary;
let fm_osc;
let gain;
let fm_gain;
// create our web audio objects
let primary = base.create_oscillator().unwrap();
let fm_osc = base.create_oscillator().unwrap();
let gain = base.create_gain().unwrap();
let fm_gain = base.create_gain().unwrap();
{
let base: &BaseAudioContext = ctx.as_ref();
// create our web audio objects
primary = base.create_oscillator().unwrap();
fm_osc = base.create_oscillator().unwrap();
gain = base.create_gain().unwrap();
fm_gain = base.create_gain().unwrap();
}
// some initial settings:
primary.set_type(OscillatorType::Sine);
@ -63,27 +68,30 @@ impl FmOsc {
// Create base class references:
let primary_node: &AudioNode = primary.as_ref();
let gain_node: &AudioNode = gain.as_ref();
let fm_osc_node: &AudioNode = fm_osc.as_ref();
let fm_gain_node: &AudioNode = fm_gain.as_ref();
let destination = base.destination();
let destination_node: &AudioNode = destination.as_ref();
{
let primary_node: &AudioNode = primary.as_ref();
let gain_node: &AudioNode = gain.as_ref();
let fm_osc_node: &AudioNode = fm_osc.as_ref();
let fm_gain_node: &AudioNode = fm_gain.as_ref();
let base: &BaseAudioContext = ctx.as_ref();
let destination = base.destination();
let destination_node: &AudioNode = destination.as_ref();
// connect them up:
// connect them up:
// 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_using_destination(gain.as_ref());
// Then connect the gain node to the AudioContext destination (aka your speakers)
gain_node.connect_with_destination_and_output_and_input_using_destination(destination_node);
// 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_using_destination(gain.as_ref());
// Then connect the gain node to the AudioContext destination (aka your speakers)
gain_node.connect_with_destination_and_output_and_input_using_destination(destination_node);
// 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_using_destination(fm_gain.as_ref());
// 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_using_destination(fm_gain.as_ref());
// Connect the FM oscillator to the frequency parameter of the main oscillator, so that the
// FM node can modulate its frequency
fm_gain_node.connect_with_destination_and_output_using_destination(&primary.frequency());
// Connect the FM oscillator to the frequency parameter of the main oscillator, so that the
// FM node can modulate its frequency
fm_gain_node.connect_with_destination_and_output_using_destination(&primary.frequency());
}
// start the oscillators!