MIDI DIN and MIDI USB Input

Hello all,

I am very new to this space so please bear with me. I am a master’s student trying to build my simple polyphonic synth for my research. I have a good understanding of electronics building my own DIY monophonic synth last year but my coding experience is not as good. I have not coded for close to 6 years!

For more context, I’m using a Daisy seed 65 MB with the program studio visual code in C++.

I am aware of the many projects online showing MIDI input, however, I’m struggling to understand how these projects have been put together.

I plan to create a MIDI in circuit such as this:

!(https://img.youtube.com/vi/GxfHijjn0ZM/maxresdefault.jpg “MIDI for the Arduino - Build a MIDI Input Circuit”)

MIDI for the Arduino - Build a MIDI Input Circuit

Once I have created this circuit how can I create some code that will take the MIDI Din input signal and then output the notes pressed in the terminal/output so I can see the Daisy seed is receiving the data?

Another question I can’t seem to find an answer to online is whether there is support for USB Midi. In this case, it would be from a MIDI signal from an AKAI LPK25 which doesn’t have a MIDI Din socket, so the connection would be a Micro B USB output from the AKAI, with a USB Male A being an input for the Daisy Seed which is what would usually go into my computer. I am aware that the Daisy seed might not have enough power to support the keyboard but I’m not sure about this.

I appreciate anyone who takes the time to read this, I apologize if I have muddled up terms, I am learning as I go along and super excited to see where my project could end.

I have copied this post from a different categories so I can get more chance of a reply.

Sorry this forum is so dead and unhelpful here!

What you’re talking about is daisy as a USB host, which I just had a search around and found this page talking about it: USB Host/OTG support

I would suggest just getting a different keyboard if it doesn’t have a normal midi in/out.

Think what you need for basic midi operation is an optoisolator, a diode and a resistor, along with the midi din or you can do over 3.5mm jack, that’s getting more common, as to save space in designs.

Midi uses the UART pins on the daisy, RX/TX I believe off the top off the noggin.

To display your values as your going via the serial monitor, you can use an extension in vscode to connect to the daisy and do serial monitoring.

There’s a logger class, have a look in the examples.

your midi reading function is here:

// Typical Switch case for Message Type.
void HandleMidiMessage(MidiEvent m)
{
    switch(m.type)
    {
        case NoteOn:
        {
            NoteOnEvent p = m.AsNoteOn();
            char        buff[512];
            sprintf(buff,
                    "Note Received:\t%d\t%d\t%d\r\n",
                    m.channel,
                    m.data[0],
                    m.data[1]);
            hw.seed.usb_handle.TransmitInternal((uint8_t *)buff, strlen(buff));
            // This is to avoid Max/MSP Note outs for now..
            if(m.data[1] != 0)
            {
                p = m.AsNoteOn();
                osc.SetFreq(mtof(p.note));
                osc.SetAmp((p.velocity / 127.0f));
            }
        }
        break;
        case ControlChange:
        {
            ControlChangeEvent p = m.AsControlChange();
            switch(p.control_number)
            {
                case 1:
                    // CC 1 for cutoff.
                    filt.SetFreq(mtof((float)p.value));
                    break;
                case 2:
                    // CC 2 for res.
                    filt.SetRes(((float)p.value / 127.0f));
                    break;
                default: break;
            }
            break;
        }
        default: break;
    }
}

this what you do in the main loop to get it crack-a-lacking:

    hw.midi.StartReceive(); // start receive function, nice and self explanatory!
    for(;;)
    {
        hw.midi.Listen(); // listen like a good little ear person
        // Handle MIDI Events
        while(hw.midi.HasEvents()) // while this has some event
        {
            HandleMidiMessage(hw.midi.PopEvent()); // handle the sausages
        }
    }
// Typical Switch case for Message Type.
void HandleMidiMessage(MidiEvent m)
{
    switch(m.type)
    {
        case NoteOn:
        {
          // this essentially your call back for midi Note on messages. 
          // this will fire when there's a note on event. You could try logging this data now
          // as a challenge, find the Logger class, find how it's printing, and now use that 
          // information to print the midi value, once you've done setting up the logger. 
          // you can just use hw.PrintLine() to print your debugging statements
         [spoiler] // remember to : hw.StartLog(true); //true == wait for PC, will block here until you connect[/spoiler]
        }

Hth’s.

As someone who is also pretty new, I just figured this out myself today.

The answers to your questions can all be found in the Daisy Examples folders. The Pod folder contains an example of MIDI DIN In (since it has one pre-soldered to the board), and the Seed folder contains a USB MIDI example.

If you’re not using a Pod and need to breadboard all of these connections yourself, it was recommended that you also install the MIDI Libraries by FortySevenEffects/Francois Best and lathoub in the Arduino IDE Library Manager.

For USB MIDI, you need to make sure that your Daisy is recognised in the Windows Device Manager as a sound device. This means you can also send and receive MIDI from your DAW if you want to, or another instance of Max/plugdata etc.

The sound results are very basic for the examples, there are no ADSR envelopes or velocity sensitivity, but much more importantly they work!

Oh and should go without saying but you also need to use a Micro USB cable that carries both data and power. I use an ST-Link so had never needed to do the whole boot/reset combo to build and program… guess how many hours I spent troubleshooting that.