Tag Archives: code

#CreativePact_1 :: Beating-sines [Processing, minim]

First up, a little introductory play around with Processing’s Minim audio library.

Throughout the masters, I looked a lot at the psychoacoustic phenomena of beat-tones – the perceived pulse created by two tones slightly out-of-tune with each other. This is a significant musical feature in drone music so for obvious reasons, its simplicity and effectiveness were of interest to me.

View the code (but watch the font).

Reading: ‘Chaos’, James Gleick
Listening: Lovehate (2007), The-Dream

Processing; code #2

More playing around with Processing this morning. Came up with a nice little sketch in which ‘planets’ orbit a ‘sun’, which is moveable with the mouse. I like the animation of the lines to the planets which gives the whole thing a nice atomosephere.

Its meant to move, so for those with Processing (and for those without, it IS free!) here is the source code:

Orbit planet;
Orbit planet2;
Orbit planet3;
Orbit planet4;
void setup() {
size(800,600);
smooth();
ellipseMode(RADIUS);
planet = new Orbit(50,0.01,12);
planet2 = new Orbit(70,-0.02,10);
planet3 = new Orbit(90,0.03,7.5);
planet4 = new Orbit(110,-0.04,5);
}
void draw() {
background(0);
planet.atmos();
planet2.atmos();
planet3.atmos();
planet4.atmos();
planet.move();
planet.display();
planet2.move();
planet2.display();
planet3.move();
planet3.display();
planet4.move();
planet4.display();
}
class Orbit {
float x;
float y;
float angle = 0.0;
float easing = 0.025;
float scalar;
float speed;
float mass;
float xOrb;
float yOrb;
Orbit(float tempScal, float tempSpeed, float tempMass) {
scalar = tempScal;
speed = tempSpeed;
mass = tempMass;
}
void move() {
// Calculate planet's orbit
xOrb = x+sin(angle)*scalar;
yOrb = y+cos(angle)*scalar;
angle+=speed;
//Ease sun to follow mouse when mouse pressed
if (mousePressed==true) {
x+=(mouseX-x)*easing;
y+=(mouseY-y)*easing;
}
}
void display() {
noStroke();
fill(200,128);
//draw 'planet'
ellipse(xOrb,yOrb,mass,mass);
//draw centre 'sun'
ellipse(x,y,mass*2,mass*2);
//link line sun to 'planet'
stroke(255,100);
line(x,y,xOrb,yOrb);
//draw line from planet to mouse position
line(mouseX,mouseY,xOrb,yOrb);
//location crosshair for sun destination
line(0,mouseY,width,mouseY);
line(mouseX,0,mouseX,height);
//location crosshair for sun position
line(0,y,width,y);
line(x,0,x,height);
//location crosshair for planet
line(0,yOrb,width,yOrb);
line(xOrb,0,xOrb,height);
//draw 'orbit' path
noFill();
ellipse(x,y,scalar,scalar);
}
void atmos() {
strokeWeight(0.5);
stroke(100,100);
for (int i = 1; i < width;i += 10) {
line(i,0,xOrb,yOrb);
line(i,height,xOrb,yOrb);
}
for (int i = 1; i < width;i += 10) {
line(0,i,xOrb,yOrb);
line(width,i,xOrb,yOrb);
}
}
}
I'm sure there is a more efficient way to code such a simple program, but its still early days. I think the next step I want to take is to use this program to output some sort of data (perhaps OSC protocol) to control aspects of Max/MSP...

Processing; introduction & code #1

As part of a little area of research (and some personal desire to learn basic coding), I am learning the Processing programming language.  Eventually, I’m hoping that I can use it as both an interface and a tool for visualising data in another project.  For the time being however, I’m still getting to grips with coding in general. (See also the current white and blue header above to see what this program’s big sister looks like!)

Here is a cute little .gif of a code I wrote last week to generate randomly placed nodes from a mouse click. Simple, but cute – especially in the real program as the nodes regenerate randomly as the mouse button is held down.

code #1 (Processing)

This weekend I hope to get my head around Processing.js that will let me drop codes into the page as a java applet – thus the program to run interactively on this site. In all its lagging glory!