-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a14272
commit 41b1879
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<head> | ||
<script language="javascript" type="text/javascript" src="../../lib/p5.js"></script> | ||
|
||
<script language="javascript" type="text/javascript" src="../../lib/addons/p5.dom.js"></script> | ||
|
||
<script language="javascript" type="text/javascript" src="../../lib/p5.sound.js"></script> | ||
|
||
<script language="javascript" type="text/javascript" src="sketch.js"></script> | ||
|
||
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |