defaulted start values for SoundObject

updated + reorganized examples
changed process() to analyze for analyzers
changed play() to process() for effects
This commit is contained in:
wirsing
2014-06-27 19:26:15 -07:00
parent 3ad8315ffd
commit 3f470bfb2b
42 changed files with 63 additions and 69 deletions

View File

@@ -13,7 +13,7 @@ Amplitude rms;
int scale=1;
public void setup() {
size(350,350);
size(640,360);
// Create and start the sound renderer
stream = new Sound(this, 44100, 512);
@@ -30,7 +30,7 @@ public void setup() {
public void draw() {
background(125,255,125);
// rms.process() return a value between 0 and 1. To adjust
// rms.analyze() return a value between 0 and 1. To adjust
// the scaling and mapping of an ellipse we scale from 0 to 0.5
scale=int(map(rms.process(), 0, 0.5, 1, 350));
noStroke();

View File

@@ -13,10 +13,10 @@ FFT fft;
int scale=1;
int bands=512;
float[] spec = new float[bands];
float[] spectrum = new float[bands];
public void setup() {
size(bands,350);
size(bands,360);
background(255);
// Create and start the sound renderer
@@ -35,7 +35,7 @@ public void setup() {
public void draw() {
background(255);
fft.process(spec);
fft.analyze(spectrum);
for(int i = 0; i < bands; i++)
{
@@ -44,4 +44,3 @@ public void draw() {
line( i, height, i, height - spec[i]*height*5 );
}
}

View File

@@ -34,7 +34,7 @@ int trigger = millis();
int note=0;
void setup() {
size(200, 200);
size(640, 360);
background(255);
//Create and start the Sound renderer

View File

@@ -17,7 +17,7 @@ int value[] = {0,0,0};
void setup(){
size(500, 500);
size(640, 360);
background(255);
// Create a Sound renderer and an array of empty soundfiles
@@ -43,9 +43,8 @@ void draw(){
void keyPressed() {
for (int i=0; i < 3; i++) {
value[i]=int(random(255));
};
}
switch(key){
case 'a':
file[0].play(0.5, 1.0);

View File

@@ -24,11 +24,11 @@ int[] playSound = {1,1,1,1,1};
int trigger;
// This array holds the pixel positions of the rectangles which are drawn each event
int[] posx = {0, 100, 200, 300, 400};
int[] posx = {0, 128, 256, 384, 512};
void setup(){
size(500, 300);
size(640, 360);
background(255);
// Create a Sound renderer and an array of empty soundfiles
@@ -63,7 +63,7 @@ void draw(){
fill(int(random(255)),int(random(255)),int(random(255)));
noStroke();
// Draw the rect in the positions we defined earlier in posx
rect(posx[i], 50, 100, 200);
rect(posx[i], 50, 128, 260);
// Choose a random index of the octave array
rate = octave[int(random(0,5))];
// Play the soundfile from the array with the respective rate and loop set to false
@@ -72,7 +72,7 @@ void draw(){
// Renew the indexes of playSound so that at the next event the order is different and randomized.
playSound[i] = int(random(0,2));
};
}
// Create a new triggertime in the future, with a random offset between 200 and 1000 milliseconds
trigger = millis() + int(random(200,1000));

View File

@@ -16,7 +16,7 @@ int bands=512;
float[] spec = new float[bands];
public void setup() {
size(bands,350);
size(bands,360);
background(255);
// Create and start the sound renderer
@@ -35,7 +35,7 @@ public void setup() {
public void draw() {
background(255);
fft.process(spec);
fft.analyze(spec);
for(int i = 0; i < bands; i++)
{
@@ -44,4 +44,3 @@ public void draw() {
line( i, height, i, height - spec[i]*height*5 );
}
}

View File

@@ -12,7 +12,7 @@ BPF bandPass;
float amp=0.0;
void setup() {
size(350,350);
size(640,360);
background(255);
// Create and start the sound renderer and the noise generator
@@ -20,7 +20,7 @@ void setup() {
noise = new WhiteNoise(this);
bandPass = new BPF(this);
noise.play(0.5);
bandPass.play(noise, 100);
bandPass.process(noise, 100);
}
void draw() {

View File

@@ -12,7 +12,7 @@ HPF highPass;
float amp=0.0;
void setup() {
size(350,350);
size(640,360);
background(255);
// Create and start the sound renderer and the noise generator
@@ -20,7 +20,7 @@ void setup() {
noise = new WhiteNoise(this);
highPass = new HPF(this);
noise.play(0.5);
highPass.play(noise, 100);
highPass.process(noise, 100);
}
void draw() {

View File

@@ -13,7 +13,7 @@ LPF lowPass;
float amp=0.0;
void setup() {
size(350,350);
size(640,360);
background(255);
// Create and start the sound renderer and the noise generator
@@ -21,10 +21,9 @@ void setup() {
noise = new WhiteNoise(this);
lowPass = new LPF(this);
noise.play(0.5);
lowPass.play(noise, 100);
lowPass.process(noise, 100);
}
void draw() {
lowPass.freq(map(mouseX, 0, 350, 20, 10000));
}

View File

@@ -9,7 +9,7 @@ SoundFile soundfile;
Delay delay;
void setup() {
size(350,350);
size(640,360);
background(255);
// Create and start the sound renderer
@@ -30,24 +30,24 @@ void setup() {
soundfile.loop();
// Patch the delay
delay.play(soundfile, 5);
delay.process(soundfile, 5);
}
void draw() {
// Map mouseX from 0.25 to 4.0 for playback rate. 1 equals original playback
// speed 2 is an octave up 0.5 is an octave down.
soundfile.rate(map(mouseX, 0, 350, 0.25, 4.0));
soundfile.rate(map(mouseX, 0, width, 0.25, 4.0));
// Map mouseY from 0.2 to 1.0 for amplitude
soundfile.amp(map(mouseY, 0, 350, 0.2, 1.0));
soundfile.amp(map(mouseY, 0, width, 0.2, 1.0));
// Map mouseY from -1.0 to 1.0 for left to right
soundfile.pan(map(mouseY, 0, 350, -1.0, 1.0));
soundfile.pan(map(mouseY, 0, width, -1.0, 1.0));
// Map mouseY from 0.001 to 2.0 seconds for the delaytime
delay.time(map(mouseY, 0, 350, 0.001, 2.0));
delay.time(map(mouseY, 0, width, 0.001, 2.0));
// Map mouseX from 0 to 0.8 for the delay feedback
delay.feedback(map(mouseX, 0, 350, 0.0, 0.8));
delay.feedback(map(mouseX, 0, width, 0.0, 0.8));
}

View File

@@ -11,7 +11,7 @@ WhiteNoise noise;
float amp=0.0;
void setup() {
size(350,350);
size(640, 360);
background(255);
// Create and start the sound renderer and the noise generator
@@ -22,8 +22,8 @@ void setup() {
void draw() {
// Map mouseX from 0.0 to 1.0 for amplitude
noise.amp(map(mouseX, 0, 350, 0.0, 1.0));
noise.amp(map(mouseX, 0, width, 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));
noise.pan(map(mouseY, 0, width, -1.0, 1.0));
}

View File

@@ -11,7 +11,7 @@ Sound stream;
Pulse pulse;
void setup() {
size(350,350);
size(640,360);
background(255);
// Create and start the sound renderer and the pulse wave oscillator
@@ -30,4 +30,3 @@ void draw() {
// Map mouseY from 0.0 to 0.5 for amplitude
pulse.width(map(mouseY, 0, height, 0.0, 1.0));
}

View File

@@ -10,7 +10,7 @@ Sound stream;
SawOsc saw;
void setup() {
size(350,350);
size(640, 360);
background(255);
// Create and start the sound renderer and the sine oscillator.

View File

@@ -14,7 +14,7 @@ float amp=0.5;
float pos;
void setup() {
size(350,350);
size(640, 360);
background(255);
// Create and start the sound renderer and the sine oscillator.

View File

@@ -10,7 +10,7 @@ Sound stream;
SqrOsc sqr;
void setup() {
size(350,350);
size(640,360);
background(255);
// Create and start the sound renderer and the sine oscillator.

View File

@@ -10,7 +10,7 @@ Sound stream;
TriOsc tri;
void setup() {
size(350,350);
size(640,360);
background(255);
// Create and start the sound renderer and the sine oscillator.

View File

@@ -9,7 +9,7 @@ Sound stream;
SoundFile soundfile;
void setup() {
size(350,350);
size(640,360);
background(255);
// Create and start the sound renderer
@@ -31,12 +31,11 @@ void setup() {
void draw() {
// Map mouseX from 0.25 to 4.0 for playback rate. 1 equals original playback
// speed 2 is an octave up 0.5 is an octave down.
soundfile.rate(map(mouseX, 0, 350, 0.25, 4.0));
soundfile.rate(map(mouseX, 0, width, 0.25, 4.0));
// Map mouseY from 0.2 to 1.0 for amplitude
soundfile.amp(map(mouseY, 0, 350, 0.2, 1.0));
soundfile.amp(map(mouseY, 0, width, 0.2, 1.0));
// Map mouseY from -1.0 to 1.0 for left to right
soundfile.pan(map(mouseY, 0, 350, -1.0, 1.0));
soundfile.pan(map(mouseY, 0, width, -1.0, 1.0));
}

View File

@@ -17,7 +17,7 @@ public class Amplitude {
ptr = m_engine.amplitude(input.returnId());
}
public float process(){
public float analyze(){
return m_engine.poll_amplitude(ptr);
}
/*

View File

@@ -17,12 +17,12 @@ public class BPF implements SoundObject{
m_engine = new MethClaInterface();
}
public void play(SoundObject input, float freq, float res){
public void process(SoundObject input, float freq, float res){
m_freq=freq; m_res=res;
m_nodeId = m_engine.bandPassPlay(input.returnId(), m_freq, m_res);
}
public void play(SoundObject input, float freq){
public void process(SoundObject input, float freq){
m_freq=freq;
m_nodeId = m_engine.bandPassPlay(input.returnId(), m_freq, m_res);
}

View File

@@ -18,17 +18,17 @@ public class Delay implements SoundObject{
m_engine = new MethClaInterface();
}
public void play(SoundObject input, float maxDelayTime, float delayTime, float feedBack){
public void process(SoundObject input, float maxDelayTime, float delayTime, float feedBack){
m_maxDelayTime=maxDelayTime; m_delayTime=delayTime; m_feedBack=feedBack;
m_nodeId = m_engine.delayPlay(input.returnId(), m_maxDelayTime, m_delayTime, m_feedBack);
}
public void play(SoundObject input, float maxDelayTime, float delayTime){
public void process(SoundObject input, float maxDelayTime, float delayTime){
m_maxDelayTime=maxDelayTime; m_delayTime=delayTime;
m_nodeId = m_engine.delayPlay(input.returnId(), m_maxDelayTime, m_delayTime, m_feedBack);
}
public void play(SoundObject input, float maxDelayTime){
public void process(SoundObject input, float maxDelayTime){
m_maxDelayTime=maxDelayTime;
m_nodeId = m_engine.delayPlay(input.returnId(), m_maxDelayTime, m_delayTime, m_feedBack);
}

View File

@@ -17,7 +17,7 @@ public class FFT {
ptr = m_engine.fft(input.returnId(), fftSize);
}
public void process(float[] value){
public void analyze(float[] value){
float[] m_value = m_engine.poll_fft(ptr);
int num_samples = Math.min(value.length, m_value.length);
for(int i=0; i<num_samples; i++){

View File

@@ -17,12 +17,12 @@ public class HPF implements SoundObject{
m_engine = new MethClaInterface();
}
public void play(SoundObject input, float freq, float res){
public void process(SoundObject input, float freq, float res){
m_freq=freq; m_res=res;
m_nodeId = m_engine.highPassPlay(input.returnId(), m_freq, m_res);
}
public void play(SoundObject input, float freq){
public void process(SoundObject input, float freq){
m_freq=freq;
m_nodeId = m_engine.highPassPlay(input.returnId(), m_freq, m_res);
}

View File

@@ -17,12 +17,12 @@ public class LPF implements SoundObject{
m_engine = new MethClaInterface();
}
public void play(SoundObject input, float freq, float res){
public void process(SoundObject input, float freq, float res){
m_freq=freq; m_res=res;
m_nodeId = m_engine.lowPassPlay(input.returnId(), m_freq, m_res);
}
public void play(SoundObject input, float freq){
public void process(SoundObject input, float freq){
m_freq=freq;
m_nodeId = m_engine.lowPassPlay(input.returnId(), m_freq, m_res);
}

View File

@@ -7,9 +7,9 @@ public class Pulse implements SoundObject {
PApplet parent;
MethClaInterface m_engine;
private int[] m_nodeId = {-1,-1};
private float m_freq = 0;
private float m_width = 0;
private float m_amp = 0;
private float m_freq = 440;
private float m_width = 0.5;
private float m_amp = 0.5;
private float m_add = 0;
private float m_pos = 0;

View File

@@ -7,8 +7,8 @@ public class SawOsc implements Oscillator{
PApplet parent;
private MethClaInterface m_engine;
private int[] m_nodeId = {-1,-1};
private float m_freq = 0;
private float m_amp = 0;
private float m_freq = 440;
private float m_amp = 0.5;
private float m_add = 0;
private float m_pos = 0;

View File

@@ -6,8 +6,8 @@ public class SinOsc implements Oscillator {
PApplet parent;
private MethClaInterface m_engine;
private int[] m_nodeId = {-1,-1};
private float m_freq = 0;
private float m_amp = 0;
private float m_freq = 440;
private float m_amp = 0.5;
private float m_add = 0;
private float m_pos = 0;

View File

@@ -7,8 +7,8 @@ public class SqrOsc implements SoundObject {
PApplet parent;
MethClaInterface m_engine;
private int[] m_nodeId = {-1,-1};
private float m_freq = 0;
private float m_amp = 0;
private float m_freq = 440;
private float m_amp = 0.5;
private float m_add = 0;
private float m_pos = 0;

View File

@@ -7,8 +7,8 @@ public class TriOsc implements Oscillator{
PApplet parent;
private MethClaInterface m_engine;
private int[] m_nodeId = {-1,-1};
private float m_freq = 0;
private float m_amp = 0;
private float m_freq = 440;
private float m_amp = 0.5;
private float m_add = 0;
private float m_pos = 0;

View File

@@ -6,7 +6,7 @@ public class WhiteNoise implements SoundObject{
PApplet parent;
private MethClaInterface m_engine;
private int[] m_nodeId = {-1,-1};
private float m_amp=0;
private float m_amp=0.5;
private float m_add=0;
private float m_pos=0;