SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By needle
#109787
Hello everyone,

i've posted this problem already on the arduino forum, but haven't found a solution for my problem yet.
and then stumbled across this forum while searchng for some buttons i wanted to use for my midi controller.

ok so here i go:

i've used this schematic to successfully interpret the midi in signal:
http://www.arduino.cc/cgi-bin/yabb2/YaB ... 187962258/

i've had no problems combining this with midi out.for an example: when i press the play button, it'll light up a led while my computer is playing music.

now i was wondering if i can make a midi vu meter with this.

the program i use is Traktor Pro, it lets me output the velocity of a mp3 to one note with a velocity between 0 and 127.

so my first attempt was to just connect 4 leds (i know this should be at least 10) to the arduino and read the velocity to turn on corresponding leds, but this gives me to much latency.

here is my code:
Code: Select all
byte incomingByte;
byte note;
byte velocity;

int vuPin1=9;
int vuPin2=8;
int vuPin3=7;
int vuPin4=6;
int statusled = 13;
int val =0;

int state = LOW;
long previousMillis = 0;
long interval = 1;

void setup() {
  Serial.begin(31250);
  pinMode(statusled, OUTPUT);
  pinMode(vuPin1, OUTPUT);
  pinMode(vuPin2, OUTPUT);
  pinMode(vuPin3, OUTPUT);
  pinMode(vuPin4, OUTPUT);
}

void loop()
{
  if (Serial.available() > 2)
  {
    digitalWrite(statusled,HIGH);
    incomingByte = Serial.read();
    if (incomingByte == 144)
    {
    note = Serial.read();
    if (millis() - previousMillis > interval)
    {
    previousMillis = millis();

    if ((state == LOW)&&(note == 1))  {
						    velocity = Serial.read();
						    if (velocity >= 100 ) { digitalWrite(vuPin1, HIGH); digitalWrite(vuPin2, HIGH); digitalWrite(vuPin3, HIGH); digitalWrite(vuPin4, HIGH); }
						    if (velocity >= 70 ) { digitalWrite(vuPin1, HIGH); digitalWrite(vuPin2, HIGH); digitalWrite(vuPin3, HIGH); }
						    if (velocity >= 50 )  { digitalWrite(vuPin1, HIGH); digitalWrite(vuPin2, HIGH);  }
						    if (velocity >= 1 )  { digitalWrite(vuPin1, HIGH); }
						    state = HIGH;
						   }

						    else{
							    digitalWrite(vuPin1, LOW);   digitalWrite(vuPin2, LOW);   digitalWrite(vuPin3, LOW); digitalWrite(vuPin4, LOW);
							    state = LOW;
							   }

    }
   }
  }
} 

Image

i've also tried a different approach,

i used only pin 9 which is a PWM output, connected to a RC circuit, connected to a LM3914 circuit (found on page 2 of the datasheet) but this also failed. (to sluggish)

this is in very short what i tried, to read more here is the original topic on the arduino.cc forum.
http://www.arduino.cc/cgi-bin/yabb2/YaB ... 1284312060

i guess the question after three weeks of trying is: is it possible to create this Midi Vu Meter?

any help would be very much appreciated.