Advice needed - MIDI controlled LED bar/ VU meter

Status
Not open for further replies.

markstewart

New member
Guys, has anyone done this already ? If so how ?


I have both the teensy 2++ and the 3. As I will be driving a lot of LEDS, I guess something needs to sit between them.

I would like to run 4 independent bar graphs (think channel VU meters), mono is fine. They need to be addressable via MIDI from the DAW/program.

Any ideas, GRATEFULLY received.

Mark
 
I think MIDI is just the protocol, and he is going to be using Ableton Live or something to do the heavy lifting and derive the VU meter levels, then send it via MIDI CC.

Like: this?

If 7 bits was "meh" you could send data on two channels and do some magic on the Teensy side.

Edit: Further thought is that 7 bits is likely fine (127 different levels) since LED VU meters in equipment have only 12 or so.

Also: What are the 4 independent graphs? Are you representing different frequencies/instruments?
 
Last edited:
I've done a VU-type display with code like [below]. I think it has a decent amount of realism.

The code is only approximate, may have off-by-one issues etc - don't rely on it verbatim.
Some things about it:
- There are green, amber and red sections of the display. These won't change their positions, i.e. the first half of the strip will always be either green or off, and the next quarter of the strip will be either amber or off, and so on.
- The peak value decays by itself. Don't blindly set the bar height to always be equal to the input level, you want it to peak quickly if the level is high, and decay relatively slowly if the input level is lower.
- Also have a "held peak" value, i.e. the highest value ever seen during the previous N seconds. Then you'll have a bouncing column, and also a single LED above the column representing the held peak. This will reset itself every few seconds.

Code:
int maxx = 600; // max level corresponding to full scale
if( level<0 ) level=0;
if( level>maxx ) level=maxx;

if( level>peak_value ) // the held-peak
{
    peak_value = level;
    peak_count = 60;  // number of times around this loop to hold the peak
}

if( level > peak_decay ) // the decaying-peak
    peak_decay = ( (1*peak_decay) + (1*level) )/2;
else
    peak_decay = ( (19*peak_decay) + (1*level) )/20;
   

for(int i=0; i<numPixels; i++)
{
    int n = i;
    int on = 0;
    if( n == (numPixels)*peak_value/maxx ) on=1;
    if( n <= (numPixels)*peak_decay/maxx ) on=1;
    if( on==0 ) { color = 0x000000; /* off */ }
    else if( n < numPixels/2 )    { color = 0x008C00; /* green */ }
    else if( n <= 3*numPixels/4 ) { color = 0xC88C00; /* yellow */ }
    else                          { color = 0xFF0000; /* red */ }
}

// Count down to reset the held peak
peak_count--;
if( peak_count==0 ) { peak_level = 0; }
 
Guys, thanks for the very quick responses. The program I wish to use initially is Traktor Pro. I intend using a teensy to monitor using MIDI over USB.

Outputs can be monitored individual, and the teensy will need to "see" CC changes.
 
I think MIDI is just the protocol, and he is going to be using Ableton Live or something to do the heavy lifting and derive the VU meter levels, then send it via MIDI CC.

Like: this?

If 7 bits was "meh" you could send data on two channels and do some magic on the Teensy side.

Edit: Further thought is that 7 bits is likely fine (127 different levels) since LED VU meters in equipment have only 12 or so.

Also: What are the 4 independent graphs? Are you representing different frequencies/instruments?


I've just been given a MIDI controller, but it has no method of monitoring levels. As it has four stereo channels to mix down, level monitoring is vital.

I've built a few projects over the last year, and felt that this is something I should be able to build too (famous last words).

The idea is simple, a small box with four LED bar graphs like this http://uk.farnell.com/avago-technologies/hdsp-4836/led-bar-array-multicolor/dp/1003272

USB connection to the host.

The software does the hard work (values for volume level), and passes off various CC states to the teensy.
 
The idea is simple, a small box with four LED bar graphs like this http://uk.farnell.com/avago-technologies/hdsp-4836/led-bar-array-multicolor/dp/1003272

USB connection to the host.

The software does the hard work (values for volume level), and passes off various CC states to the teensy.

I hope you'll post a photo or video when it's working?

Like any project, the way to get started is breaking it into smaller pieces, developing each piece, and then using them together. Probably the very first piece to attempt would be a program running on Teensy that uses MIDI (eg, set in Tools > USB Type) to receive the incoming messages and just use Serial.print() to show them in the Arduino Serial Monitor. Once you know you're getting useful numbers onto the Teensy, then you can try using those to drive code that decides which LEDs to turn on. Once you have LEDs lighting up, then it's probably time to try laying in more complex code that does some sort of animation (eg, making the levels slowly fade down to zero... if the PC isn't sending updates rapidly?)
 
In addition to following Paul's advice, I suggest looking at p.7 of the data sheet where it says
These displays are designed for
strobed operation. The typical
forward voltage values can be
scaled from Figures 5 and 11.
These values should be used to
calculate the current limiting
resistor value and typical power
consumption.
as this will affect how you drive the LEDs.
 
The resistor will depend if you're using Teensy 2 (5 volts) or Teensy 3 (3.3 volts).

For Teensy 2, start with a 470 ohm resistor. If it's not bright enough, try decreasing the resistor, but don't go below 150 ohms.

For Teensy 3, start with a 220 ohm resistor. If it's not bright enough, try decreasing the resistor, but don't go below 120 ohms. If you need brighter, you'll need to use a buffer chip or transistor between Teensy 3 and the LED, to get more current.

Don't worry about "designed for strobe operation". Unless you really know what you're doing, just keep things simple and connect 1 LED to each pin and turn it on/off with digitalWrite().
 
thanks guys, I'll start coding later today. I'll start with a simple array of regular LEDS (with pauls notes taken into consideration).

photos will be taken as a project guide

cheers
Mark
 
Status
Not open for further replies.
Back
Top