Added sound library

This commit is contained in:
wirsing
2014-06-27 18:19:09 -07:00
parent b336330ce2
commit 678fc45e53
104 changed files with 8672 additions and 0 deletions
@@ -0,0 +1,29 @@
/*
This is a simple WhiteNoise generator. It can be started with .play(float amp).
In this example it is started and stopped by clicking into the renderer window.
*/
import processing.sound.*;
Sound stream;
WhiteNoise noise;
float amp=0.0;
void setup() {
size(350,350);
background(255);
// Create and start the sound renderer and the noise generator
stream = new Sound(this);
noise = new WhiteNoise(this);
noise.play();
}
void draw() {
// Map mouseX from 0.0 to 1.0 for amplitude
noise.amp(map(mouseX, 0, 350, 0.0, 1.0));
// Map mouseY from -1.0 to 1.0 for left to right
noise.pan(map(mouseY, 0, 350, -1.0, 1.0));
}
@@ -0,0 +1,33 @@
/*
This is a pulse-wave oscillator. The method .play() starts the oscillator.
There are several setters like .amp(), .freq(), .width(), .pan() and .add().
If you want to set all of them at the same time use
.set(float freq, float width, float amp, float add, float pan)
*/
import processing.sound.*;
Sound stream;
Pulse pulse;
void setup() {
size(350,350);
background(255);
// Create and start the sound renderer and the pulse wave oscillator
stream = new Sound(this);
pulse = new Pulse(this);
pulse.play();
}
void draw() {
// Map mouseX from 20Hz to 500Hz for frequency
pulse.freq(map(mouseX, 0, width, 20.0, 500.0));
// Map mouseX from 0.0 to 0.5 for amplitude
pulse.pan(map(mouseX, 0, width, -1.0, 1.0));
// Map mouseY from 0.0 to 0.5 for amplitude
pulse.amp(map(mouseY, 0, height, 0.0, 0.5));
// Map mouseY from 0.0 to 0.5 for amplitude
pulse.width(map(mouseY, 0, height, 0.0, 1.0));
}
@@ -0,0 +1,36 @@
/*
This is a saw-wave oscillator. The method .play() starts the oscillator. There
are several setters like .amp(), .freq(), .pan() and .add(). If you want to set all of them at
the same time use .set(float freq, float amp, float add, float pan)
*/
import processing.sound.*;
Sound stream;
SawOsc saw;
void setup() {
size(350,350);
background(255);
// Create and start the sound renderer and the sine oscillator.
// Second and Third arguments are optional, default is 44100 / 512
// for Sample Rate and Buffer Size
stream = new Sound(this, 44100, 256);
saw = new SawOsc(this);
//Start the Sine Oscillator. There will be no sound in the beginning
//unless the mouse enters the
saw.play();
}
void draw() {
// Map mouseY from 0.0 to 1.0 for amplitude
saw.amp(map(mouseY, 0, height, 1.0, 0.0));
// Map mouseX from 20Hz to 1000Hz for frequency
saw.freq(map(mouseX, 0, width, 80.0, 200.0));
// Map mouseX from -1.0 to 1.0 for left to right
saw.pan(map(mouseX, 0, width, -1.0, 1.0));
}
@@ -0,0 +1,43 @@
/*
This is a sine-wave oscillator. The method .play() starts the oscillator. There
are several setters like .amp(), .freq(), .pan() and .add(). If you want to set all of them at
the same time use .set(float freq, float amp, float add, float pan)
*/
import processing.sound.*;
Sound stream;
SinOsc sine;
float freq=400;
float amp=0.5;
float pos;
void setup() {
size(350,350);
background(255);
// Create and start the sound renderer and the sine oscillator.
// Second and Third arguments are optional, default is 44100 / 512
// for Sample Rate and Buffer Size
stream = new Sound(this, 44100, 256);
sine = new SinOsc(this);
//Start the Sine Oscillator.
sine.play();
}
void draw() {
// Map mouseY from 0.0 to 1.0 for amplitude
amp=map(mouseY, 0, height, 1.0, 0.0);
sine.amp(amp);
// Map mouseX from 20Hz to 1000Hz for frequency
freq=map(mouseX, 0, width, 80.0, 1000.0);
sine.freq(freq);
// Map mouseX from -1.0 to 1.0 for left to right
pos=map(mouseX, 0, width, -1.0, 1.0);
sine.pan(pos);
}
@@ -0,0 +1,36 @@
/*
This is a saw-wave oscillator. The method .play() starts the oscillator. There
are several setters like .amp(), .freq(), .pan() and .add(). If you want to set all of them at
the same time use .set(float freq, float amp, float add, float pan)
*/
import processing.sound.*;
Sound stream;
SqrOsc sqr;
void setup() {
size(350,350);
background(255);
// Create and start the sound renderer and the sine oscillator.
// Second and Third arguments are optional, default is 44100 / 512
// for Sample Rate and Buffer Size
stream = new Sound(this, 44100, 256);
sqr = new SqrOsc(this);
//Start the Sine Oscillator. There will be no sound in the beginning
//unless the mouse enters the
sqr.play();
}
void draw() {
// Map mouseY from 0.0 to 1.0 for amplitude
sqr.amp(map(mouseY, 0, height, 1.0, 0.0));
// Map mouseX from 20Hz to 1000Hz for frequency
sqr.freq(map(mouseX, 0, width, 80.0, 200.0));
// Map mouseX from -1.0 to 1.0 for left to right
sqr.pan(map(mouseX, 0, width, -1.0, 1.0));
}
@@ -0,0 +1,36 @@
/*
This is a saw-wave oscillator. The method .play() starts the oscillator. There
are several setters like .amp(), .freq(), .pan() and .add(). If you want to set all of them at
the same time use .set(float freq, float amp, float add, float pan)
*/
import processing.sound.*;
Sound stream;
TriOsc tri;
void setup() {
size(350,350);
background(255);
// Create and start the sound renderer and the sine oscillator.
// Second and Third arguments are optional, default is 44100 / 512
// for Sample Rate and Buffer Size
stream = new Sound(this, 44100, 256);
tri = new TriOsc(this);
//Start the Sine Oscillator. There will be no sound in the beginning
//unless the mouse enters the
tri.play();
}
void draw() {
// Map mouseY from 0.0 to 1.0 for amplitude
tri.amp(map(mouseY, 0, height, 1.0, 0.0));
// Map mouseX from 20Hz to 1000Hz for frequency
tri.freq(map(mouseX, 0, width, 80.0, 1000.0));
// Map mouseX from -1.0 to 1.0 for left to right
tri.pan(map(mouseX, 0, width, -1.0, 1.0));
}