Extend p5.js with Web Audio functionality including audio input, playback, analysis and synthesis.
Looking for the main p5.js reference? Go to the reference!
isDetected is set to true when a peak is detected.
Create a p5.Convolver.
Returns the closest MIDI note value for a given frequency.
Returns the Audio Context for this sketch.
Returns a number representing the output volume for sound in this sketch.
loadSound() returns a new p5.SoundFile from a specified path.
Returns the frequency value of a MIDI note value.
Scale the output of all sound in this sketch Scaled between 0.0 (silence) and 1.0 (full volume).
Returns a number representing the sample rate, in samples per second, of all sound objects in this audio context.
Save a p5.SoundFile as a .wav file.
Set the global tempo, in beats per minute, for all p5.Parts.
List the SoundFile formats that you will include.
p5.soundOut is the p5.sound final output bus.
It is not only a good practice to give users control over starting audio.
Get the current amplitude value of a sound.
Connect an audio source to the amplitude object.
Determines whether the results of Amplitude.process() will be Normalized.
Set amplitude (volume) of a mic input between 0 and 1.0.
Input amplitude, connect to it by default but not to master out
Connect to an audio unit.
Disconnect the AudioIn from all audio units.
Client must allow browser to access their microphone / audioin source.
Read the Amplitude (volume level) of an AudioIn.
Returns a list of available input sources.
Set the input source.
Start the audio input.
Stop the audio input.
Connect to p5 objects or Web Audio Nodes
Disconnect from soundOut
Set the cutoff frequency of the filter.
The gain of the filter in dB units.
The filter's resonance factor.
Set the type of the filter.
Get current attack or set value w/ time ramp
The p5.Compressor is built with a Web Audio Dynamics Compressor Node
Get current knee or set value w/ time ramp
Performs the same function as .connect, but also accepts optional parameters to set compressor's audioParams
Get current ratio or set value w/ time ramp
Return the current reduction value
Get current release or set value w/ time ramp
Set the paramters of a compressor.
Get current threshold or set value w/ time ramp
Load and assign a new Impulse Response to the p5.Convolver.
Internally, the p5.Convolver uses the a Web Audio Convolver Node.
If you load multiple impulse files using the .addImpulse method, they will be stored as Objects in this Array.
Connect a source to the convolver.
Similar to .addImpulse, except that the .impulses Array is reset to save memory.
If you have used .addImpulse() to add multiple impulses to a p5.Convolver, then you can use this method to toggle between the items in the .impulses Array.
Adjust the amplitude of the delay effect.
Send output to a p5.sound or web audio object
Set the delay time in seconds.
Disconnect all output.
The amount of feedback in the delay line.
Set a lowpass filter frequency for the delay.
The p5.Delay is built with two Web Audio Delay Nodes, one for each stereo channel.
Process an input signal with a delay effect.
Choose a preset type of delay.
The p5.Distortion is built with a Web Audio WaveShaper Node.
Return the distortion amount, typically between 0-1.
Return the oversampling.
Process a sound source, optionally specify amount and oversample values.
Set the amount and oversample of the waveshaper distortion.
The p5.EQ is built with abstracted p5.Filter objects.
Process an input by connecting it to the EQ
Set the output volume of the filter.
Link effects together in a chain Example usage: filter.chain(reverb, delay, panner); May be used with an open-ended number of arguments
Send output to a p5.js-sound, Web Audio Node, or use signal to control an AudioParam
Adjust the dry/wet value.
Add a value to the p5.Oscillator's output amplitude, and return the oscillator.
Level once attack is complete.
Sets the attack time of the envelope.
Level after decay.
Time until envelope reaches decayLevel.
Multiply the p5.Envelope's output amplitude by a fixed value.
Trigger the envelope and release it after the sustain time.
Exponentially ramp to a value using the first two values from setADSR(attackTime, decayTime) as time constants for simple exponential ramps.
Level at the end of the release.
Sets the release time of the envelope.
Scale this envelope's amplitude values to a given range, and return the envelope.
Reset the envelope with a series of time/value pairs.
Sets the attack, decay, sustain, and release times of the envelope.
Set whether the envelope ramp is linear (default) or exponential.
Set max (attackLevel) and min (releaseLevel) of envelope.
Trigger the Attack, and Decay portion of the Envelope.
Trigger the Release of the envelope.
Returns the frequency spectrum of the input signal.
Returns the spectral centroid of the input signal.
Returns the amount of energy (volume) at a specific frequency, or the average amount of energy between two frequencies.
Calculates and Returns the 1/N Octave Bands N defaults to 3 and minimum central frequency to 15.625Hz.
Returns an array of average amplitude values for a given number of frequency bands split equally.
Returns an array of average amplitude values of the spectrum, for a given set of Octave Bands NOTE: analyze() must be called prior to logAverages().
Set the input source for the FFT analysis.
Smooth FFT analysis by averaging with the last analysis frame.
Returns an array of sample values from the input audio.
The p5.Filter is built with a Web Audio BiquadFilter Node.
Set the filter frequency, in Hz, from 10 to 22050 (the range of human hearing, although in reality most people hear in a narrower range).
Controls the gain attribute of a Biquad Filter.
Filter an audio signal according to a set of filter parameters.
Controls either width of a bandpass frequency, or the resonance of a low/highpass cutoff frequency.
Set the frequency and the resonance of the filter.
Set the type of a p5.Filter.
Toggle function.
Adjust the amplitude of the soundfile.
Connect a source to the gain node.
MonoSynth amp
Getters and Setters
Connect to a p5.sound / Web Audio object.
Disconnect all outputs
Get rid of the MonoSynth and free up its resources / memory.
Play tells the MonoSynth to start playing a note.
Set values like a traditional ADSR envelope .
Trigger the release of the Envelope.
Adjust the amplitude of the noise source.
Set type of noise to 'white', 'pink' or 'brown'.
Starts the noise source.
Stops the noise source.
Adjust the amplitude of the Oscillator.
Adjusts the frequency of the oscillator.
Returns the value of output gain
Returns the value of frequency of oscillator
Returns the current value of panPosition , between Left (-1) and Right (1)
Returns current type of oscillator eg.
Multiply the p5.Oscillator's output amplitude by a fixed value (i.e.
Pan between Left (-1) and Right (1)
Adjusts the phase of the oscillator.
Scale this oscillator's amplitude values to a given range, and return the oscillator.
Sets the type of the oscillator.
Starts the oscillator.
Stops the oscillator.
Pan a sound source left or right.
Set the maximum distance of the panner.
Set the X,Y,Z position of the Panner
Getter and setter methods for orient coordinates
Web Audio Spatial Panner Node Properties include Panning Model : "equal power" or "HRTF" DistanceModel : "linear", "inverse", or "exponential"
Set the X position of the sound source.
Set the Y position of the sound source.
Set the Z position of the sound source.
Connects an input source to the 3D panner.
How quickly the volume is reduced as the source moves away from the listener
Set the rolloff rate of the panner.
Set the x, y, and z position of the 3D panner.
The rolloff rate of the panner.
Add a p5.Phrase to this Part.
Returns the tempo, in Beats Per Minute, of this part.
Get a phrase from this part, based on the name it was given when it was created.
Loop playback of this part.
Tell the part to stop looping.
Set the function that will be called at every step.
Pause the part.
Remove a phrase from this part, based on the name it was given when it was created.
Find all sequences with the specified name, and replace their patterns with the specified array.
Set the tempo of this part, in Beats Per Minute.
Start playback of this part.
Stop the part and cue it to step 0.
onPeak accepts two arguments: a function to call when a peak is detected.
The update method is run in the draw loop.
Array of values to pass into the callback at each step of the phrase.
Shift the pitch of the source audio.
Monosynth that generates the sound for each note that is triggered.
noteADSR sets the envelope for a specific note that has just been triggered.
Trigger the Attack, and Decay portion of a MonoSynth.
Trigger the Release of an AudioVoice note.
An object that holds information about which notes have been played and which notes are currently being played.
Play a note by triggering noteAttack and noteRelease with sustain time
A PolySynth must have at least 1 voice, defaults to 8
Set the PolySynths global envelope.
Set the width of a Pulse object (an oscillator that implements Pulse Width Modulation).
Set the output level of the reverb effect.
Connect a source to the reverb, and assign reverb parameters.
Set the decay time of the reverb.
Loop playback of the score.
Stop looping playback of the score.
Pause playback of the score.
Set the tempo for all parts in the score
Start playback of the score.
Stop playback of the score.
Schedule events to trigger every time a MediaElement (audio/video) reaches a playback cue point.
Gets the number of channels in the sound file.
Remove all of the callbacks that had originally been scheduled via the addCue method.
Connects the output of a p5sound object to input of another p5.sound object.
Return the current position of the p5.SoundFile playhead, in seconds.
Disconnects the output of this p5sound object.
Returns the duration of a sound file in seconds.
Return the number of samples in a sound file.
This method is useful for sending a SoundFile to a server.
Returns the current stereo pan position (-1.0 to 1.0)
Returns an array of amplitude peaks in a p5.SoundFile that can be used to draw a static waveform.
Returns true if the sound file finished loading successfully.
Return the playback state of the soundfile.
Returns true if a p5.SoundFile is paused, false if not (i.e.
Move the playhead of a soundfile that is currently playing to a new position.
Loop the soundfile.
Define a function to call when the soundfile is done playing.
Set the stereo panning of a p5.sound object to a floating point number between -1.0 (left) and 1.0 (right).
Pause the soundfile.
Start the soundfile.
p5.SoundFile has two play modes: restart and sustain.
Set the playback rate of the soundfile.
Remove a callback based on its ID.
Reverses the p5.SoundFile's buffer source.
Replace the current Audio Buffer with a new Buffer.
Set a loop region, and optionally a playback rate, and amplitude for the soundfile.
Change the path for the soundfile.
Multiply the output volume (amplitude) of a sound file between 0.0 (silence) and 1.0 (full volume).
Stop the soundfile.
Getters and Setters, setting any paramter will result in a change in the clock's frequency, that will be reflected after the next callback beats per minute (defaults to 60)
length of the loops interval
how many times the callback has been called so far
Set a limit to the number of loops to play.
musicalTimeMode uses Tone.Time convention true if string, false if number
Pause the loop
Start the loop
Stop the loop
Synchronize loops.
number of quarter notes in a measure (defaults to 4)
Start recording.
Connect a specific device to the p5.SoundRecorder.
Stop the recording.
Looking for the old p5.js site? Find it here!