Arduino and Mixxx (MIDI) | How to control Mixxx with Arduino (SOLVED!)

Hello there,

So I want to make Arduino talk to the Software Mixxx (DJ Software). Here's what I have done:

  • I am using an Arduino Uno and 1 button connected at pin 9.
    Every time I press the button, the Arduino sends a command as shown at the code here:
void setup()
{
  pinMode(9, INPUT_PULLUP);
  Serial.begin(115200);    
}

void loop()
{

  if (digitalRead(9) == LOW) {
    MIDImessage(0x90, 1, 0x01);
    delay(100);
    MIDImessage(0x90, 1, 0x00);
    delay(1000); 
  }
 
 delay(10); 
}


void MIDImessage(byte command, byte data1, byte data2) 
{
  Serial.write(command);
  Serial.write(data1);
  Serial.write(data2);

}

To make a virtual MIDI, I am using Hairless MIDI to get commands from the Arduino and then loopMIDI to make the "virtual MIDI". Everything works fine. I open the Mixxx Programm and go to controllers. I can see my "virtual controller". I select it and I am trying to use the Learning Wizard function without success. It does not understand the key that I am pressing and at the end, it says " Didn't get any midi messages. Please try again". So my question is: Is my code ok when it comes to midi commands? Anyone who has tried a similar project to give me some advice? Thank you in advance!

-Note: I used VirtualDJ to map my button and it does detect it and I can see variables changing but I can not use it since this function needs full version on the software, aka buy it...

What MIDI message do you think you're sending? Looks like a very short note 1 with a low velocity of only 1 to me. Is that what the software expects?

Steve

Hey Steve,

Thank you for your answer! To be honest, I am not sure what the software expects. I am kinda new at this. I think that I could find info here: Home · mixxxdj/mixxx Wiki · GitHub but I don't know what to look for. Also, I added a potentiometer and tried an online midi "software" (you.dj) and the potentiometer worked. Also, it recognized the button. Here's the new code:

void setup()
{
  pinMode(9, INPUT_PULLUP);
  Serial.begin(115200);   
}

void loop()
{


 val = analogRead(0) / 8; 
 
 if (val != lastVal)
  {
 
    MIDImessage(176, 1, val);
  }  
 
  lastVal = val;



  if (digitalRead(9) == LOW) {
    MIDImessage(0x90, 1, 0x01);
    delay(100);
    MIDImessage(0x90, 1, 0x00);
    delay(1000);
  }
 
 delay(10);
}


void MIDImessage(byte command, byte data1, byte data2)
{
  Serial.write(command);
  Serial.write(data1);
  Serial.write(data2);

}

Most MIDI tone generators won't respond to note numbers less than about 20.
Try changing:-

MIDImessage(0x90, 1, 0x01);
    delay(100);
    MIDImessage(0x90, 1, 0x00);

to

MIDImessage(0x90, 60, val); // so your pot controls the volume of the note.
    delay(100);
    MIDImessage(0x90, 60, 0x00);

Also note that sending a message of 176 is a CC message and 1 is the Modulation Wheel or Lever.

It looks like your program is working fine. If other DJ software can recognise the MIDI messages you're sending then the problems you're having are just how to get your Mixxx software to do anything with those same messages. I doubt if you can get much help with that here. Most of us, like me, have probably never used or even heard of Mixxx.

I see you've asked the same question in the Mixxx forums with not much luck. Perhaps be a bit more specific...maybe say you are sending a MIDI NoteOn (0x90), 1, 1 for button down and NoteOn, 1, 0 for button release and ask what steps you need to take to get those recognised by Mixxx?

Steve

All right guys, problem SOLVED!!!

I am posting here what I did and fixed it in case anyone else wants to do it too!

You can find some info here as well: How to Make a MIDI Controller with an Arduino

So I am using loopMIDI (loopMIDI | Tobias Erichsen) and HairlessMIDI (The Hairless MIDI<->Serial Bridge). Download and install those programs from the links. Also, download and install at Arduino IDE this library: GitHub - FortySevenEffects/arduino_midi_library: MIDI for Arduino Next upload this sketch at Arduino:

#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>

int val = 0; 
int lastVal = 0;


MIDI_CREATE_INSTANCE(HardwareSerial, Serial, midiOut);

void setup() {
  pinMode(9, INPUT_PULLUP);

  Serial.begin(115200); 
}

void loop() {

  val = analogRead(0) / 8;
  if (val != lastVal)
  {

    midiOut.sendControlChange(55, val, 1);
  }
  lastVal = val;


  if (digitalRead(9) == LOW) { 
    delay(10); // 
    if (digitalRead(9) == LOW) { 
      midiOut.sendControlChange(56, 127, 1); // send a MIDI CC -- 56 = note, 127 = velocity, 1 = channel
      delay(250);
    }
  }

}

Note: Code is for 1 button connected at pin 9 and 1 potentiometer at pin A0. You can add more buttons/potentiometers later but remember to change channel (midiOut.sendControlChange((put a number here), 127, 1); )

Next, run loopMIDI HairlessMIDI and setup them (search about it). Then go to Mixxx, go to options and preferences. If everything is ok, you should see the "virtual MIDI" controller at the "controllers" section. Use Learning Wizard to set up your buttons and you are done! Feel free to ask for any questions!