We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey i want a Play/Pause button in my Visualizer can you help me??
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
PImage hintergrund;
Minim minim;
AudioPlayer Player;
FFT fft;
int w;
int farbe;
void setup()
{
size(500,300,P3D);
minim = new Minim(this);
Player = minim.loadFile("bla.mp3"); // Spielt die Mp3 datei ab
Player.loop(); // Wiederholt den aktuellen Song
fft = new FFT(Player.bufferSize(), Player.sampleRate());
fft.logAverages(60, 7);
stroke(255);
w = width/fft.avgSize();
strokeWeight(w);
strokeCap(SQUARE);
farbe = 0;
}
void draw()
{
hintergrund = loadImage("hintergrund.jpg");
image(hintergrund,0,0);
fft.forward(Player.mix);
colorMode(HSB);
stroke(farbe, 255, 255);
colorMode(RGB);
for(int i = 0; i < fft.avgSize(); i++){
line((i * w)*3, height/1.1, (i * w)*3, height/1.1 - fft.getAvg(i) * 0.5);
}
farbe += 5;
if( farbe > 255)
{
farbe = 0;
}
}
This is atm my Code also i would donate a few euro if you can help me :)
Answers
Move line 35 to your setup() because you don't want to do this in draw().
For play/pause:
For more information about Minim, check their reference: http://code.compartmental.net/minim/
Kf
hey thank you for the fast answer
the void mouseReleased is really great but how can i implate there a Button?
because now the Song stops everytime i klick with my mouse but i want to press a Button
greetings
You can check if your mouseX and mouseY values are within some values before calling Player.pause() or Player.loop().
You can use the following code:
Now you can use it in the following way:
Kf
You could also use G4P or controlP5. If you install the libraries using the Processing IDE's library manager, you can have a look at the provided examples. Alternatively, you can do a search on the forum and you could see previous posts:
https://forum.processing.org/two/search?Search=G4P
https://forum.processing.org/two/search?Search=controlP5
Kf
ill try to implate your code into mine but dosent work :( the code looks complicated is there a way who is moore simple ^^ ??