import krister.Ess.*; int numSines = 5; // Number of oscillators to use AudioStream myStream; // Audio stream to write into SineWave[] myWave; // Array of sines FadeOut myFadeOut; // Amplitude ramp function FadeIn myFadeIn; // Amplitude ramp function int mx; int my; int mx2; int my2; int hue1 = 0; int hue2 = 175; int counter = 0; int lValue; int taco = 100; PImage steez; void setup(){ size(800, 600); noStroke(); background(255,0,0); colorMode(HSB); mx = constrain (width/2, 0, width); my = constrain (height/2, 0, height); mx = constrain (width/2, 0, width); my = constrain (height/2, 0, height); Ess.start(this); // Start Ess myStream = new AudioStream(); // Create a new AudioStream myStream.smoothPan = true; myWave = new SineWave[numSines]; // Initialize the oscillators for (int i = 0; i < myWave.length; i++) { float sinVolume = (1.0 / myWave.length) / (i + 1); myWave[i] = new SineWave(0, sinVolume); } myStream.start(); // Start audio } void draw(){ houndsTooth(mx, my, .5, hue1); if(random(1.0) > .51){mx += 50;} else {mx -= 50;} if(random(1.0) > .51){my += 50;} else {my -= 50;} houndsTooth(mx2, my2, .5, hue2); if(random(1.0) > .51){mx2 += 50;} else {mx2 -= 50;} if(random(1.0) > .51){my2 += 50;} else {my2 -= 50;} lValue = int(random(width)); strokeWeight(1); stroke(0,255,255,20); pushMatrix(); rotate(random(360)); line ( lValue, 0, lValue, height); line ( 0, lValue, width,lValue); rotate(random(360)); line ( lValue, 0, lValue, height); line ( 0, lValue, width,lValue); rotate(random(360)); line ( lValue, 0, lValue, height); line ( 0, lValue, width,lValue); popMatrix(); noStroke(); if(keyPressed){if(key == 'k'){saveFrame("line-####.tif");}} } void houndsTooth(int htx, int hty, float htSize, int htHue){ pushMatrix(); scale(htSize); translate(htx, hty); fill(htHue, 255, 255); rect(0, 0, 50, 50); //top triangle(0, 0, 0, 35, -35, 0); triangle(0, 0, 35, 0, 0, -35); //bottom quad(50,0,50,15,85,50,100,50); quad(0,50,15,50,50,85,50,100); popMatrix(); } void mousePressed(){ mx = int(random(width)); my = int(random(height)); mx2 = int(random(width)); my2 = int(random(height)); strokeWeight(random(1, 20)); stroke(175, 255, 255); line(lValue * random(1), 0, lValue, height); strokeWeight(random(1, 20)); stroke(0, 255, 255); line(lValue * random(1), 0, lValue * random(1), height); steez = get (int(random(width)), 0, int(random(width)), height); for(int iter = 0; iter <= width; iter += random (100)){ set(int(random(iter)), 0, steez); } } void audioStreamWrite(AudioStream s) { // Figure out frequencies and detune amounts from the mouse // using exponential scaling to approximate pitch perception float yoffset = random(height); float frequency = pow(random(30000),random(yoffset)); myWave[0].generate(myStream); // Generate first sine, replace Stream myWave[0].phase += myStream.size; // Increment the phase myWave[0].phase %= myStream.sampleRate; for (int i = 0; i < myWave.length; i++) { // Set the frequencies myWave[i].frequency = frequency; myWave[i].phase = 0; } for (int i = 0; i < myWave.length; i++) { // Set the frequencies myWave[i].frequency = frequency; myWave[i].phase = 0;} }