Archive for the ‘Design’ Category

Frequency Mandelbrot

Sunday, September 21st, 2008

Frequency Mandelbrot 1Where I had been experimenting with just the outsides of the mandelbrot before, I’ve started having a look at modifying the inside of the fractal as well. I’ve continued to use the frequency spectrum for the effects simply because it goes with the frequency spectrum used in the background.

import ddf.minim.*;
import ddf.minim.analysis.*;

FFT fft;

AudioPlayer song;
BeatDetect beat;

float fSize;

void setup()
size(300, 300);

// always start Minim first!

// specify 512 for the length of the sample buffers
// the default buffer size is 1024
song = Minim.loadFile("freedom.mp3", 512);;
beat = new BeatDetect();

float fSize = 20;
// an FFT needs to know how
// long the audio buffers it will be analyzing are
// and also needs to know
// the sample rate of the audio it is analyzing is
fft = new FFT(song.bufferSize(), song.sampleRate());

void draw()
// first perform a forward fft on one of song's buffers
// I'm using the mix buffer
//  but you can use any one you like


// Maximum number of iterations for each point on the complex plane
float maxiterations = 200;
float xmin = -2.5;
float ymin = -2;
float wh = 2;

if ( beat.isOnset() ) fSize += 0.1;

fSize = constrain(fSize, -10, 10);

ymin = -1;
xmin = -1.5;

maxiterations = maxiterations + fSize;

// x goes from xmin to xmax
float xmax = xmin + wh;
// y goes from ymin to ymax
float ymax = ymin + wh;

// Calculate amount we increment x,y for each pixel
float dx = (xmax - xmin) / (width);
float dy = (ymax - ymin) / (height);

// Start y
float y = ymin;
for(int j = 0; j < height; j++) {
// Start x
float x = xmin;
for(int i = 0;  i < width; i++) {

// Now we test, as we iterate z = z^2 + cm does z tend towards infinity?
float a = x;
float b = y;
int n = 0;
while (n < maxiterations) {
float aa = a * a;
float bb = b * b;
float twoab = 2.0 * a * b;
a = aa - bb + x;
b = twoab + y;
// Infinty in our finite world is simple, let's just consider it 16
if(aa + bb > 16.0f) {
break;         }

// We color each pixel based on how long it takes to get to infinity
// If we never got there, let's pick the color black
if (n == maxiterations) pixels[i+j*width] = 0;
else pixels[i+j*width] = color(n*(song.right.get(i)*50) % 255, n*(song.left.get(i)*50) % 200, n*(song.right.get(i)*30));
x += dx;
y += dy;

void stop()

Frequency Mandelbrot 2In this version I have used the BeatDetect class and another variable, fSize with a constraint on it and then added to the maximum iterations. This allows the frequency spectrum to spread through the mandelbrot fractal, or appear to anyway. It is actually just using the frequency spectrum to colour the fractal, and this makes it appear like spectrum is forming the fractal.

You can have a look at it in action here. The song used in this piece is “Freedom (Waking Mix)” by vo1k1 2008 – Licensed under Creative Commons Attribution Noncommercial (3.0).

This is fairly CPU intensive, so many computers will have trouble running this, it is also about 13mb to load so you probably don’t want to try it on a low speed connection.

Walking Lines 3 – Processing

Thursday, August 21st, 2008

Walking Lines 3, joining lines.I received some feedback on my earlier versions of the walking lines in the form of a trackback from Alex.

The feedback was part of a practice peer review, but he went into some detail on how i could fix up my current code so that the lines follow on from each other and how to reduce the load on the CPU per cycle with the same effect. The advice is greatly appreciated.

View the new version online here.

The changes and source code are after the jump.


Walking Lines 1

Thursday, July 31st, 2008

Semi-random lines sketchIn the week 2 tutorial for KKB211 – Computational Arts 2, we are looking at doing walking lines in our chosen development tool.

Walking lines are effectively randomly generated paths that the lines follow to create a random image.

I have been using Processing for this particular focus. Thus far I have random lines, however they don’t follow any particular path as of yet. This is effectively still walking lines as the position of the lines is added to and built on. Unfortunately this actually draws a new line every frame that is not necessarily joined to the line from the previous frame.

Have a look at it online here.

The code used to do this is extremely simple and just involves a few random variables based on the width and height of the canvas. I don’t believe this is entirely stochastic because the randoms are tightly controlled, but it is random within its boundaries (unless you want to get into the nitty gritty of it, which I don’t).

The source code is available after the jump.


Dancing Balls

Friday, June 6th, 2008

Just playing with Quartz Composer. Four dancing balls that bounce horizontally and vertically.

The file, dancing_balls.qtz is online here.

Audio Responsive Lines 2

Thursday, June 5th, 2008

There were a few problems with the first responsive lines that I did. Mainly related to visibility. For the lines I decided to make their visibility based on the audio spectrum as well as the volume, so sometimes they vanish altogether when they shouldn’t.

I have mostly fixed this now, it does still occasionally happen but not too often and in general it responds to all audio better than it did before. It is more sensitive overall.

There are some changes to the rotations as well so now there is more variation in how the lines appear, including the illusion of a horizon, so there is a lot more randomness to it.

I have also gone through and added in notes to make it easier to figure out what does what later on, also so anyone looking at it can figure it out relatively easily.

The Quartz Composer file, responsive_lines_2.qtz is available here.

It requires input via the built in mic in Macbook’s or iMac’s. It can of course be changed to accept audio input from the microphone-in, or line-in on Mac Pro’s or Mac Mini’s. With the right plug-in, it can also accept input from iTunes.

The most ideal is via line-in or microphone in as this gives the most control over what exactly the graphics are being synchronised with. However, using the built-in microphone means that no extra accessories are required.

Note that this was done using  Quartz Composer in Leopard.