Loading... Please wait...

Sign up for our newsletter

Please note we're currently out of production. If we get enough interest, we may do a crowd sale supported run in the future. Let us know if you're interested!

You can also follow us on twitter.

Our Newsletter

Controlling Individual VMeter LEDs, Programming Interface, and Demos: Binary Clock, Game of Life and More

 

This tutorial will show how to control individual LEDs on the VMeter using special MIDI commands. A variety of demos are illustrated in the following python script.

 

note: hardware rev B and firmware 1.28+ required.

  

 

  • Using the position and pressure outputs directly
  • Cursor display
  • Binary counter
  • Binary clock
  • LED Chase
  • Page scrolling effect
  • CPU Monitor display (with smoothing envelope follower)
  • Game of Life Simulation

Download: VMeter_python_demos.py (more details are in comments in the code).

 

To run, type "python VMeter_python_demos.py". Note: you will first need to install pyMidiPort if on OS X, and possibly some additional libraries for the CPU monitoring demo (http://code.google.com/p/psutil/).  Please see our pyMidiPort tutorial for the harrowing details.

 

Individual LED Control Protocol

There are 38 LEDs that can be individually addressed by sending "aftertouch" commands over MIDI channels 14, 15 and 16.

 

Aftertouch MIDI command structure (3 bytes long)

  • 1st byte: first 4 bits are the "aftertouch" command (0xA), followed by the MIDI channel. So an aftertouch command over channel 1 is 0xA0, and over channel 16 is 0xAF.
  • 2nd byte: data byte, originally the note number, but used to set 7 LEDs. The 8th bit is reserved to differentiate between status and data bytes.
  • 3rd byte: data byte, originally the pressure, but repurposed to set 7 LEDs.

 

Aftertouch Commands to LED Mapping

Since only 14 bits can be sent with each aftertouch command, 3 commands (with 6 data bytes) must be sent to cover all 38 LEDs.
 
vmeter-aftertouch-midi-led-mapping.png
 
 

Examples

To set the first 4 LEDs on, and all other off, send:

0xAD, 0x0F, 0x00

0xAE, 0x00, 0x00

0xAF, 0x00, 0x00

 

To set every other LED on and off, send:

0xAD, 0b01010101, 0b00101010

0xAE, 0b01010101, 0b00101010

0xAF, 0b01010101, 0b00000010

 

Note that only the first 3 bits (LSBs) of the 2nd byte of the 3rd command are used.

 

Converting an array to 6 data bytes in python

def SendArray(array, MidiOut):

    # assuming 38 length array

    # need to split array into (6) 7bit chunks

    # Individual LED control is sent to the aftertouch MIDI command and channels 14, 15 and 16.

    # Each of the data bytes transmit 7 LED states.

    bytes = [0,0,0,0,0,0]

    bytes[0] = array[0] | array[1]<<1 | array[2]<<2 | array[3]<<3 | array[4]<<4 | array[5]<<5 | array[6]<<6
    bytes[1] = array[7] | array[8]<<1 | array[9]<<2 | array[10]<<3 | array[11]<<4 | array[12]<<5 | array[13]<<6
    bytes[2] = array[14] | array[15]<<1 | array[16]<<2 | array[17]<<3 | array[18]<<4 | array[19]<<5 | array[20]<<6
    bytes[3] = array[21] | array[22]<<1 | array[23]<<2 | array[24]<<3 | array[25]<<4 | array[26]<<5 | array[27]<<6
    bytes[4] = array[28] | array[29]<<1 | array[30]<<2 | array[31]<<3 | array[32]<<4 | array[33]<<5 | array[34]<<6
    bytes[5] = array[35] | array[36]<<1 | array[37]<<2

    MidiOut.WriteShort(0xAD,bytes[0],bytes[1])
    MidiOut.WriteShort(0xAE,bytes[2],bytes[3])
    MidiOut.WriteShort(0xAF,bytes[4],bytes[5])