Need help with command to automatically open .mp3s


i downloaded code have arduino output commands series of leds make them "dance" music. in order play song have add .mp3 in manually before running code using processing 3.2.3. wondering if there way have program automatically play song after song directory of .mp3s automatically.

i attached code have below.

thanks

code: [select]
import processing.serial.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import cc.arduino.*;

minim minim;
audioplayer song;
beatdetect beat;
beatlistener bl;
arduino arduino;

int ledpin =  9;    // led connected digital pin 9
int ledpin2 =  8;    // led connected digital pin 1
int ledpin3 =  2;    // led connected digital pin 0

float kicksize, snaresize, hatsize;

void setup() {
  size(512, 200, p3d);
  
  minim = new minim(this);
  arduino = new arduino(this, arduino.list()[0], 57600);
  
  song = minim.loadfile("test.mp3", 2048);
  song.play();
  // beat detection object freq_energy mode
  // expects buffers length of song's buffer size
  // , samples captured @ songs's sample rate
  beat = new beatdetect(song.buffersize(), song.samplerate());
  // set sensitivity 300 milliseconds
  // after beat has been detected, algorithm wait 300 milliseconds
  // before allowing beat reported. can use dampen
  // algorithm if giving many false-positives. default value 10,
  // no damping. if try set sensitivity negative value,
  // error reported , set 10 instead.
  beat.setsensitivity(100);  
  kicksize = snaresize = hatsize = 16;
  // make new beat listener, won't miss buffers analysis
  bl = new beatlistener(beat, song);  
  textfont(createfont("helvetica", 16));
  textalign(center);
  
  arduino.pinmode(ledpin, arduino.output);    
  arduino.pinmode(ledpin2, arduino.output);  
  arduino.pinmode(ledpin3, arduino.output);  
}

void draw() {
  background(0);
  fill(255);
  if(beat.iskick()) {
      arduino.digitalwrite(ledpin, arduino.high);   // set led on
      kicksize = 32;
  }
  if(beat.issnare()) {
      arduino.digitalwrite(ledpin2, arduino.high);   // set led on
      snaresize = 32;
  }
  if(beat.ishat()) {
      arduino.digitalwrite(ledpin3, arduino.high);   // set led on
      hatsize = 32;
  }
  arduino.digitalwrite(ledpin, arduino.low);    // set led off
  arduino.digitalwrite(ledpin2, arduino.low);    // set led off
  arduino.digitalwrite(ledpin3, arduino.low);    // set led off
  textsize(kicksize);
  text("kick", width/4, height/2);
  textsize(snaresize);
  text("snare", width/2, height/2);
  textsize(hatsize);
  text("hat", 3*width/4, height/2);
  kicksize = constrain(kicksize * 0.95, 16, 32);
  snaresize = constrain(snaresize * 0.95, 16, 32);
  hatsize = constrain(hatsize * 0.95, 16, 32);
}

void stop() {
  // close minim audio classes when finished them
  song.close();
  // stop minim before exiting
  minim.stop();
  // closes sketch
  super.stop();
}

quote
before running code using processing 3.2.3
have noticed processing != arduino?


Arduino Forum > Using Arduino > Programming Questions > Need help with command to automatically open .mp3s


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor