From 41b1879ee3f249a98c1a90296a0a02a4fdd63b64 Mon Sep 17 00:00:00 2001 From: Jason Sigal Date: Fri, 22 Aug 2014 20:14:36 -0400 Subject: [PATCH] adding oscillator_fmSynth example --- examples/oscillator_FMSynth/index.html | 10 +++++++ examples/oscillator_FMSynth/sketch.js | 41 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 examples/oscillator_FMSynth/index.html create mode 100644 examples/oscillator_FMSynth/sketch.js diff --git a/examples/oscillator_FMSynth/index.html b/examples/oscillator_FMSynth/index.html new file mode 100644 index 00000000..6ec1957c --- /dev/null +++ b/examples/oscillator_FMSynth/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/examples/oscillator_FMSynth/sketch.js b/examples/oscillator_FMSynth/sketch.js new file mode 100644 index 00000000..65a56f89 --- /dev/null +++ b/examples/oscillator_FMSynth/sketch.js @@ -0,0 +1,41 @@ +var carrier, modulator; + +// carrier frequency signal, a p5.Signal +var carrierFreq; + +// modulator frequency signal, a p5.Signal +var modFreq; + + +// output envelope +var env; + +function setup() { + carrier = new p5.Oscillator(); + + carrierFreq = new p5.Signal(240); + carrier.freq(carrierFreq); + carrier.start(); + + env = new p5.Env(0.05, 1, 0.5, 0); + carrier.amp(env); + + modulator = new p5.Oscillator(); + modulator.disconnect(); + modFreq = new p5.SignalMult(8); + modFreq.setInput(carrierFreq); + modulator.freq(modFreq); + modulator.start(); + + var m1 = new p5.SignalMult(); + m1.setInput(modulator); + m1.setValue(100); +} + +function draw() { + carrierFreq.fade(mouseX); +} + +function mousePressed() { + env.play(); +} \ No newline at end of file