Go Down

Topic: Arduino Mega / hairless MIDI / Input without DIN PLUG and Optocoupler (Read 4802 times) previous topic - next topic

ArduBogus

Hello guys!

I'm trying to make a midi controller to interface with Vmix software.
I've been successful on sending midi notes. My workflow is usb-> hairless Midi software -> Loop MIDI windows driver -> Vmix

So basically Hairless grabs the Arduino Mega Serial com port and links it with Loop MIDI driver that vmix recognises. And i am able to create a MIDI port on vmix for input and for outputting back to the Arduino Com port.

I am able to send hardware button presses from the arduino to the VMIX, and i did it easily without the need for any extra hardware. But the opposite is not working.
Hairless sees the note i choose coming from Vmix to the Com port, but i am not being able to read it on my arduino code.

The thing is that i only see older stuff on forums and online tutorials and most of them use optocouplers and resistors on DIN MIDI plugs to (i think ) correct logic levels. But the same way i can send them all through USB shouldn't i be able to read them also? There's so much info that i am confused.
I really wouldn't want to use DIN plugs or extra converters. Is there any way?

There are those usb hacks to change arduino USB into more of a midi HID kind of thing but then i would have to use a AVR programmer and since my mega is inside a box and the FDTI plug is not soldered, i don't want to use that solution.

Here is my test sketch only for midi inputs coming from hairless:
Its suppose to change a led color based on some note. ( it's a modified sketch from MIDI.h example callback)


#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();
#include "FastLED.h"
#define NUM_LEDS 77
#define DATA_PIN 36
CRGB leds[NUM_LEDS];
// -----------------------------------------------------------------------------

// This function will be automatically called when a NoteOn is received.
// It must be a void-returning function with the correct parameters,
// see documentation here:
// http://arduinomidilib.fortyseveneffects.com/a00022.html

void handleNoteOn(byte channel, byte pitch, byte velocity)
{
    // Do whatever you want when a note is pressed.

leds[10] = CHSV(120, 255, 255);

FastLED.show();
    // Try to keep your callbacks short (no delays ect)
    // otherwise it would slow down the loop() and have a bad impact
    // on real-time performance.
}

void handleNoteOff(byte channel, byte pitch, byte velocity)
{
    // Do something when the note is released.

  leds[10] = CHSV(255, 255, 255);

FastLED.show();
    // Note that NoteOn messages with 0 velocity are interpreted as NoteOffs.
}

// -----------------------------------------------------------------------------

void setup()
{
LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
LEDS.setBrightness(20);
  leds[10] = CHSV(255, 255, 255);

FastLED.show();
delay(500);
leds[10] = CHSV(255, 0, 255);

FastLED.show();
 
 
  //Serial.begin(115200);
    // Connect the handleNoteOn function to the library,
    // so it is called upon reception of a NoteOn.
    MIDI.setHandleNoteOn(handleNoteOn);  // Put only the name of the function

    // Do the same for NoteOffs
    MIDI.setHandleNoteOff(handleNoteOff);

    // Initiate MIDI communications, listen to all channels
    MIDI.begin(2);
    Serial.begin(115200);
}

void loop()
{
    // Call MIDI.read the fastest you can for real-time performance.
    MIDI.read();

    // There is no need to check if there are messages incoming
    // if they are bound to a Callback function.
    // The attached method will be called automatically
    // when the corresponding message has been received.
}




Thank you

spino50

Hi there. I had the same idea to switch on the leds with activators in vmix. I found this:

https://www.youtube.com/watch?v=cZmtrPImZaI&t=34s

It works perfect if Arduino receives the note by a daw but it doesn't work if it receives the note by vmix.

Can you try and check if this could be a solution?

hector0502

hola me pueden ayudar con esto? quiero que motores microservos se muevan al leer una nota musical desde un editor de partituras pero no logro dar con el codigo.Ayuda por favor!! gracias!!

Go Up