iggy wave

“Now I Wanna Be Your Dog” as a 3d landscape. I was using the minim library in processing to visualize the sound level data stream, then exporting out to rhino. Many thanks to the proxyarch team for help with the code.
EDIT:
Added link to processing app, see it in action (loud rock music will begin playing…so turn it up!)
http://gracefulspoon.com/processingapps/singlewave/index.html
import processing.dxf.*;
import ddf.minim.analysis.*;
import ddf.minim.*;
FFT fftLin;
FFT fftLog;
Waveform myRects;
Minim minim;
AudioPlayer groove;
boolean record;
void setup(){
size(1000, 500, P3D);
noStroke();
minim = new Minim(this);
groove = minim.loadFile(“groove.mp3″);
groove.loop();
background(255);
fftLog = new FFT(groove.bufferSize(), groove.sampleRate());
fftLog.logAverages(22, 4); //adjust spacing here
float w = float(width/fftLog.avgSize());
float x = w;
float y = 0;
float z = 50;
float radius = 10;
myRects = new Waveform(x,y,z,radius);
}
void draw(){
background(0);
directionalLight(126,126,126,sin(radians(frameCount)),cos(radians(frameCount)),1);
ambientLight(102,102,102);
float zoom = 1000;
PVector foc = new PVector(myRects.x*0.5, myRects.y*0.5, 0);
PVector cam = new PVector(zoom*sin(radians(frameCount)), zoom*cos(radians(frameCount)), -zoom);
camera(foc.x+cam.x,foc.y+cam.y,foc.z+cam.z,foc.x,foc.y,foc.z,0,0,1);
//play the song
fftLog.forward(groove.mix);
myRects.update();
if(record){
beginRaw(DXF, “output.dxf”);
}
// DXF will export the stuff drawn between here.
myRects.plotTrace();
if(record){
endRaw();
record = false;
println(“Done DXF~!”);
}
}
void stop() {
// always close Minim audio classes when you finish with them
groove.close();
// always stop Minim before exiting
minim.stop();
super.stop();
}
class Waveform{
float x,y,z;
float radius;
PVector[] pts = new PVector[fftLog.avgSize()];
PVector[] trace = new PVector[0];
Waveform(float incomingX, float incomingY, float incomingZ, float incomingRadius){
x = incomingX;
y = incomingY;
z = incomingZ;
radius = incomingRadius;
}
void update(){
plot();
}
void plot(){
for(int i = 0; i < fftLog.avgSize(); i++){
int w = int(width/fftLog.avgSize());
x = i*w;
y = frameCount*5;
z = height/4-fftLog.getAvg(i)*10;
stroke(0);
point(x, y, z);
pts[i] = new PVector(x, y, z);
trace = (PVector[]) expand(trace, trace.length+1);
trace[trace.length-1] = new PVector(pts[i].x, pts[i].y, pts[i].z);
}
}
void plotTrace(){
/*
//drawing points
for(int i=0; i
//locator(trace[i].x, trace[i].y, trace[i].z, 1);
point(trace[i].x, trace[i].y, trace[i].z);
}
*/
//drawing poly surface
fill(255,20); noStroke();
//stroke(0,255,255,5);
int inc = fftLog.avgSize();
for(int i=1; i
beginShape(TRIANGLE_STRIP);
vertex(trace[i].x, trace[i].y, trace[i].z);
vertex(trace[i-1].x, trace[i-1].y, trace[i-1].z);
vertex(trace[i+inc].x, trace[i+inc].y, trace[i+inc].z);
vertex(trace[i-1+inc].x, trace[i-1+inc].y, trace[i-1+inc].z);
endShape(CLOSE);
}
}
//draw splines
int skip = 5;
stroke(255, 20); noFill();
for(int i=0; i
for(int j=0; j
}
endShape();
}
}
}
void keyPressed() {
// use a key press so that it doesn’t make a million files
if (key == ‘r’) record = true;
}
void locator(float x, float y, float z, float sc){
line(x-sc,y,z,x+sc,y,z);
line(x,y-sc,z,x,y+sc,z);
line(x,y,z-sc,x,y,z+sc);
}

