Skip to content

Commit b27eca9

Browse files
authored
Merge pull request #737 from processing/p5-sound-versions
Only use old p5.sound on 1.x
2 parents dae0435 + 343e2ac commit b27eca9

File tree

154 files changed

+3291
-3364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+3291
-3364
lines changed

public/reference/data.json

+1,394-1,603
Large diffs are not rendered by default.

src/content/reference/en/p5.Amplitude/getLevel.mdx

+44-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,54 @@
22
title: getLevel
33
module: p5.sound
44
submodule: p5.sound
5-
file: src/Amplitude.js
6-
description: Get the current amplitude value of a sound.
7-
line: 63
5+
file: lib/addons/p5.sound.js
6+
description: |
7+
<p>Returns a single Amplitude reading at the moment it is called.
8+
For continuous readings, run in the draw loop.</p>
9+
line: 3209
810
isConstructor: false
911
itemtype: method
12+
example:
13+
- |-
14+
15+
<div><code>
16+
function preload(){
17+
sound = loadSound('/assets/beat.mp3');
18+
}
19+
20+
function setup() {
21+
let cnv = createCanvas(100, 100);
22+
cnv.mouseClicked(toggleSound);
23+
amplitude = new p5.Amplitude();
24+
}
25+
26+
function draw() {
27+
background(220, 150);
28+
textAlign(CENTER);
29+
text('tap to play', width/2, 20);
30+
31+
let level = amplitude.getLevel();
32+
let size = map(level, 0, 1, 0, 200);
33+
ellipse(width/2, height/2, size, size);
34+
}
35+
36+
function toggleSound(){
37+
if (sound.isPlaying()) {
38+
sound.stop();
39+
} else {
40+
sound.play();
41+
}
42+
}
43+
</code></div>
1044
class: p5.Amplitude
45+
params:
46+
- name: channel
47+
description: |
48+
<p>Optionally return only channel 0 (left) or 1 (right)</p>
49+
type: Number
50+
optional: true
1151
return:
12-
description: Amplitude level (volume) of a sound.
52+
description: Amplitude as a number between 0.0 and 1.0
1353
type: Number
1454
chainable: false
1555
---

src/content/reference/en/p5.Amplitude/setInput.mdx

+53-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,63 @@
22
title: setInput
33
module: p5.sound
44
submodule: p5.sound
5-
file: src/Amplitude.js
6-
description: Connect an audio source to the amplitude object.
7-
line: 53
5+
file: lib/addons/p5.sound.js
6+
description: |
7+
<p>Connects to the p5sound instance (main output) by default.
8+
Optionally, you can pass in a specific source (i.e. a soundfile).</p>
9+
line: 3117
810
isConstructor: false
911
itemtype: method
12+
example:
13+
- |-
14+
15+
<div><code>
16+
function preload(){
17+
sound1 = loadSound('/assets/beat.mp3');
18+
sound2 = loadSound('/assets/drum.mp3');
19+
}
20+
function setup(){
21+
cnv = createCanvas(100, 100);
22+
cnv.mouseClicked(toggleSound);
23+
24+
amplitude = new p5.Amplitude();
25+
amplitude.setInput(sound2);
26+
}
27+
28+
function draw() {
29+
background(220);
30+
text('tap to play', 20, 20);
31+
32+
let level = amplitude.getLevel();
33+
let size = map(level, 0, 1, 0, 200);
34+
ellipse(width/2, height/2, size, size);
35+
}
36+
37+
function toggleSound(){
38+
if (sound1.isPlaying() && sound2.isPlaying()) {
39+
sound1.stop();
40+
sound2.stop();
41+
} else {
42+
sound1.play();
43+
sound2.play();
44+
}
45+
}
46+
</code></div>
1047
class: p5.Amplitude
1148
params:
12-
- name: input
13-
description: '- An object that has audio output.'
14-
type: Object
49+
- name: snd
50+
description: |
51+
<p>set the sound source
52+
(optional, defaults to
53+
main output)</p>
54+
type: SoundObject|undefined
55+
optional: true
56+
- name: smoothing
57+
description: |
58+
<p>a range between 0.0 and 1.0
59+
to smooth amplitude readings</p>
60+
type: Number|undefined
61+
optional: true
1562
chainable: false
1663
---
1764

