frequency modulation
@author
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
Minim minim;
AudioOutput out;
Oscil src, mod;
void setup(){
size(512, 200);
minim = new Minim(this);
out = minim.getLineOut();
src = new Oscil(440, 0.5, Waves.SINE);
mod = new Oscil(100, 100, Waves.SINE);
mod.offset.setLastValue(600);
mod.patch(src.frequency);
src.patch(out);
}
void mouseMoved(){
float modFreq = map(mouseX, 0, width, 1, 1000);
mod.setFrequency(modFreq);
float modDepth = map(mouseY, 0, height, 1, 300);
mod.setAmplitude(modDepth);
}
void draw(){
background(0);
stroke(255);
for(int i = 0; i < out.bufferSize() - 1; i++){
line(i, 50 + out.left.get(i) * 50, i + 1, 50 + out.left.get(i + 1) * 50);
line(i, 150 + out.right.get(i) * 50, i + 1, 150 + out.right.get(i + 1) * 50);
}
}