Reference+
Class Name
Sound
Description
This class can be used for configuring the Processing Sound library. The Sound class allows for configuring global properties of the sound library's audio synthesis and playback, such as the output device, sample rate or global output volume. Information on available input and output devices can be obtained by calling Sound.list()
Examples
import processing.sound.*; Sound s; void setup() { size(200, 200); // Play two sine oscillators with slightly different frequencies for a nice "beat". SinOsc sin = new SinOsc(this); sin.play(200, 0.2); sin = new SinOsc(this); sin.play(205, 0.2); // Create a Sound object for globally controlling the output volume. s = new Sound(this); } void draw() { // Map vertical mouse position to volume. float amplitude = map(mouseY, 0, height, 0.4, 0.0); // Instead of setting the volume for every oscillator individually, we can just // control the overall output volume of the whole Sound library. s.volume(amplitude); }
Constructors
Sound(parent)
Sound(parent, sampleRate, outputDevice, inputDevice, volume)
Parameters
parent
(PApplet)
typically use "this"sampleRate
(int)
the sample rate to be used by the synthesis engine (default 44100)outputDevice
(int)
the device id of the sound card that sound should be played oninputDevice
(int)
the device id of the sound card from which sound should be capturedvolume
(float)
the overall output volume of the library (default 1.0)
Methods
list()
Shows information about available audio devicessampleRate()
Get or set the internal sample rate of the synthesis engine.inputDevice()
Choose the device (sound card) which should be used for grabbing audio input using AudioIn.outputDevice()
Choose the device (sound card) which the Sound library's audio output should be sent to.volume()
Set the overall output volume of the Processing sound library.status()
Prints information about the sound library's current memory and CPU usage
Related
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.