Skip to content

Commit 94972af

Browse files
committed
Merge branch 'main' into Listener_tests
2 parents a361226 + 83297b9 commit 94972af

23 files changed

+2568
-1292
lines changed

lib/p5.sound.js

Lines changed: 118 additions & 118 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 1319 additions & 347 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
"chai": "3.4.1",
1717
"eslint-config-prettier": "^6.11.0",
1818
"eslint-plugin-prettier": "^3.1.3",
19-
"grunt": "~0.4.5",
20-
"grunt-cli": "^0.1.13",
19+
"grunt": "~1.5.3",
20+
"grunt-cli": "^1.4.3",
2121
"grunt-contrib-connect": "^1.0.2",
2222
"grunt-decomment": "^0.2.4",
2323
"grunt-eslint": "^20.0.0",
2424
"grunt-githooks": "^0.6.0",
2525
"grunt-mocha": "^1.0.4",
2626
"grunt-open": "^0.2.3",
2727
"grunt-webpack": "^3.1.3",
28-
"mocha": "2.3.4",
28+
"mocha": "10.1.0",
2929
"prettier": "2.0.5",
3030
"raw-loader": "^3.0.0",
3131
"tslint-config-prettier": "^1.18.0",

src/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ p5.Distortion = Distortion;
129129
import Gain from './gain';
130130
p5.Gain = Gain;
131131

132+
import Envelope from './envelope';
133+
p5.Envelope = Envelope;
134+
135+
import Env from './deprecations/Env';
136+
p5.Env = Env;
137+
132138
import AudioVoice from './audioVoice';
133139
p5.AudioVoice = AudioVoice;
134140

