Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : How to play a list of songs with minim player?

$
0
0
I just solved the problem. For those who will have the same problem.

Processing code (the path is only for mac users), the programm plays the songlist from desktop and shows a 8-band EQ. If you want to drive Led as a 7 band EQ just send the val2 to arduino

import ddf.minim.*;
import ddf.minim.analysis.*;
AudioPlayer[] player = new AudioPlayer[4];
Minim minim;
FFT fft;
float val;
int val2;
int bufferSize = 8;
int fftSize = floor(bufferSize*.9)+1;
int count=0;


void setup() {
  size(600, 260);

  minim = new Minim(this);
  player[0] = minim.loadFile("/Users/.../Desktop/m.mp3");
  player[1] = minim.loadFile("/Users/.../Desktop/Y.mp3");
  player[2] = minim.loadFile("/Users/.../Desktop/t.mp3");
  player[3] = minim.loadFile("/Users/.../Desktop/h.mp3");


  player[count].play();

  fft=new FFT(player[count].bufferSize(), player[count].sampleRate());
}

void draw()
{
  if(!player[count].isPlaying())
  {
    count++;
    if(count>3)count=0;
    player[count].play();   
  }
   
  fft.forward(player[count].mix);
  background(255);

  for (int i = 0; i < fftSize; i++)
  {
    float band = fft.getBand(i);
    float control,afactor=10;
    control=band*afactor;
    if(control>1023)control=1023;
   
      val=map(control, 0, 1023, 0, 255);
      val2=int(val);

      print("chanel ");
      print(i);
      print("  actual value ");
      print(val2);
      println();

      fill(0);
      ellipse(5+i*(width/8), height-val2, 10, 10);

      }
    line(0, height-255, width,height-255);

}
void stop()
{
  //player.close();
  //minim.stop();
 // super.stop();
}   


Viewing all articles
Browse latest Browse all 1768

Trending Articles