Sound

The new Sound library for Processing 3 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+.

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.

  • stop()

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.

  • 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 and returns it as an array with as many elements as frequency bands.

  • input()

    Define the audio input for the analyzer.

  • stop()

    Stops the FFT.

Waveform

  • Waveform

    This is a Waveform analyzer.

  • 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.

  • add()

    The .add() method is useful for modulating other audio signals.

  • amp()

    Changes the amplitude/volume of the input stream.

  • pan()

    Pan the input stream in a stereo panorama.

  • play()

    Start capturing the input stream and route it to the audio output

  • set()

    Sets amplitude, add and pan position with one method.

  • start()

    Start the input stream without routing it to the audio output.

  • stop()

    Stops the Input Stream.

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()

    Jump to a specific position in the audiosample while continuing to play (or starting to play if it wasn't playing already).

  • 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.

  • add()

    Offset the output of the player by the given value.

  • 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.

  • set()

    Set multiple playback parameters of the soundfile at once.

  • stop()

    Stops the playback.

Effects

BandPass

  • BandPass

    This is a band pass filter.

  • bw()

    Set the bandwidth for the filter.

  • freq()

    Set the cutoff frequency for the filter.

  • process()

    Start the filter.

  • set()

    Sets frequency and bandwidth of the filter with one method.

  • stop()

    Stops the filter.

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()

    Stops the effect.

  • time()

    Changes the delay time of the effect.

HighPass

LowPass

  • LowPass

    This is a low pass filter.

  • freq()

    Set the cut off frequency for the filter.

Reverb

  • Reverb

    This is a simple reverb effect.

  • damp()

    Changes the damping factor of the reverb effect.

  • process()

    Start the filter.

  • room()

    Change the room size of the reverb effect.

  • set()

    Set multiple parameters of the reverb.

  • stop()

    Stops the reverb.

  • wet()

    Change the wet/dry ratio of the reverb.

Noise

BrownNoise

  • BrownNoise

    This is a brown noise generator.

  • add()

    Offset the output of this generator by a fixed value.

  • amp()

    Changes the amplitude/volume of the noise generator.

  • pan()

    Pan the generator in a stereo panorama.

  • play()

    Start the generator.

  • set()

    Sets amplitude, add and pan position with one method.

  • stop()

    Stops the Brown Noise generator.

PinkNoise

  • PinkNoise

    This is a pink noise generator.

  • add()

    Offset the output of this generator by a fixed value.

  • amp()

    Change the amplitude/volume of this sound.

  • pan()

    Pan the generator in a stereo panorama.

  • play()

    Start the generator.

  • set()

    Sets amplitude, add and pan position with one method.

  • stop()

    Stops the Pink Noise generator.

WhiteNoise

  • WhiteNoise

    This is a White Noise Generator.

  • add()

    Offset the output of this generator by a fixed value.

  • amp()

    Change the amplitude/volume of this sound.

  • pan()

    Move the sound in a stereo panorama.

  • play()

    Start the generator.

  • set()

    Set multiple parameters at once.

  • stop()

    Stop the generator.

Envelopes

Env

  • Env

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

  • play()

    Triggers the envelope.

Oscillators

Pulse

  • Pulse

    This is a simple Pulse oscillator.

  • add()

    Offset the output of this generator by given value.

  • amp()

    Changes the amplitude/volume of the pulse oscillator.

  • freq()

    Changes the frequency of the pulse oscillator in Hz.

  • pan()

    Pan the oscillator in a stereo panorama.

  • play()

    Starts the oscillator

  • set()

    Set multiple parameters at once

  • stop()

    Stops the Sine Oscillator generator.

  • width()

    Changes the pulse width of the pulse oscillator.

SawOsc

  • SawOsc

    This is a simple Saw Wave Oscillator.

  • add()

    Offset the output of this generator by given value.

  • amp()

    Changes the amplitude/volume of the saw oscillator.

  • freq()

    Set the frequency of the oscillator in Hz.

  • pan()

    Move the sound in a stereo panorama.

  • play()

    Starts the oscillator.

  • set()

    Set multiple parameters at once.

  • stop()

    Move the sound in a stereo panorama.

SinOsc

  • SinOsc

    This is a simple Sine Wave Oscillator.

  • add()

    Offset the output of this generator by given value.

  • amp()

    Changes the amplitude/volume of the sine oscillator.

  • freq()

    Set the frequency of the oscillator in Hz.

  • pan()

    Pan the oscillator in a stereo panorama.

  • play()

    Starts the oscillator.

  • set()

    Set multiple parameters at once.

  • stop()

    Stops the oscillator.

SqrOsc

  • SqrOsc

    This is a simple Square Wave Oscillator.

  • add()

    Offset the output of this generator by given value.

  • amp()

    Change the amplitude/volume of of the square oscillator.

  • freq()

    Set the frequency of the oscillator in Hz.

  • pan()

    Move the sound in a stereo panorama.

  • play()

    Starts the oscillator.

  • set()

    Set multiple parameters at once.

  • stop()

    Stop the oscillator.

TriOsc

  • TriOsc

    This is a simple triangle (or "saw") wave oscillator.

  • add()

    Offset the output of this generator by given value.

  • amp()

    Changes the amplitude/volume of the triangle oscillator.

  • freq()

    Set the frequency of the oscillator in Hz.

  • pan()

    Move the sound in a stereo panorama.

  • play()

    Starts the oscillator.

  • set()

    Set multiple parameters at once.

  • stop()

    Stop the oscillator.

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()

    Print and return information on available audio devices and their number of input/output channels.

  • 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.

  • volume()

    Set the overall output volume of the Processing sound library.