src/audioVoice.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class AudioVoice {
2323

2424
amp(vol, rampTime) {}
2525

26+
setADSR(attack, decay, sustain, release) {}
27+
2628
/**
2729
* Connect to p5 objects or Web Audio Nodes
2830
* @method connect

src/compressor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class Compressor extends Effect {
235235
* @return {Number} Value of the amount of gain reduction that is applied to the signal
236236
*/
237237
reduction() {
238-
return this.compressor.reduction.value;
238+
return this.compressor.reduction;
239239
}
240240

241241
dispose() {

src/delay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Delay extends Effect {
114114
*
115115
* @method process
116116
* @for p5.Delay
117-
* @param {Object} Signal An object that outputs audio
117+
* @param {Object} src An object that outputs audio
118118
* @param {Number} [delayTime] Time (in seconds) of the delay/echo.
119119
* Some browsers limit delayTime to
120120
* 1 second.

src/deprecations/Env.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Envelope from '../envelope';
2+
3+
class Env extends Envelope {
4+
constructor(t1, l1, t2, l2, t3, l3) {
5+
console.warn(
6+
'WARNING: p5.Env is now deprecated and may be removed in future versions. ' +
7+
'Please use the new p5.Envelope instead.'
8+
);
9+
super(t1, l1, t2, l2, t3, l3);
10+
}
11+
}
12+
13+
export default Env;

src/distortion.js

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,72 @@ function makeDistortionCurve(amount) {
3030
* @class p5.Distortion
3131
* @extends p5.Effect
3232
* @constructor
33-
* @param {Number} [amount=0.25] Unbounded distortion amount.
34-
* Normal values range from 0-1.
35-
* @param {String} [oversample='none'] 'none', '2x', or '4x'.
33+
* @param {Number} [amount] Unbounded distortion amount.
34+
* Normal values range from 0-1 (defaults to 0.25)
35+
* @param {String} [oversample] 'none', '2x' (default), or '4x'.
36+
* @example
37+
* <div><code>
38+
* let osc, distortion, fft;
3639
*
40+
* function setup() {
41+
* let cnv = createCanvas(100, 100);
42+
* fft = new p5.FFT(0, 256);
43+
*
44+
* osc = new p5.TriOsc();
45+
* osc.amp(0.3);
46+
* osc.freq(375);
47+
*
48+
* distortion = new p5.Distortion();
49+
* distortion.process(osc);
50+
* cnv.mousePressed(oscStart);
51+
* }
52+
*
53+
* function draw() {
54+
* background(220);
55+
* // set the amount based on mouseX
56+
* let amount = constrain(map(mouseX, 0, width, 0, 1), 0, 1);
57+
*
58+
* // multiply the amount to smooth the value
59+
* distortion.set(amount * amount);
60+
*
61+
* noStroke();
62+
* fill(0);
63+
* text('tap to play', 10, 20);
64+
* text('amount: ' + amount, 10, 40);
65+
*
66+
* // draw the waveform
67+
* var samples = fft.waveform();
68+
* drawOscilloscope(samples);
69+
* }
70+
*
71+
* //function based on distortion example
72+
* function drawOscilloscope(samples) {
73+
* var yTranslateScope = 20;
74+
* var scopeWidth = width;
75+
* var scopeHeight = height;
76+
*
77+
* stroke(0);
78+
* strokeWeight(1);
79+
* noFill();
80+
*
81+
* beginShape();
82+
* for (var sampleIndex in samples) {
83+
* var x = map(sampleIndex, 0, samples.length, 0, scopeWidth);
84+
* var y = map(samples[sampleIndex], -1, 1, -scopeHeight / 4, scopeHeight / 4);
85+
* vertex(x, y + scopeHeight / 2 + yTranslateScope);
86+
* }
87+
* endShape();
88+
* }
89+
*
90+
* function oscStart() {
91+
* osc.start();
92+
* }
93+
*
94+
* function mouseReleased() {
95+
* osc.stop();
96+
* }
97+
*
98+
* </code></div>
3799
*/
38100
class Distortion extends Effect {
39101
constructor(amount, oversample) {
@@ -61,8 +123,7 @@ class Distortion extends Effect {
61123
* @property {AudioNode} WaveShaperNode
62124
*/
63125
this.waveShaperNode = this.ac.createWaveShaper();
64-
65-
this.amount = curveAmount;
126+
this.amount = amount;
66127
this.waveShaperNode.curve = makeDistortionCurve(curveAmount);
67128
this.waveShaperNode.oversample = oversample;
68129

@@ -76,9 +137,10 @@ class Distortion extends Effect {
76137
*
77138
* @method process
78139
* @for p5.Distortion
79-
* @param {Number} [amount=0.25] Unbounded distortion amount.
140+
* @param {Object} src An object that outputs audio
141+
* @param {Number} [amount] Unbounded distortion amount.
80142
* Normal values range from 0-1.
81-
* @param {String} [oversample='none'] 'none', '2x', or '4x'.
143+
* @param {String} [oversample] 'none', '2x', or '4x'.
82144
*/
83145
process(src, amount, oversample) {
84146
src.connect(this.input);
@@ -90,14 +152,15 @@ class Distortion extends Effect {
90152
*
91153
* @method set
92154
* @for p5.Distortion
93-
* @param {Number} [amount=0.25] Unbounded distortion amount.
155+
* @param {Number} [amount] Unbounded distortion amount.
94156
* Normal values range from 0-1.
95-
* @param {String} [oversample='none'] 'none', '2x', or '4x'.
157+
* @param {String} [oversample] 'none', '2x', or '4x'.
96158
*/
97159
set(amount, oversample) {
98-
if (amount) {
160+
if (typeof amount === 'number') {
99161
var curveAmount = p5.prototype.map(amount, 0.0, 1.0, 0, 2000);
100-
this.amount = curveAmount;
162+
//this.amount = curveAmount;
163+
this.amount = amount;
101164
this.waveShaperNode.curve = makeDistortionCurve(curveAmount);
102165
}
103166
if (oversample) {

src/effect.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import CrossFade from 'Tone/component/CrossFade.js';
1111
* <a href="/reference/#/p5.Compressor">p5.Compressor</a>,
1212
* <a href="/reference/#/p5.Delay">p5.Delay</a>,
1313
* <a href="/reference/#/p5.Filter">p5.Filter</a>,
14-
* <a href="/reference/#/p5.Reverb">p5.Reverb</a>.
14+
* <a href="/reference/#/p5.Reverb">p5.Reverb</a>,
15+
* <a href="/reference/#/p5.EQ">p5.EQ</a>,
16+
* <a href="/reference/#/p5.Panner3D">p5.Panner3D</a>.
1517
*
1618
* @class p5.Effect
1719
* @constructor

0 commit comments

Comments
 (0)