Exporting DXF files.
in
Contributed Library Questions
•
2 years ago
Hello everyone, I've come up against a little problem exporting a DXF file from a program I've been working on. The program itself requires the
ESS library (which I'm sure many of you may already have) and a sound file entitled cell.aif, any .aif will do but here's the one I've been using
link.
What I want to do is create a 3d representation of a sound-wave (which I have successfully done) and then export it as a DXF file. I've set up the export, it works, however it only exports a single 3d box as opposed to the whole structure I've built onscreen.
I'm a bit of a noob, I've only been working with processing for a couple of weeks, so please forgive me if I'm missing something fairly fundamental!
Any help towards exporting the whole structure would be greatly appreciated! Here's the code:
-
import krister.Ess.*;import processing.dxf.*;
/*-------------------------------------------------------*** GLOBAL VARIABLES ***--------------------------------------------------------*/
AudioChannel myChannel;FFT myFFT;int d=0;int bufferSize=256;
boolean damp=false;// -------------- Variable to store boolean 'export' toggleboolean dxfExport;
/*-------------------------------------------------------*** GLOBAL SETUP ***--------------------------------------------------------*/
void setup() {//------------------------------------------ general thingssize(1000,500,P3D);smooth();//------------------------------------------ start up EssEss.start(this);//------------------------------------------ load "cell.aif" into a new AudioChannelmyChannel=new AudioChannel("cell.aif");//------------------------------------------ set FFT sizemyFFT=new FFT(bufferSize*2);//------------------------------------------ damp our spectrum datamyFFT.damp(.1);//------------------------------------------ start the sound looping oncemyChannel.play(1);
noStroke();fill(0);}
/*-------------------------------------------------------*** GLOBAL SETUP ***--------------------------------------------------------*/
void draw() {//------------------------------------------ lightslights();//------------------------------------------ if export if TRUEif (dxfExport) {beginRaw(DXF, "output.dxf");}//------------------------------------------ initial rotationrotateY(radians(-17)); //rotates YrotateX(radians(-10)); // rotates X//------------------------------------------ get spectrummyFFT.getSpectrum(myChannel);//------------------------------------------ draw frequency barsfor (int i=0; i<bufferSize/2; i++) {//------------------------------------------ add 1 each time the buffer restartsif (i==0){d++; }//------------------------------------------ push new 3d matrixpushMatrix();translate(i+500, height/2, d);box(1, 1+myFFT.spectrum[i]*-400, 1);popMatrix();//------------------------------------------ print how far forward the buffer has movedprintln(d);//------------------------------------------ finish export and set dxfExport to FALSEif(dxfExport) {endRaw();dxfExport = false;if (d==250){ //controls the length the patch runs for relative to the amount of FFT window instancesnoLoop();}}}}//------------------------------------------ we are done, clean up Ess
public void stop() {Ess.stop();super.stop();}
/*-------------------------------------------------------*** GLOBAL KEYSTOKE EVENTS ***--------------------------------------------------------*/void keyPressed() {//------------------------------------------ use a key press so that it doesn't make a million filesswitch (key) {case 'x':dxfExport = true;println("DXF export complete!");break;case 's':saveFrame("boxes.jpg");println("screen grab made");break;}}
1