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

  • AllPass

    Outputs all input frequencies at the same amplitude but changes their phase relationship.

  • gain()

    Sets the gain for the filter.

  • process()

    Start the effect.

  • stop()

    Stop the effect.

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

  • Delay

    This is a simple delay effect.

  • feedback()

    Change the feedback of the delay effect.

  • process()

    Start the delay effect.

  • set()

    Set delay time and feedback values at once.

  • stop()

    Stop the effect.

  • time()

    Changes the delay time of the effect.

HighPass

  • HighPass

    This is a high pass filter.

  • freq()

    Sets the cutoff frequency for the filter.

  • process()

    Starts applying this 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.

LowPass

  • LowPass

    This is a low pass filter.

  • freq()

    Sets the cutoff frequency for the filter.

  • process()

    Starts applying this 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.

Reverb

  • Reverb

    This is a simple reverb effect.

  • damp()

    Changes the damping factor of the reverb effect.

  • process()

    Start the effect.

  • room()

    Change the room size of the reverb effect.

  • set()

    Set multiple parameters of the reverb.

  • stop()

    Stop the effect.

  • wet()

    Change the wet/dry ratio of the reverb.

Analysis

Amplitude

  • Amplitude

    This is a volume analyzer.

  • analyze()

    Queries a value from the analyzer and returns a float between 0. and 1.

  • input()

    Define the audio input for the analyzer.

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

  • Waveform

    Inspects the underlying soundwave of an audio signal.

  • analyze()

    Gets the content of the current audiobuffer from the input source.

  • input()

    Define the audio input for the analyzer.

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

  • BrownNoise

    Brown noise (also called red noise) has higher energy at lower frequencies.

  • amp()

    Change the amplitude/volume of this sound.

  • pan()

    Move the sound in a stereo panorama.

  • play()

    Starts the noise

  • set()

    Set the amplitude and panoramic position with one method.

  • stop()

    Stop the noise from playing back

PinkNoise

  • PinkNoise

    This is a pink noise generator.

  • amp()

    Change the amplitude/volume of this sound.

  • pan()

    Move the sound in a stereo panorama.

  • play()

    Starts the noise

  • set()

    Set the amplitude and panoramic position with one method.

  • stop()

    Stop the noise from playing back

WhiteNoise

  • WhiteNoise

    This is a White Noise Generator.

  • amp()

    Change the amplitude/volume of this sound.

  • pan()

    Move the sound in a stereo panorama.

  • play()

    Starts the noise

  • set()

    Set the amplitude and panoramic position with one method.

  • stop()

    Stop the noise from playing back

Envelopes

  • Env

    This is an ASR (Attack Sustain Release) Envelope Generator.

  • play()

    Triggers the envelope.

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

  • SawOsc

    This is a simple Saw Wave 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

SinOsc

  • SinOsc

    This is a simple Sine Wave 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

SqrOsc

  • SqrOsc

    This is a simple Square Wave 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

TriOsc

  • TriOsc

    This is a simple triangle wave 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

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.