connecting an Akai midimix to a teensy 3.6/4.1

Status
Not open for further replies.

grahamguitarman

Well-known member
Hi
This is not a question, but rather a tip for those designing audio circuits.

I recently bought an Akai MidiMix to act as a control panel for my teensy synth & sequencer projects.
for £71, it gives me access to 24 pots, 16 buttons and 9 sliders with which to control my various audio projects.

Setting it up on the teensy 3.6 or 4.1 is easy. Just attach the teensy USB Hub cable to the five pin USB Hub interface on the teensy https://www.pjrc.com/store/cable_usb_host_t36.html

Plug the Midimix directly into the usb connector and you are ready to go!

In theory that is. As many other people have found, the illuminated buttons don't light up unless you send a midi note on code, and then getting them to turn off again appears to be impossible.
This had me flummoxed for a while until I discovered that the Midimix uses a very odd way of controlling the buttons.
To turn a button on, you send a midi note on command (midi1.sendNoteOn(note, 127, channel)), however sending a midi note off command (as most people were trying) does nothing!
Turns out you have to send another midi note on command but with a velocity of zero to turn the led back off again!

I've posted a sample code below that works perfectly for interfacing with the Midimix. The toggles array keeps track of whether buttons are toggled off or on, and the dials array keeps track of the values sent by the dials/sliders.

The serial commands send the midi input values to the serial monitor so you can check k the midi mix interface is working, this can be removed later for optimisation purposes.

Code:
#include <USBHost_t36.h>

USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
MIDIDevice midi1(myusb);


void setup() 
{
  Serial.begin(115200);
  delay(1500);
  Serial.println("USB Host InputFunctions example");
  delay(10);
  myusb.begin();
  midi1.setHandleNoteOn(myNoteOn);
  midi1.setHandleControlChange(myControlChange);
}
byte dials[64];
byte toggles[32];
byte toggle = 0;
void loop() 
{
  myusb.Task();
  midi1.read();
}


void myNoteOn(byte channel, byte note, byte velocity) 
{
  toggle = toggles[note];
  if(toggle == 0)
  {
    midi1.sendNoteOn(note, 127, channel);
    toggles[note] = 1;
  }
  else if(toggle == 1)
  {
    midi1.sendNoteOn(note, 0, channel);
    toggles[note] = 0;
  }
}

void myControlChange(byte channel, byte control, byte value) 
{
  dials[control] = value;
  //print out midi values
  Serial.print("Control Change, ch=");
  Serial.print(channel, DEC);
  Serial.print(", control=");
  Serial.print(control, DEC);
  Serial.print(", value=");
  Serial.println(value, DEC);
}

to access a midi cc, just use: variable = dials[dial number]
to check a button status, use: variable = toggles[button number]

Below is a chart showing the midi cc control number / note on numbers transmitted from the Midimix

Screenshot 2021-05-18 at 00.45.00.png

I hope this is enough to help anyone who wants to try out using a Midimix to control their teensy projects :)
 

Attachments

  • Screenshot 2021-05-18 at 00.28.38.png
    Screenshot 2021-05-18 at 00.28.38.png
    26.6 KB · Views: 55
Status
Not open for further replies.
Back
Top