September 2nd, 2009 at 1:06 am
beautiful. I am getting an unexpected character (\) at the groove.mp3 file line. I have the newest minim lib and renamed my audio file appropriately. Any ideas? write back at gabriel at gabrielmathews dot com…
Thanks!
September 2nd, 2009 at 4:51 pm
Thanks for the comment. So, what I hope is happening here is one of two things:
Thing 1: When you copy text from a doc file or website or whatever into the processing app it converts all the quotation marks into a character set that processing can’t recognize (Processing only knows vertical quotation marks, whereas notepad uses a different character for an opening and a closing mark). The solution would be to simply retype each quotation mark in processing.
Thing 2: Whatever the mp3 file is called, make sure you change it to the more generic “groove.mp3.” It could be that processing can’t find the file so double check that it is in the same root folder as the processing file.
If neither of those get it working, let me know,
best,
John
December 10th, 2009 at 2:09 pm
Hey John,
I just stumbled accross your page, and i thought this looked amazing, so i wanted to try it out.
but im getting an error:
processing.app.debug.RunnerException: unexpected token: i
on the first line of this setion:
for(int i=1; i if(i%inc != 0){
beginShape(TRIANGLE_STRIP);
vertex(trace[i].x, trace[i].y, trace[i].z);
vertex(trace[i-1].x, trace[i-1].y, trace[i-1].z);
vertex(trace[i+inc].x, trace[i+inc].y, trace[i+inc].z);
vertex(trace[i-1+inc].x, trace[i-1+inc].y, trace[i-1+inc].z);
endShape(CLOSE);
}
appologies if this is a silly question, im very new to processing, just playing around really.
Cheers,
Phil.
December 12th, 2009 at 12:56 pm
Hi Phil,
One of the vagaries of processing is that it doesn’t like to copy and paste text and that’s most likely what’s going on here. Anyway, a better way to share code is probably to actually link to the processing app, so that’s here: http://gracefulspoon.com/processingapps/singlewave/index.html the code should remain formatted and provide a better means to investigate. Let me know if it’s still not working for you. best, john
December 13th, 2009 at 9:08 am
That’s working perfectly now, thanks so much for your help!
Phil.
February 25th, 2010 at 7:09 am
Hi,
I’m just trying processing for the fisrt time and i’m not sure why but when it gets to
Waveform myRects;
is says it cant find it. Why is this happening?
Thanks,
Alex
March 1st, 2010 at 10:01 am
Hi, I’ve been trying to find out how to create your image above and I’m having few problems, it keeps coming up with the following error message and when i hit play the screen is blank white. Do you know what i can do to fix it?
Exception in thread “Animation Thread” java.lang.NullPointerException
at ddf.minim.javasound.JSMinim.getAudioInputStream(JSMinim.java:604)
at ddf.minim.javasound.JSMinim.getAudioRecordingStream(JSMinim.java:200)
at ddf.minim.Minim.loadFile(Minim.java:357)
at ddf.minim.Minim.loadFile(Minim.java:341)
at sketch_mar01a.setup(sketch_mar01a.java:45)
at processing.core.PApplet.handleDraw(PApplet.java:1402)
at processing.core.PApplet.run(PApplet.java:1327)
at java.lang.Thread.run(Thread.java:619)
Thanks, Alex
March 2nd, 2010 at 9:06 pm
Hi Alex, looks like either the minim library isn’t loaded into processing or you’re missing an audio file named “groove.mp3″ in your data folder. If that doesn’t help, try to download a .rar with the processing file and mp3 from here: gracefulspoon.com/processingapps/waveform_landscape04.rar If that still doesn’t work let me know.
best, John
March 23rd, 2010 at 10:05 pm
Hi John,
Thank you for posting this!! I’ve checked out your site a few times now and find it really intriguing. I’m working on a thesis project here in Philadelphia which is about ways to visualize sound and apply that to design. Currently I’ve done some experiments with code I’ve found online and have built a few study models ( http://www.grasshopper3d.com/photo/photo/listForContributor?screenName=2luhs3b9vc16z ).
I’m really looking to get into this more in the next couple of weeks and generate some forms besides topographies from the sound. The problem is that I don’t know much at all about programming other than what is possible. Fortunately the online Processing and Grasshopper/Rhino community has been very supportive and helpful. Anyway, I was wondering if you might be able to help with a couple questions about sound generated forms?
About this particular code- how can I change/control the animation? how can I export or import this into a mesh or point cloud that I can use in Rhino? Is there a way to just play/pause certain parts to use in Rhino or make it not loop? when I ran the file, I couldn’t see where it was saving to..where/how in the code do I control this?
Another question I had was how could I use processing to make different 3D objects? One idea I had was to have a set of tetrahedronal modules/blocks for each key on a piano..so, I would set the basic parameters and the sound would essentially do the rest. In theory, a better music composition would in-effect make a better structured object. I’ve got a lot of other experiments I’d like to try as well…just as renderings and actual objects when possible. Maybe we could even collaborate on some projects in the near future.
Thank you for any help or suggestions.
feel free to email me directly too..
Matt
June 16th, 2010 at 12:53 pm
how can i make it the same as the image above ? (filled gray )
June 20th, 2010 at 12:00 pm
Shay,
hit “r” while the program is running, it will place a dxf file in your sketch folder. Open this dxf in rhino, set the render engine to vray, load the vray preset “gi_irmap_high,” hit render and you’re all set.
September 19th, 2011 at 11:01 am
[...] 3D Spectrogram created using Processing based on code by John Locke. [...]
September 29th, 2011 at 11:21 am
[...] 3D spectrogram created with Processing. Realtime visualization of sound using a microphone or line in. Modified code to allow for realtime recording using line in or microphone. Based on code by John Locke. Link [...]
October 3rd, 2011 at 8:00 am
[...] Audio recording of laser created by a computer mouse. Recorded with two photocells and a Zoom H2. 3D Spectrogram created using Processing based on code by John Locke. [...]
October 3rd, 2011 at 8:01 am
[...] 3D spectrogram created with Processing. Realtime visualization of sound using a microphone or line in. Modified code to allow for realtime recording using line in or microphone. Based on code by John Locke. Link [...]
April 1st, 2012 at 6:28 pm
Hey, I’ve tried to delete the older waves by editing your code in the plot() function but I can’t seem to get it right
it should be easy by having the trace list with a static size and then by shifting its shapes, so the older ones
can disappear…
Can you help me?