I want to convert this "Processing code" to OF code

#1

Hi, All.

I want to convert this “Processing code” to OF code.

images
It’s a realtime audio spectrum using 3D disappearing to backward.
github: https://github.com/Hollenbeckj/ProcessingMusicVisualizer

How Can I convert?

import ddf.minim.;
import ddf.minim.signals.
;
import ddf.minim.analysis.*;
visualizer classicVi;

Minim minim;
FFT fft;

AudioOutput out;
AudioPlayer mp3;

PFont directions;
PImage fade;
float rWidth,rHeight;
int hVal;

boolean started; //boolean for telling if the program has started
boolean selection; //boolean for telling if a song has been selected
boolean canPlay;//boolean for allowing the audio to play
boolean canPauseAndPlay; //boolean for allowing the pause and play function
PImage title;//Image etup for the title screen

void setup()
{
//program setup
size(900,500,P3D);
title = loadImage(“VisualZtitle .png”);
frameRate(60);
started = false;
selection = false;

// sound and minim setup parameters
minim = new Minim(this);
mp3 = minim.loadFile(“mashUp.mp3”,2048);// load your mp3 file here make sure you use processing’s built in add file feature and type the name of the loaded mp3 inside the quotation marks
out = minim.getLineOut(Minim.STEREO,44100);
fft = new FFT(mp3.bufferSize(),mp3.sampleRate());//allows for the decription of the sound waves
rectMode(CORNERS);
mp3.loop();

//background fader parameters
fade = get(0,0, width,height);// parameter for making the background fade
rWidth = width0.99;
rHeight = height
0.99;
classicVi = new visualizer(); // initializes the class visualizer

if(!started)
{
mp3.pause();
}
}

void draw()
{
if(!started)
{
background(title);
canPauseAndPlay = false;
}
else if(started)
{
canPlay = true;
background(0);
classicVi.drawEQ();
if(canPlay)
{
mp3.play();
pauseAndPlay();
}
}
}
// Start Button Parameters
void mouseClicked()
{
started = true;// tells the program its started playing
}
void keyPressed()
{
if(key == ESC)
{
started = false; //kills the program
mp3.pause();
}
}
// function for pausing and playing the audio
void pauseAndPlay()
{
if(key == ‘p’)
{
mp3.pause();
}
else if(key == ‘q’)
{
mp3.play();
}
}

void close()
{
out.close();
minim.stop();
super.stop();
}

Thanks.
Best,
@bemoregt.

#2

How Can I implement the “3D disappearing to backward” using OF ?

I wonder …

Thanks in advance ~

#3

As an alternative to Minim, if it’s just playback and FFT analysis, you should take a look at the chapter on sound in the ofBook here - https://openframeworks.cc/ofBook/chapters/sound.html

If there’s a more advanced need, I’d always recommend ofMaxim. @edapx can some nice Maxim tutorials as well here, including an FFT analysis file player.

“3D disappearing backwards” can mean a lot of things and could be potentially developed in a lot of different ways…

1 Like
#4

Processing is written in Java. Openframeworks is written in C++.

I’d suggest becoming familiar with both languages (or just the target language: C++) there is a good intro here: openframeworks.cc/ofBook/chapters/cpluplus_basics.html

1 Like
#5

this processing example used a false 3d, it draws the previous screen scaled and darker and over time the software will have this “perspective to dark” look.
I suggest you read the PDE code trying to figure out what is happening in each part, maybe try to run it in processing.

In this forum it helps a lot to visualize code if you type “crasis” character `
three times in a row before your code, and after.
The result will be a formatted code like this:

	if (girinos.size() < n) {
		int numero = n - girinos.size();
		for (int a=0; a<numero; a++) {
			createGirino(ofRandom(0,1));
		}
	}

All the best

1 Like