help with forward fft display
in
Core Library Questions
•
2 years ago
Hi,
Anyone tell me where i'm going wrong with this sketch? Both arcs are displaying the frequency response for the bass guitar, whereas i want one of them to show frequency of the shaker.
- import ddf.minim.*;
- import ddf.minim.analysis.*;
- AudioPlayer player, player1;
- Minim minim;
- FFT fft;
- int bufferSize = 512;
- int fftSize = floor(bufferSize*.5f)+1;
- float ai = TWO_PI/fftSize;
- void setup() {
- size(400, 400, P3D);
- smooth();
- noStroke();
- colorMode(HSB, fftSize, 10, 10);
- minim = new Minim(this);
- player = minim.loadFile("bass guitar.mp3");
- player1 = minim.loadFile("shaker.mp3");
- player.play();
- player.loop();
- player1.play();
- player1.loop();
- fft=new FFT(player.bufferSize(), player.sampleRate());
- fft=new FFT(player1.bufferSize(), player1.sampleRate());
- smooth();
- }
- void draw() {
- background(0, 0, 100);
- fft.forward(player.mix);
- for (int i = 0; i < fftSize; i++) {
- float band = fft.getBand(i);
- {
- fill(i, 150+100*(band), 100, 100);
- arc(100, 100, 50+band * (i+1)/2, 50+band * (i+1)/2, ai*i, ai*(i+1));
- fill(i, 150+100*(band), 100, 100);
- arc(200, 200, 50+band * (i+1)/2, 50+band * (i+1)/2, ai*i, ai*(i+1));
- }
- }
- }
- void stop()
- {
- player.close();
- player1.close();
- minim.stop();
- super.stop();
- }
1