Sound
The Sound library for Processing provides a simple way to work with audio. It can play, analyze, and synthesize sound. It provides a collection of oscillators for basic wave forms, a variety of noise generators, and effects and filters to play and alter sound files and other generated sounds. The syntax is minimal to make it easy to patch one sound object into another. The library also comes with example sketches covering many use cases to help you get started.
The source code is available on the processing-sound GitHub repository. Please report bugs here. This library is only compatible with Processing 3.0+.
Effects
AllPass
BandPass
- BandPass
This is a band pass filter.
- bw()
Sets the bandwidth for the filter.
- freq()
Sets the center frequency of the filter.
- process()
Start applying this bandpass filter to an input signal.
- res()
Sets the resonance (or 'Q factor') of this filter.
- set()
Sets frequency and bandwidth of the filter with one method.
- stop()
Stop the effect.
Delay
HighPass
LowPass
Reverb
Analysis
Amplitude
BeatDetector
- BeatDetector
Looks for spikes in the energy of an audio signal which are often associated with rhythmic musical beats and can be used to trigger a response whenever the incoming audio signal pulses.
- input()
Define the audio input for the analyzer.
- isBeat()
Returns whether or not the current moment of audio contains a beat or not.
- sensitivity()
Sets the sensitivity of the beat detector.
FFT
- FFT
This is a Fast Fourier Transform (FFT) analyzer.
- analyze()
Calculates the current frequency spectrum of the audio input signal.
- analyzeSample()
Calculates the frequency spectrum of a given audio sample.
- input()
Define the audio input for the analyzer.
PitchDetector
- PitchDetector
Detects the fundamental frequency of a sound signal
- analyze()
Detect the fundamental frequency of the input sound signal.
- input()
Define the audio input for the analyzer.
Waveform
I/O
AudioIn
- AudioIn
AudioIn lets you grab the audio input from your sound card.
- amp()
Change the amplitude/volume of this sound.
- pan()
Move the sound in a stereo panorama.
- play()
Start capturing the input stream and route it to the audio output
- set()
Set amplitude and pan position with one method.
- start()
Start the input stream without routing it to the audio output.
- stop()
Stop capturing sound from this audio input.
MultiChannel
- MultiChannel
Controls the routing of sounds on multi-channel devices
- activeChannel()
Controls which output channel sounds will be played back to. After selecting a new output channel, all sounds that start `play()`ing will be sent to that channel.
- availableChannels()
Gets the number of output channels available on an output device
- usePortAudio()
Force using PortAudio instead of JavaSound.
Sampling
AudioSample
- AudioSample
This class allows you low-level access to an audio buffer to create, access, manipulate and play back sound samples.
- amp()
Changes the amplitude/volume of the player.
- channels()
Returns the number of channels in the audiosample as an int (1 for mono, 2 for stereo).
- cue()
Cues the playhead to a fixed position in the audiosample.
- cueFrame()
Cues the playhead to a fixed position in the audiosample.
- duration()
Returns the duration of the audiosample in seconds.
- frames()
Returns the number of frames of the audiosample as an int.
- jump()
Jumps to a specific position in the audio sample.
- jumpFrame()
Jump to a specific position in the audiosample without interrupting playback.
- loop()
Starts the playback of the audiosample.
- pan()
Pan the soundfile in a stereo panorama.
- pause()
Stop the playback of the sample, but cue it to the current position.
- percent()
Get current sound file playback position in percent.
- play()
Starts the playback of the audiosample.
- playFor()
Starts the playback of the audiosample for the specified duration or to the end of the audiosample, whichever comes first.
- position()
Get current sound file playback position in seconds.
- positionFrame()
Get frame index of current sound file playback position.
- rate()
Set the relative playback rate of the audiosample.
- read()
The underlying data of the audiosample can be read and written in several different.
- resize()
Resizes the underlying buffer of the audiosample to the given number of frames.
- sampleRate()
Returns the underlying sample rate of the audiosample.
- set()
Set multiple parameters at once.
- stop()
Stops the playback.
- write()
The underlying data of the audiosample can be read and (over)written in several different ways.
SoundFile
- SoundFile
This is a Soundfile Player which allows to play back and manipulate soundfiles.
- amp()
Changes the amplitude/volume of the player.
- channels()
Returns the number of channels of the soundfile as an int (1 for mono, 2 for stereo).
- cue()
Cues the playhead to a fixed position in the soundfile.
- duration()
Returns the duration of the soundfile in seconds.
- frames()
Returns the number of frames of this soundfile.
- isPlaying()
Check whether this soundfile is currently playing.
- jump()
Jump to a specific position in the soundfile while continuing to play (or starting to play if it wasn't playing already).
- loop()
Starts playback which will loop at the end of the soundfile.
- pan()
Move the sound in a stereo panorama.
- pause()
Stop the playback of the file, but cue it to the current position.
- play()
Starts the playback of the soundfile.
- rate()
Set the playback rate of the soundfile.
- removeFromCache()
Remove this SoundFile's decoded audio sample from the cache, allowing it to be garbage collected once there are no more references to this SoundFile.
Noise
BrownNoise
PinkNoise
WhiteNoise
Envelopes
Oscillators
Pulse
- Pulse
This is a simple Pulse oscillator.
- amp()
Change the amplitude/volume of this sound.
- freq()
Sets the frequency of the oscillator.
- pan()
Move the sound in a stereo panorama.
- play()
Starts the oscillator
- set()
Set multiple parameters at once
- stop()
Stop the oscillator from playing back
- width()
Changes the pulse width of the pulse oscillator.
SawOsc
SinOsc
SqrOsc
TriOsc
Configuration
Sound
- Sound
This class can be used for configuring the Processing Sound library.
- inputDevice()
Choose the device (sound card) which should be used for grabbing audio input using AudioIn.
- list()
Shows information about available audio devices
- outputDevice()
Choose the device (sound card) which the Sound library's audio output should be sent to.
- sampleRate()
Get or set the internal sample rate of the synthesis engine.
- status()
Prints information about the sound library's current memory and CPU usage
- volume()
Set the overall output volume of the Processing sound library.