src/content/reference/en/p5.Amplitude/smooth.mdx

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
title: smooth
33
module: p5.sound
44
submodule: p5.sound
5-
file: src/Amplitude.js
6-
description: Get the current amplitude value of a sound.
7-
line: 73
5+
file: lib/addons/p5.sound.js
6+
description: |
7+
<p>Smooth Amplitude analysis by averaging with the last analysis
8+
frame. Off by default.</p>
9+
line: 3293
810
isConstructor: false
911
itemtype: method
1012
class: p5.Amplitude
1113
params:
12-
- name: Smooth
13-
description: >-
14-
Amplitude analysis by averaging with the last analysis frame. Off by
15-
default.
14+
- name: set
15+
description: |
16+
<p>smoothing from 0.0 <= 1</p>
1617
type: Number
1718
chainable: false
1819
---

src/content/reference/en/p5.AudioIn/amp.mdx

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
title: amp
33
module: p5.sound
44
submodule: p5.sound
5-
file: src/AudioIn.js
6-
description: Set amplitude (volume) of a mic input between 0 and 1.0.
7-
line: 81
5+
file: lib/addons/p5.sound.js
6+
description: |
7+
<p>Set amplitude (volume) of a mic input between 0 and 1.0. <br/></p>
8+
line: 6257
89
isConstructor: false
910
itemtype: method
1011
class: p5.AudioIn
1112
params:
12-
- name: amplitudeAmount
13-
description: An amplitude value between 0 and 1.
13+
- name: vol
14+
description: |
15+
<p>between 0 and 1.0</p>
1416
type: Number
17+
- name: time
18+
description: |
19+
<p>ramp time (optional)</p>
20+
type: Number
21+
optional: true
1522
chainable: false
1623
---
1724

src/content/reference/en/p5.AudioIn/start.mdx

+26-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,35 @@
22
title: start
33
module: p5.sound
44
submodule: p5.sound
5-
file: src/AudioIn.js
6-
description: Start the audio input.
7-
line: 56
5+
file: lib/addons/p5.sound.js
6+
description: |
7+
<p>Start processing audio input. This enables the use of other
8+
AudioIn methods like getLevel(). Note that by default, AudioIn
9+
is not connected to p5.sound's output. So you won't hear
10+
anything unless you use the connect() method.<br/></p>
11+
<p>Certain browsers limit access to the user's microphone. For example,
12+
Chrome only allows access from localhost and over https. For this reason,
13+
you may want to include an errorCallback—a function that is called in case
14+
the browser won't provide mic access.</p>
15+
line: 6114
816
isConstructor: false
917
itemtype: method
1018
class: p5.AudioIn
19+
params:
20+
- name: successCallback
21+
description: |
22+
<p>Name of a function to call on
23+
success.</p>
24+
type: Function
25+
optional: true
26+
- name: errorCallback
27+
description: |
28+
<p>Name of a function to call if
29+
there was an error. For example,
30+
some browsers do not support
31+
getUserMedia.</p>
32+
type: Function
33+
optional: true
1134
chainable: false
1235
---
1336

src/content/reference/en/p5.AudioIn/stop.mdx

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
title: stop
33
module: p5.sound
44
submodule: p5.sound
5-
file: src/AudioIn.js
6-
description: Stop the audio input.
7-
line: 72
5+
file: lib/addons/p5.sound.js
6+
description: |
7+
<p>Turn the AudioIn off. If the AudioIn is stopped, it cannot getLevel().
8+
If re-starting, the user may be prompted for permission access.</p>
9+
line: 6171
810
isConstructor: false
911
itemtype: method
1012
class: p5.AudioIn

src/content/reference/en/p5.Biquad/freq.mdx

-19
This file was deleted.

src/content/reference/en/p5.Biquad/gain.mdx

-21
This file was deleted.

src/content/reference/en/p5.Biquad/res.mdx

-19
This file was deleted.

src/content/reference/en/p5.Biquad/setType.mdx

-21
This file was deleted.

src/content/reference/en/p5.Delay/amp.mdx

+18-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,29 @@
22
title: amp
33
module: p5.sound
44
submodule: p5.sound
5-
file: src/Delay.js
6-
description: Adjust the amplitude of the delay effect.
7-
line: 146
5+
file: lib/addons/p5.sound.js
6+
description: |
7+
<p>Set the output level of the delay effect.</p>
8+
line: 8223
89
isConstructor: false
910
itemtype: method
1011
class: p5.Delay
1112
params:
12-
- name: amplitudeAmount
13-
description: An amplitude value between 0 and 1.
13+
- name: volume
14+
description: |
15+
<p>amplitude between 0 and 1.0</p>
1416
type: Number
17+
- name: rampTime
18+
description: |
19+
<p>create a fade that lasts rampTime</p>
20+
type: Number
21+
optional: true
22+
- name: timeFromNow
23+
description: |
24+
<p>schedule this event to happen
25+
seconds from now</p>
26+
type: Number
27+
optional: true
1528
chainable: false
1629
---
1730

0 commit comments

Comments
 (0)