We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › replacing perlin noise with data from mp3
Page Index Toggle Pages: 1
replacing perlin noise with data from mp3 (Read 713 times)
replacing perlin noise with data from mp3
Nov 6th, 2008, 4:33pm
 
as a beginner its not always easy to see the obvious solution! i'm not a programmer so this is a process of discovery for me.

here's an example of a waveform i would like to generate. this one is triggered by perlin noise, which i would like to replace by an mp3 file. i have included the minim code dis-activated.
i think the key to my woe's here is the 'noise' variable under renderWave. i can't seem to find an appropriate replacement. i have tried 'get' but it doesn't work.

any help would be greatly appreciated.
d

//import ddf.minim.*;

int xspacing = 16;   // How far apart should each horizontal location be spaced
int w;    // Width of entire wave

float yoff = 0.0f;   // 2nd dimension of perlin noise
float[] yvalues;

//Minim minim;
//AudioPlayer son;

void setup() {
 size(1024,768);

 // minim = new Minim(this);
//   son = minim.loadFile("son.mp3", 512);
 //son.play();

 frameRate(30);
 colorMode(RGB,255,255,255,100);
 smooth();
 w = width+16;
 yvalues = new float[w/xspacing];
 }

void draw() {
 background(0);
 calcWave();
 renderWave();
}

void calcWave() {
 float dx = 0.06f;
 float dy = 0.02f; //speed of scroll
 float amplitude = 100.0f;

 // Increment y ('time')
 yoff += dy;

 float xoff = yoff;

 for (int i = 0; i < yvalues.length; i++) {
   yvalues[i] = (2* noise (xoff)-1)*amplitude;    // here i think i need to replace noise for get or toArray but i can't figure out how to make it work!!!
   xoff+=dx;
 }
}

void renderWave() {

for (int x = 0; x < yvalues.length-1; x++) {
 stroke(255);
 strokeWeight(3);

  line(x*xspacing,width/2+yvalues[x],(x-1)*xspacing,width/2+yvalues[x+1]);
}
}

void stop()
{
 son.close();
 input.close();
 minim.stop();
}

Re: replacing perlin noise with data from mp3
Reply #1 - Nov 7th, 2008, 1:39am
 
are you trying to do something similar to this?
http://code.compartmental.net/minim/examples/FFT/ForwardFFT/
Re: replacing perlin noise with data from mp3
Reply #2 - Nov 7th, 2008, 2:09am
 
not really.
i want to create a scrolling wave... i will look more closely at the code involved in what you have sent me to see if there are any clues within, but essentially i want a scrolling wave like the perlin noise tutorial by shiffman, however i want to trigger the wave from an mp3 file.

thanks for the suggestion.

d



Page Index Toggle Pages: 1