Reference p5.AudioIn

p5.AudioIn

Get sound from an input source, typically a computer microphone.

Examples

Fields

enabled

Client must allow browser to access their microphone / audioin source. Default: false. Will become true when the client enables access.

amplitude

Input amplitude, connect to it by default but not to master out

Methods

start
Start the audio input.
stop
Stop the audio input.
connect

Connect to an audio unit. If no parameter is provided, will connect to the main output (i.e. your speakers).

disconnect

Disconnect the AudioIn from all audio units. For example, if connect() had been called, disconnect() will stop sending signal to your speakers.

getLevel

Read the Amplitude (volume level) of an AudioIn. The AudioIn class contains its own instance of the Amplitude class to help make it easy to get a microphone's volume level. Accepts an optional smoothing value (0.0 < 1.0). NOTE: AudioIn must .start() before using .getLevel().

amp
Set amplitude (volume) of a mic input between 0 and 1.0.
getSources

Returns a list of available input sources. This is a wrapper for MediaDevices.enumerateDevices() - Web APIs | MDN and it returns a Promise.

setSource

Set the input source. Accepts a number representing a position in the array returned by getSources(). This is only available in browsers that support navigator.mediaDevices.enumerateDevices()

Notice any errors or typos? Please let us know. Please feel free to edit src/AudioIn.js and open a pull request!

Related References