Skip to content

Commit 9d7458f

Browse files
authored
Merge pull request #726 from Abhijay007/Abhijay007/AudioIn-fields
(Docs): Updated various fields in the p5.AudioIn reference
2 parents 030270f + 04a3c79 commit 9d7458f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/audioin.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,40 +50,47 @@ p5sound.inputSources = [];
5050
*/
5151
class AudioIn {
5252
constructor(errorCallback) {
53-
// set up audio input
5453
/**
54+
* Set up audio input
5555
* @property {GainNode} input
5656
*/
5757
this.input = p5sound.audiocontext.createGain();
5858
/**
59+
* Send audio as an output, i.e. your computer's speaker.
5960
* @property {GainNode} output
6061
*/
6162
this.output = p5sound.audiocontext.createGain();
62-
6363
/**
64+
* Used to store the MediaStream object that is returned from the getUserMedia() API,
65+
* which allows access to the user's microphone. The stream is used to create a MediaStreamAudioSourceNode,
66+
* which is used as the audio source for the input and output gain nodes.
67+
* The stream is also used to check if the browser supports the MediaStreamTrack and mediaDevices API,
68+
* and if not, an errorCallback function is called or an alert is displayed.
6469
* @property {MediaStream|null} stream
6570
*/
6671
this.stream = null;
6772
/**
73+
* Used to access the "audio input" from the user's microphone.
74+
* It creates a MediaStream object that can be used to start and stop the mic and measure its volume using the getLevel() method or by connecting it to an FFT object.
75+
* MediaStream object can also be use to check if the browser supports MediaStreamTrack and mediaDevices and to add the AudioIn object to the soundArray for disposal on close.
6876
* @property {MediaStreamAudioSourceNode|null} mediaStream
6977
*/
7078
this.mediaStream = null;
7179
/**
80+
* Used to store the "current source of audio input", such as the user's microphone.
81+
* Initially set to "null" and can be updated as the user selects different audio sources.
82+
* Also used in conjunction with the "input" and "mediaStream" properties to control audio input.
7283
* @property {Number|null} currentSource
7384
*/
7485
this.currentSource = null;
75-
7686
/**
7787
* Client must allow browser to access their microphone / audioin source.
7888
* Default: false. Will become true when the client enables access.
79-
*
8089
* @property {Boolean} enabled
8190
*/
8291
this.enabled = false;
83-
8492
/**
8593
* Input amplitude, connect to it by default but not to master out
86-
*
8794
* @property {p5.Amplitude} amplitude
8895
*/
8996
this.amplitude = new Amplitude();

0 commit comments

Comments
 (0)