Skip to content

Commit 09f822d

Browse files
authoredJun 11, 2018
Merge pull request #288 from JunShern/rename-envelope
Rename envelope
2 parents 0662bc1 + a010124 commit 09f822d

File tree

25 files changed

+84
-76
lines changed

25 files changed

+84
-76
lines changed
 

Diff for: ‎Gruntfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module.exports = function(grunt) {
7676
'pulse': 'src/pulse',
7777
'noise': 'src/noise',
7878
'audioin': 'src/audioin',
79-
'env': 'src/env',
79+
'envelope': 'src/envelope',
8080
'delay': 'src/delay',
8181
'effect': 'src/effect',
8282
'panner3d' : 'src/panner3d',

Diff for: ‎examples/DelayNoiseEnvelope/sketch.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Example: p5.Delay w/ p5.Noise, p5.Env & p5.Amplitude
2+
* Example: p5.Delay w/ p5.Noise, p5.Envelope & p5.Amplitude
33
*
44
* Click the mouse to hear the p5.Delay process a Noise Envelope.
55
*
@@ -13,7 +13,7 @@ function setup() {
1313
createCanvas(710, 400);
1414
noise = new p5.Noise('white'); // other types include 'brown' and 'pink'
1515

16-
// Turn down because we'll control .amp with a p5.Env
16+
// Turn down because we'll control .amp with a p5.Envelope
1717
noise.amp(0);
1818

1919
noise.start();
@@ -22,8 +22,8 @@ function setup() {
2222
delay = new p5.Delay();
2323
delay.process(noise, .12, .7, 2300); // tell delay to process noise
2424

25-
// the Env ADSR: attackTime, decayTime, sustainLevel, releaseTime
26-
env = new p5.Env();
25+
// the Envelope ADSR: attackTime, decayTime, sustainLevel, releaseTime
26+
env = new p5.Envelope();
2727
env.setADSR(0.01, 0.2, 0.2, 0.1)
2828
env.setRange(1, 0);
2929

Diff for: ‎examples/_polyphonic_synth/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function PeriodicWave(params){
6363
this.osc.disconnect();
6464
this.osc.start();
6565

66-
this.env = new p5.Env(0.021,0.025,0.025,0.025,0.95,0.33,0.25);
66+
this.env = new p5.Envelope(0.021,0.025,0.025,0.025,0.95,0.33,0.25);
6767
this.env.disconnect();
6868

6969
this.filter = new p5.LowPass();

Diff for: ‎examples/bells_envelope_test/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function setup()
5656
{
5757
// make arrays of sine waves for each note, additive synthesis, and assign independent envelopes, amplitudes, and slight detunings for each harmonic
5858
osc[i][j] = new p5.SinOsc();
59-
envelope[i][j] = new p5.Env();
59+
envelope[i][j] = new p5.Envelope();
6060
if (random(0, 1) > percentWashed)
6161
{
6262
myMaxAttack = maxAttack;

Diff for: ‎examples/distortion/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function setup() {
1313
fft = new p5.FFT(0, 256);
1414

1515

16-
env = new p5.Env();
16+
env = new p5.Envelope();
1717
env.setADSR(0.01, 0.2, 0.1, 0.3);
1818
env.setRange(1.0, 0.0);
1919

Diff for: ‎examples/envAmpFreq/sketch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ var osc; // this oscillator will modulate the amplitude of the carrier
77
var freqEnv; // env for frequency
88

99
function setup() {
10-
env = new p5.Env();
10+
env = new p5.Envelope();
1111
env.setADSR(0.01, 0.2, 0.2, 0.3);
1212
env.setRange(0, 1);
1313

14-
freqEnv = new p5.Env();
14+
freqEnv = new p5.Envelope();
1515
freqEnv.setADSR(0.01, 0.2, 0.2, 0.3);
1616
freqEnv.setRange(300, 5000);
1717

Diff for: ‎examples/envExp/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function setup() {
3434
audioContext = getAudioContext();
3535

3636
// Instantiate the envelope with time / value pairs
37-
envelope = new p5.Env(0.1, 0.5, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0);
37+
envelope = new p5.Envelope(0.1, 0.5, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0);
3838
osc.amp(0.);
3939
osc.start();
4040
myPhraseAttack = new p5.Phrase('testerAttack', makeSoundAttack, atPattern);

Diff for: ‎examples/envelope/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function setup(){
4545
triOsc.amp(0);
4646
triOsc.start();
4747

48-
env = new p5.Env();
48+
env = new p5.Envelope();
4949
env.setADSR(attackTime, decayTime, susPercent, releaseTime);
5050
env.setRange(attackLevel, releaseLevel);
5151

Diff for: ‎examples/envelopeMultipleSources/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function setup(){
5353
noise.setType('brown');
5454
noise.start();
5555

56-
env = new p5.Env(attackTime, attackLevel, decayTime, decayLevel, sustainTime, sustainLevel, releaseTime);
56+
env = new p5.Envelope(attackTime, attackLevel, decayTime, decayLevel, sustainTime, sustainLevel, releaseTime);
5757

5858
// noise.amp(env);
5959
// triOsc.amp(env);

Diff for: ‎examples/envelopeOnOff/sketch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Example: Create an Envelope (p5.Env) to control oscillator amplitude.
2+
* Example: Create an Envelope (p5.Envelope) to control oscillator amplitude.
33
* Trigger the Attack portion of the envelope when the mouse is clicked.
44
* Trigger the Release when the mouse is released.
55
*/
@@ -35,7 +35,7 @@ function setup(){
3535
osc.freq(220);
3636
osc.start();
3737

38-
env = new p5.Env();
38+
env = new p5.Envelope();
3939
env.setADSR(attackTime, decayTime, susPercent, releaseTime);
4040
env.setRange(attackLevel, releaseLevel);
4141

Diff for: ‎examples/envelopeRamp/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var numWaveforms = 50;
1010
function setup() {
1111
createCanvas(710, 200);
1212
osc = new p5.SinOsc();
13-
envelope = new p5.Env();
13+
envelope = new p5.Envelope();
1414
envelope.setADSR(.005,0.02);
1515
osc.amp(0.);
1616
osc.start();

Diff for: ‎examples/envelope_designer/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function setup() {
2020
var cnv = createCanvas(500, 500);
2121
cnv.mousePressed(playEnv);
2222

23-
env = new p5.Env();
23+
env = new p5.Envelope();
2424
osc = new p5.Oscillator('triangle');
2525
osc.amp(env);
2626
osc.start();

Diff for: ‎examples/envelope_exponential_play/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var numWaveforms = 50;
1111
function setup() {
1212
createCanvas(710, 200);
1313
osc = new p5.SinOsc();
14-
envelope = new p5.Env(0.1, 1.0, 0.1, .5, .1, .5, .1, 0.0); //
14+
envelope = new p5.Envelope(0.1, 1.0, 0.1, .5, .1, .5, .1, 0.0); //
1515
envelope.setExp(true);
1616
//envelope.setADSR(0.1, 1.0, 1.0, 0.2, 5.0, 0.0); //AT, AL, DT, SL, RT, RL
1717
osc.amp(0.);

Diff for: ‎examples/envelope_exponential_trig_rel/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var numWaveforms = 50;
1111
function setup() {
1212
createCanvas(710, 200);
1313
osc = new p5.SinOsc();
14-
envelope = new p5.Env();
14+
envelope = new p5.Envelope();
1515
envelope.setExp(true);
1616
envelope.setADSR(0.1, 1.0, .1, 0.2, .01, 0.0); //AT, AL, DT, SL, RT, RL
1717
osc.amp(0.);

Diff for: ‎examples/learningProcessingExamples/07_envelope/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function setup() {
2727
osc = new p5.SinOsc();
2828

2929
// Instantiate the envelope with time / value pairs
30-
envelope = new p5.Env(0.01, 0.5, 1, 0.5);
30+
envelope = new p5.Envelope(0.01, 0.5, 1, 0.5);
3131

3232
osc.start();
3333
}

Diff for: ‎examples/looper_simple/sketch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var prevTime = 0;
1515

1616
function setup() {
1717
// prepare the osc and env used by playNote()
18-
env = new p5.Env(0.01, 0.8, 0.2, 0);
18+
env = new p5.Envelope(0.01, 0.8, 0.2, 0);
1919
osc = new p5.TriOsc(); // connects to master output by default
2020
osc.start(0);
2121
osc.connect();
@@ -25,7 +25,7 @@ function setup() {
2525
noise = new p5.Noise();
2626
// noise.amp(0.0);
2727
noise.start();
28-
noiseEnv = new p5.Env(0.01, 0.5, 0.1, 0);
28+
noiseEnv = new p5.Envelope(0.01, 0.5, 0.1, 0);
2929
noiseEnv.setInput(noise);
3030
// create a part with 8 spaces, where each space represents 1/16th note (default)
3131
part = new p5.Part(8, 1/16);

Diff for: ‎examples/oscillator_FMSynth/sketch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function setup() {
1717
carrier.freq(carrierFreq);
1818
carrier.start();
1919

20-
env = new p5.Env(0.05, 1, 0.5, 0);
20+
env = new p5.Envelope(0.05, 1, 0.5, 0);
2121
carrier.amp(env);
2222

2323
modulator = new p5.Oscillator();

Diff for: ‎src/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ define(function (require) {
1212
require('fft');
1313
require('signal');
1414
require('oscillator');
15-
require('env');
15+
require('envelope');
1616
require('pulse');
1717
require('noise');
1818
require('audioin');

Diff for: ‎src/delay.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ define(function (require) {
4646
*
4747
* // play the noise with an envelope,
4848
* // a series of fades ( time / value pairs )
49-
* env = new p5.Env(.01, 0.2, .2, .1);
49+
* env = new p5.Envelope(.01, 0.2, .2, .1);
5050
* }
5151
*
5252
* // mouseClick triggers envelope

Diff for: ‎src/env.js renamed to ‎src/envelope.js

+52-44
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ define(function (require) {
1717
* of an object, a series of fades referred to as Attack, Decay,
1818
* Sustain and Release (
1919
* <a href="https://upload.wikimedia.org/wikipedia/commons/e/ea/ADSR_parameter.svg">ADSR</a>
20-
* ). Envelopes can also control other Web Audio Parameters—for example, a p5.Env can
20+
* ). Envelopes can also control other Web Audio Parameters—for example, a p5.Envelope can
2121
* control an Oscillator's frequency like this: <code>osc.freq(env)</code>.</p>
22-
* <p>Use <code><a href="#/p5.Env/setRange">setRange</a></code> to change the attack/release level.
23-
* Use <code><a href="#/p5.Env/setADSR">setADSR</a></code> to change attackTime, decayTime, sustainPercent and releaseTime.</p>
24-
* <p>Use the <code><a href="#/p5.Env/play">play</a></code> method to play the entire envelope,
25-
* the <code><a href="#/p5.Env/ramp">ramp</a></code> method for a pingable trigger,
26-
* or <code><a href="#/p5.Env/triggerAttack">triggerAttack</a></code>/
27-
* <code><a href="#/p5.Env/triggerRelease">triggerRelease</a></code> to trigger noteOn/noteOff.</p>
28-
*
29-
* @class p5.Env
22+
* <p>Use <code><a href="#/p5.Envelope/setRange">setRange</a></code> to change the attack/release level.
23+
* Use <code><a href="#/p5.Envelope/setADSR">setADSR</a></code> to change attackTime, decayTime, sustainPercent and releaseTime.</p>
24+
* <p>Use the <code><a href="#/p5.Envelope/play">play</a></code> method to play the entire envelope,
25+
* the <code><a href="#/p5.Envelope/ramp">ramp</a></code> method for a pingable trigger,
26+
* or <code><a href="#/p5.Envelope/triggerAttack">triggerAttack</a></code>/
27+
* <code><a href="#/p5.Envelope/triggerRelease">triggerRelease</a></code> to trigger noteOn/noteOff.</p>
28+
*
29+
* @class p5.Envelope
3030
* @constructor
3131
* @example
3232
* <div><code>
@@ -46,7 +46,7 @@ define(function (require) {
4646
* textAlign(CENTER);
4747
* text('click to play', width/2, height/2);
4848
*
49-
* env = new p5.Env();
49+
* env = new p5.Envelope();
5050
* env.setADSR(attackTime, decayTime, susPercent, releaseTime);
5151
* env.setRange(attackLevel, releaseLevel);
5252
*
@@ -63,7 +63,7 @@ define(function (require) {
6363
* }
6464
* </code></div>
6565
*/
66-
p5.Env = function(t1, l1, t2, l2, t3, l3) {
66+
p5.Envelope = function(t1, l1, t2, l2, t3, l3) {
6767
/**
6868
* Time until envelope reaches attackLevel
6969
* @property attackTime
@@ -130,7 +130,7 @@ define(function (require) {
130130

131131
// this init function just smooths the starting value to zero and gives a start point for the timeline
132132
// - it was necessary to remove glitches at the beginning.
133-
p5.Env.prototype._init = function () {
133+
p5.Envelope.prototype._init = function () {
134134
var now = p5sound.audiocontext.currentTime;
135135
var t = now;
136136
this.control.setTargetAtTime(0.00001, t, .001);
@@ -171,7 +171,7 @@ define(function (require) {
171171
* textAlign(CENTER);
172172
* text('click to play', width/2, height/2);
173173
*
174-
* env = new p5.Env(t1, l1, t2, l2, t3, l3);
174+
* env = new p5.Envelope(t1, l1, t2, l2, t3, l3);
175175
* triOsc = new p5.Oscillator('triangle');
176176
* triOsc.amp(env); // give the env control of the triOsc's amp
177177
* triOsc.start();
@@ -187,7 +187,7 @@ define(function (require) {
187187
* </code></div>
188188
*
189189
*/
190-
p5.Env.prototype.set = function(t1, l1, t2, l2, t3, l3) {
190+
p5.Envelope.prototype.set = function(t1, l1, t2, l2, t3, l3) {
191191
this.aTime = t1;
192192
this.aLevel = l1;
193193
this.dTime = t2 || 0;
@@ -237,7 +237,7 @@ define(function (require) {
237237
* textAlign(CENTER);
238238
* text('click to play', width/2, height/2);
239239
*
240-
* env = new p5.Env();
240+
* env = new p5.Envelope();
241241
* env.setADSR(attackTime, decayTime, susPercent, releaseTime);
242242
* env.setRange(attackLevel, releaseLevel);
243243
*
@@ -254,7 +254,7 @@ define(function (require) {
254254
* }
255255
* </code></div>
256256
*/
257-
p5.Env.prototype.setADSR = function(aTime, dTime, sPercent, rTime) {
257+
p5.Envelope.prototype.setADSR = function(aTime, dTime, sPercent, rTime) {
258258
this.aTime = aTime;
259259
this.dTime = dTime || 0;
260260

@@ -292,7 +292,7 @@ define(function (require) {
292292
* textAlign(CENTER);
293293
* text('click to play', width/2, height/2);
294294
*
295-
* env = new p5.Env();
295+
* env = new p5.Envelope();
296296
* env.setADSR(attackTime, decayTime, susPercent, releaseTime);
297297
* env.setRange(attackLevel, releaseLevel);
298298
*
@@ -309,7 +309,7 @@ define(function (require) {
309309
* }
310310
* </code></div>
311311
*/
312-
p5.Env.prototype.setRange = function(aLevel, rLevel) {
312+
p5.Envelope.prototype.setRange = function(aLevel, rLevel) {
313313
this.aLevel = aLevel || 1;
314314
this.rLevel = rLevel || 0;
315315

@@ -334,7 +334,7 @@ define(function (require) {
334334
// param {Number} attackTimeConstant attack time constant
335335
// param {Number} decayTimeConstant decay time constant
336336
//
337-
p5.Env.prototype._setRampAD = function(t1, t2) {
337+
p5.Envelope.prototype._setRampAD = function(t1, t2) {
338338
this._rampAttackTime = this.checkExpInput(t1);
339339
this._rampDecayTime = this.checkExpInput(t2);
340340

@@ -347,7 +347,7 @@ define(function (require) {
347347
};
348348

349349
// private method
350-
p5.Env.prototype.setRampPercentages = function(p1, p2) {
350+
p5.Envelope.prototype.setRampPercentages = function(p1, p2) {
351351
//set the percentages that the simple exponential ramps go to
352352
this._rampHighPercentage = this.checkExpInput(p1);
353353
this._rampLowPercentage = this.checkExpInput(p2);
@@ -363,15 +363,15 @@ define(function (require) {
363363

364364
/**
365365
* Assign a parameter to be controlled by this envelope.
366-
* If a p5.Sound object is given, then the p5.Env will control its
366+
* If a p5.Sound object is given, then the p5.Envelope will control its
367367
* output gain. If multiple inputs are provided, the env will
368368
* control all of them.
369369
*
370370
* @method setInput
371371
* @param {Object} [...inputs] A p5.sound object or
372372
* Web Audio Param.
373373
*/
374-
p5.Env.prototype.setInput = function() {
374+
p5.Envelope.prototype.setInput = function() {
375375
for (var i = 0; i<arguments.length; i++) {
376376
this.connect(arguments[i]);
377377
}
@@ -385,12 +385,12 @@ define(function (require) {
385385
* @method setExp
386386
* @param {Boolean} isExp true is exponential, false is linear
387387
*/
388-
p5.Env.prototype.setExp = function(isExp) {
388+
p5.Envelope.prototype.setExp = function(isExp) {
389389
this.isExponential = isExp;
390390
};
391391

392392
//helper method to protect against zero values being sent to exponential functions
393-
p5.Env.prototype.checkExpInput = function(value) {
393+
p5.Envelope.prototype.checkExpInput = function(value) {
394394
if (value <= 0)
395395
{
396396
value = 0.00000001;
@@ -401,7 +401,7 @@ define(function (require) {
401401
/**
402402
* Play tells the envelope to start acting on a given input.
403403
* If the input is a p5.sound object (i.e. AudioIn, Oscillator,
404-
* SoundFile), then Env will control its output volume.
404+
* SoundFile), then Envelope will control its output volume.
405405
* Envelopes can also be used to control any <a href="
406406
* http://docs.webplatform.org/wiki/apis/webaudio/AudioParam">
407407
* Web Audio Audio Param.</a>
@@ -429,7 +429,7 @@ define(function (require) {
429429
* textAlign(CENTER);
430430
* text('click to play', width/2, height/2);
431431
*
432-
* env = new p5.Env();
432+
* env = new p5.Envelope();
433433
* env.setADSR(attackTime, decayTime, susPercent, releaseTime);
434434
* env.setRange(attackLevel, releaseLevel);
435435
*
@@ -448,7 +448,7 @@ define(function (require) {
448448
* }
449449
* </code></div>
450450
*/
451-
p5.Env.prototype.play = function(unit, secondsFromNow, susTime) {
451+
p5.Envelope.prototype.play = function(unit, secondsFromNow, susTime) {
452452
var tFromNow = secondsFromNow || 0;
453453
var susTime = susTime || 0;
454454

@@ -494,7 +494,7 @@ define(function (require) {
494494
* textAlign(CENTER);
495495
* text('click to play', width/2, height/2);
496496
*
497-
* env = new p5.Env();
497+
* env = new p5.Envelope();
498498
* env.setADSR(attackTime, decayTime, susPercent, releaseTime);
499499
* env.setRange(attackLevel, releaseLevel);
500500
*
@@ -522,7 +522,7 @@ define(function (require) {
522522
* }
523523
* </code></div>
524524
*/
525-
p5.Env.prototype.triggerAttack = function(unit, secondsFromNow) {
525+
p5.Envelope.prototype.triggerAttack = function(unit, secondsFromNow) {
526526
var now = p5sound.audiocontext.currentTime;
527527
var tFromNow = secondsFromNow || 0;
528528
var t = now + tFromNow;
@@ -615,7 +615,7 @@ define(function (require) {
615615
* textAlign(CENTER);
616616
* text('click to play', width/2, height/2);
617617
*
618-
* env = new p5.Env();
618+
* env = new p5.Envelope();
619619
* env.setADSR(attackTime, decayTime, susPercent, releaseTime);
620620
* env.setRange(attackLevel, releaseLevel);
621621
*
@@ -643,7 +643,7 @@ define(function (require) {
643643
* }
644644
* </code></div>
645645
*/
646-
p5.Env.prototype.triggerRelease = function(unit, secondsFromNow) {
646+
p5.Envelope.prototype.triggerRelease = function(unit, secondsFromNow) {
647647

648648
// only trigger a release if an attack was triggered
649649
if (!this.wasTriggered) {
@@ -701,7 +701,7 @@ define(function (require) {
701701

702702
/**
703703
* Exponentially ramp to a value using the first two
704-
* values from <code><a href="#/p5.Env/setADSR">setADSR(attackTime, decayTime)</a></code>
704+
* values from <code><a href="#/p5.Envelope/setADSR">setADSR(attackTime, decayTime)</a></code>
705705
* as <a href="https://en.wikipedia.org/wiki/RC_time_constant">
706706
* time constants</a> for simple exponential ramps.
707707
* If the value is higher than current value, it uses attackTime,
@@ -726,7 +726,7 @@ define(function (require) {
726726
* fill(0,255,0);
727727
* noStroke();
728728
*
729-
* env = new p5.Env();
729+
* env = new p5.Envelope();
730730
* env.setADSR(attackTime, decayTime);
731731
*
732732
* osc = new p5.Oscillator();
@@ -751,7 +751,7 @@ define(function (require) {
751751
* }
752752
* </code></div>
753753
*/
754-
p5.Env.prototype.ramp = function(unit, secondsFromNow, v1, v2) {
754+
p5.Envelope.prototype.ramp = function(unit, secondsFromNow, v1, v2) {
755755

756756
var now = p5sound.audiocontext.currentTime;
757757
var tFromNow = secondsFromNow || 0;
@@ -797,7 +797,7 @@ define(function (require) {
797797
};
798798

799799

800-
p5.Env.prototype.connect = function(unit) {
800+
p5.Envelope.prototype.connect = function(unit) {
801801
this.connection = unit;
802802

803803
// assume we're talking about output gain
@@ -822,7 +822,7 @@ define(function (require) {
822822
this.output.connect(unit);
823823
};
824824

825-
p5.Env.prototype.disconnect = function() {
825+
p5.Envelope.prototype.disconnect = function() {
826826
if (this.output) {
827827
this.output.disconnect();
828828
}
@@ -838,27 +838,27 @@ define(function (require) {
838838
*
839839
* @method add
840840
* @param {Number} number Constant number to add
841-
* @return {p5.Env} Envelope Returns this envelope
841+
* @return {p5.Envelope} Envelope Returns this envelope
842842
* with scaled output
843843
*/
844-
p5.Env.prototype.add = function(num) {
844+
p5.Envelope.prototype.add = function(num) {
845845
var add = new Add(num);
846846
var thisChain = this.mathOps.length;
847847
var nextChain = this.output;
848848
return p5.prototype._mathChain(this, add, thisChain, nextChain, Add);
849849
};
850850

851851
/**
852-
* Multiply the p5.Env's output amplitude
852+
* Multiply the p5.Envelope's output amplitude
853853
* by a fixed value. Calling this method
854854
* again will override the initial mult() with new values.
855855
*
856856
* @method mult
857857
* @param {Number} number Constant number to multiply
858-
* @return {p5.Env} Envelope Returns this envelope
858+
* @return {p5.Envelope} Envelope Returns this envelope
859859
* with scaled output
860860
*/
861-
p5.Env.prototype.mult = function(num) {
861+
p5.Envelope.prototype.mult = function(num) {
862862
var mult = new Mult(num);
863863
var thisChain = this.mathOps.length;
864864
var nextChain = this.output;
@@ -875,10 +875,10 @@ define(function (require) {
875875
* @param {Number} inMax input range maximum
876876
* @param {Number} outMin input range minumum
877877
* @param {Number} outMax input range maximum
878-
* @return {p5.Env} Envelope Returns this envelope
878+
* @return {p5.Envelope} Envelope Returns this envelope
879879
* with scaled output
880880
*/
881-
p5.Env.prototype.scale = function(inMin, inMax, outMin, outMax) {
881+
p5.Envelope.prototype.scale = function(inMin, inMax, outMin, outMax) {
882882
var scale = new Scale(inMin, inMax, outMin, outMax);
883883
var thisChain = this.mathOps.length;
884884
var nextChain = this.output;
@@ -887,7 +887,7 @@ define(function (require) {
887887

888888

889889
// get rid of the oscillator
890-
p5.Env.prototype.dispose = function() {
890+
p5.Envelope.prototype.dispose = function() {
891891
// remove reference from soundArray
892892
var index = p5sound.soundArray.indexOf(this);
893893
p5sound.soundArray.splice(index, 1);
@@ -902,4 +902,12 @@ define(function (require) {
902902
}
903903
};
904904

905+
// Different name for backwards compatibility, replicates p5.Envelope class
906+
p5.Env = function(t1, l1, t2, l2, t3, l3) {
907+
console.warn('WARNING: p5.Env is now deprecated and may be removed in future versions. ' +
908+
'Please use the new p5.Envelope instead.');
909+
p5.Envelope.call(this, t1, l1, t2, l2, t3, l3);
910+
};
911+
p5.Env.prototype = Object.create(p5.Envelope.prototype);
912+
905913
});

Diff for: ‎src/helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ define(function (require) {
181181
};
182182

183183
/**
184-
* Used by Osc and Env to chain signal math
184+
* Used by Osc and Envelope to chain signal math
185185
*/
186186
p5.prototype._mathChain = function(o, math, thisChain, nextChain, type) {
187187
// if this type of math already exists in the chain, replace it

Diff for: ‎src/master.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ define(function () {
6464
* 1.0 is the maximum amplitude of a digital sound, so multiplying
6565
* by greater than 1.0 may cause digital distortion. To
6666
* fade, provide a <code>rampTime</code> parameter. For more
67-
* complex fades, see the Env class.
67+
* complex fades, see the Envelope class.
6868
*
6969
* Alternately, you can pass in a signal source such as an
7070
* oscillator to modulate the amplitude with an audio signal.

Diff for: ‎src/monosynth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ define(function (require) {
4949
this.oscillator = new p5.Oscillator();
5050
// this.oscillator.disconnect();
5151

52-
this.env = new p5.Env();
52+
this.env = new p5.Envelope();
5353
this.env.setRange(1, 0);
5454
this.env.setExp(true);
5555

Diff for: ‎src/soundfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ define(function (require) {
687687
* 1.0 is the maximum amplitude of a digital sound, so multiplying
688688
* by greater than 1.0 may cause digital distortion. To
689689
* fade, provide a <code>rampTime</code> parameter. For more
690-
* complex fades, see the Env class.
690+
* complex fades, see the Envelope class.
691691
*
692692
* Alternately, you can pass in a signal source such as an
693693
* oscillator to modulate the amplitude with an audio signal.

Diff for: ‎todo.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ p5.sound to do list
1313
- Figure out a way to keep track of connections between objects. From there, .disconnect() can accept a specific object rather than disconnecting all output.
1414

1515

16-
- Make sure all methods that should be modular can accept a Number, AudioParam, p5.Env, p5.Oscillator or p5.Signal as input.
16+
- Make sure all methods that should be modular can accept a Number, AudioParam, p5.Envelope, p5.Oscillator or p5.Signal as input.
1717

1818

1919
- Log a message to the console if a user calls FFT methods like getEnergy without first calling .analyze() in either the draw loop, or in the method in which they call getEnergy. Maybe log the time that .analyze was last called, and compare it to the current time, and if it is a big gap, then log the message?
@@ -74,8 +74,8 @@ p5.sound to do list
7474

7575
- Add option to p5.FFT that returns data in decibels (from Float32Array)
7676

77-
- p5.Env should be able to connect to multiple
78-
- p5.Env takes no action on triggerRelease unless currently playing
77+
- p5.Envelope should be able to connect to multiple
78+
- p5.Envelope takes no action on triggerRelease unless currently playing
7979

8080
- Add a logarithmic scaling option for p5.FFT
8181
- p5.SoundFile.getPeaks should be able to return stereo peaks. Like [this](https://github.com/olosmusic/olos-soundfile/blob/master/olos-soundfile.html#L379)

0 commit comments

Comments
 (0)
Please sign in to comment.