Skip to content

Commit

Permalink
update env.js and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
therewasaguy committed Feb 1, 2016
1 parent 3f9e82d commit d877991
Show file tree
Hide file tree
Showing 5 changed files with 295 additions and 72 deletions.
9 changes: 5 additions & 4 deletions examples/DelayNoiseEnvelope/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ function setup() {
delay = new p5.Delay();
delay.process(noise, .12, .7, 2300); // tell delay to process noise

// the Env accepts time / value pairs to
// create a series of timed fades
env = new p5.Env(.01, 1, .2, .1);
// the Env ADSR: attackTime, decayTime, sustainLevel, releaseTime
env = new p5.Env();
env.setADSR(0.01, 0.2, 0.2, 0.1)
env.setRange(1, 0);

// p5.Amplitude will analyze all sound in the sketch
analyzer = new p5.Amplitude();
Expand Down Expand Up @@ -52,5 +53,5 @@ function draw() {
}

function mousePressed() {
env.play(noise);
env.play(noise, 0, 0.1, 0);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!doctype html>
<head>
<script language="javascript" type="text/javascript" src="../../lib/p5.js"></script>

Expand All @@ -8,3 +9,8 @@
<script language="javascript" type="text/javascript" src="sketch.js"></script>

</head>

<body>
click to trigger amplitude and frequency envelopes

</body>
35 changes: 35 additions & 0 deletions examples/envAmpFreq/sketch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Control the level of an envelope
*/

var env; // this is the env
var osc; // this oscillator will modulate the amplitude of the carrier
var freqEnv; // env for frequency

function setup() {
env = new p5.Env();
env.setADSR(0.01, 0.2, 0.2, 0.3);
env.setRange(0, 1);

freqEnv = new p5.Env();
freqEnv.setADSR(0.01, 0.2, 0.2, 0.3);
freqEnv.setRange(300, 5000);


osc = new p5.Oscillator(); // connects to master output by default
osc.start(0);
osc.freq(220);
// osc.freq(env.scale(0,1,800,300));
osc.freq(freqEnv);
osc.amp(env);
}

function mousePressed() {
env.triggerAttack();
freqEnv.triggerAttack();
}

function mouseReleased() {
env.triggerRelease();
freqEnv.triggerRelease();
}
24 changes: 0 additions & 24 deletions examples/envSignalMath/sketch.js

This file was deleted.

Loading

0 comments on commit d877991

Please sign in to comment.