Code Monkey home page Code Monkey logo

midi2usbhost's Introduction

midi2usbhost

Use a Raspbery Pi Pico to add old school MIDI IN and MIDI OUT to MIDI devices with a USB B device port.

Disclaimers

This is a hardware and software project. The MIDI gadgets you will wire to this hardware will likely cost a lot more than than the hardware for this project. Please double-check my design and test your circuit and wiring before you connect it to anything expensive. I will take no responsibility for burning up your favorite keyboard or sound module.

This projects uses commercial hardware for testing. I do not officially endorse any hardware. I have not been paid by anyone to use this hardware. A carefully designed custom board would be a better solution. The hardware combinations described here would almost certainly fail electrical and RF compliance testing. Use at your own risk.

Software

You may build one of two different programs in this project to bridge USB Host MIDI to serial port MIDI depending on whether you prefer to work with C Code or with an Arduino Sketch. Either program will run on the same hardware. If you want to build and run the C Code, follow the instructions in the README.md file in the C-Code directory. If you want to build and run the Arduino sketch, follow the instructions in the README.md file in the arduino directory.

Hardware Dependencies

This project is designed to run on the RP2040 chip. It is tested on a Raspberry Pi Pico board, but any board that provides access to the USB port and UART 1 will probably be fine.

The project uses the RP2040 UART 1 port for driving the old school MIDI IN and MIDI OUT ports. You can use whatever circuit you would like for the current loop driver for MIDI OUT and the optical isolator for MIDI IN. This project is tested using the MIDI Featherwing board. If you use this board, please note that MIDI OUT is not isolated from your processor board UART 1 TX pin, and that contrary to the MIDI specification, the UART 1 TX output pin cannot be programmed to be open drain. Also note there are no ferrite beads on MIDI IN and MIDI OUT connector pins, so radio frequency interference (RFI) may be an issue with this circuit. All that said, I have had no trouble using this circuit with the MIDI gear I have tested.

You will need to provide +5VDC to the VBus input. I use the VBUS pin from a picoprobe board.

If you use the Pico board, you will need to be able to connect your USB MIDI device to the Pico's micro USB connector. I use the least expensive micro USB to full size USB A OTG adapter I could find. I won't link to one here. Web search is your friend. Note that just using the adapter provides no current limit on the USB host VBus line, so please be careful what you connect to this.

If you choose to use the same hardware I did, wire the boards together as follows.

USB C Breakout board VBus pin -> Pico board VBUS Pin 40
USB C Breakout board GND pin  -> Pico board GND Pin 38
Pico board GND Pin 8 -> MIDI Featherwing board GND Pin 4
Pico board 3.3V Pin 36 -> MIDI Featherwing board 3.3V Pin 2
Pico board UART1 TX Pin 6 -> MIDI Featherwing board Pin 15
Pico board UART1 RX Pin 7 -> MIDI Featherwing board Pin 14

A photo of my development setup using a second Pico board as a picoprobe is below. The Pico board in the middle is running the MIDI adapter software. It is wired to the MIDI featherwing on the left and has the Micro USB to USB A adapter on it. The picoprobe is providing VBUS power and the serial port console. The picoprobe wiring is

picoprobe GND -> MIDI Pico GND
picoprobe GP2 -> MIDI Pico SWCLK
picoprobe GP3 -> MIDI Pico SWDIO
picoprobe GP4/UART1 TX -> MIDI Pico GP1/UART0 RX
picoprobe GP5/UART1 RX -> MIDI Pico GP0/UART0 TX
picoprobe VBUS -> Pico B VBUS

Pico USB MIDI Host Adapter with picoprobe on the right

midi2usbhost's People

Contributors

rppicomidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

midi2usbhost's Issues

Using raspberry pi pico as a MIDI controller

Hi. Sorry for reporting an issue but I don't see a discussion option.
I am trying to build a midi controller so that I can send midi commands to my NUX MG-300 guitar processor. I am currently using Arduino Uno for testing purposes and I have managed to send and receive messages (cc and sysex) going through PC. The problem is that arduino uno cannot be a usb host so I cannot connect MG-300 directly to it. There is an option of using a usb host shield but it is not cost effective and I think I will need more resources to implement everything that I envisioned.
I think you mentioned here hathach/tinyusb#1152 that you have an issue receiving messages from usb device. Is this resolved?
Do you think that this project can be modified so that I can send and receive MIDI messages to the MG-300?
I don't need the "old school MIDI IN and MIDI OUT" if it makes any difference.

Add CV and Gate

A lot of Synths and all modular systems use a 1V/octave control voltage for pitch, and a gate signal (low/high = note off/on). It would be great to be able to use this project to control such synths or add CV/Gate outputs to MIDI keyboards. This can be done by PWM and filters or a DAC such as the MCP4725 (I2C) for a better signal. in general, a semitone is 83.33 milivolts (0.08333 V)

USB MIDI host via built-in USB-C

I have a pimoroni lipo Pico which runs off of battery. This frees up the USB-C port. Is it possible for me to modify this project to send over usb? Apologies for the "issue".

Problems with devices with multiple virtual cables

When using a Novation 24SL MKII for example, which presents itself as a 4 virtual cable device, the device will not work and report:

WARN: starting new transfer on already active ep 0 in
WARN: startassertion "!(buf_ctrl & USB_BUF_CTRL_FULL)" failed: file "/home/xxx/dev/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.c", line 219, function: sync_ep_buffer

Capturing incoming midi pitch bend messages

Hello.
I can capture midi notes with velocity and modulation from my arturia microlab. but I the pitch bend messages, as soon as I take my hands of the pitch bend strip, seem to freeze my pico.
Is this an know issue?

Can't find #include "class/midi/midi_host.h"

Hi ๐Ÿ‘‹
I was trying to compile your code on a windows 10 with
vs code but I was not able find this file anywhere in your code (#include"class/midi/midi_host.h") can you please guide me about this issue. I have old m audio keystudio 49 that doesn't connects to Cubasis 3 but works fine with FL studio mobile on the same phone. Thanks in advance. I am getting the same error as described by fadh3r please help

Multicable error

It works beautifully! but I'm getting an error when I connect a midi device that has two virtual cables, sometimes it detects the device after 10 secs then it unmount the device.

Is the a way to get it work with a multicable device? I have only tried with a keystation mk3 it has 2 virtual cables.
when I plug a simple 1 virtual cable it works great.

Thanks

Project based on RP2040, potential firmware target

Hey,

I am the guy behind the RP2040 based USB MIDI host and I am going to release it soon.
My plan is to make the firmware open, and I was thinking for compatibility reasons and community friendlyness,
it would be nice to base it on the midi2usbhost firmware.

image

image

@rppicomidi I am happy to send you a device if you would like one.
It is powered by USB-C, has TRS-A MIDI In and Out, a USB MUX, Power switch to external device via MOSFET and much more. Wriite me an E-Mail to midihost (at) datanoise.org

Pico PIO USB Host

Hi!
Not really an issue but arduino-pico, tinyUSB and Adafruit-tinyUSB just got updated to oficially support USB hosting with PIO on the RP2040.
Maybe that can be a shortcut to get MIDI hosting working.

Problems with Midi-device Launchpad X

Hi.
First of all, great product. This was exactly what I was looking for.
I got this to work without any issues when I connected my Launchkey 37. The midi packages was sent to my midi monitor just the same as i played them.

But when I connect my Launchpad X (mk3) I behaves weird.
When I press a key, my rpipico sends the correct midi info, but when I release it, the rpipico sends the last midi message again.
This behavior continues 15 times (15 note on, 15 note off). And then the rpipico bursts out messages.
It also falls behind as if the rpipico keeps the last message.

TIMESTAMP IN PORT STATUS DATA1 DATA2 CHAN NOTE EVENT               What i played
 046D70B1   1  --     90    24    15    1  C  2 Note On               C on
 046D7241   1  --     90    24    15    1  C  2 Note On               C off
 046D779C   1  --     90    24    00    1  C  2 Note Off              C# on
 046D7936   1  --     90    24    00    1  C  2 Note Off              C# off
 046D7BC0   1  --     90    25    3D    1  C# 2 Note On               D on
 046D7D31   1  --     90    25    3D    1  C# 2 Note On               D off
 046D7F99   1  --     90    25    00    1  C# 2 Note Off              D# on
 046D811B   1  --     90    25    00    1  C# 2 Note Off              D# off
 046D8448   1  --     90    26    3E    1  D  2 Note On         C on
 046D85A4   1  --     90    26    3E    1  D  2 Note On               C off
 046D879A   1  --     90    26    00    1  D  2 Note Off              C# on
 046D88E7   1  --     90    26    00    1  D  2 Note Off              C# off
 046D8C43   1  --     90    27    4B    1  Eb 2 Note On               D on
 046D8D7A   1  --     90    27    4B    1  Eb 2 Note On               D off
 046D8F4E   1  --     90    27    00    1  Eb 2 Note Off             D# on
 046D909F   1  --     90    27    00    1  Eb 2 Note Off              D# off
 046D9323   1  --     90    24    16    1  C  2 Note On               C on
 046D9447   1  --     90    24    16    1  C  2 Note On               C off
 046D96E1   1  --     90    24    00    1  C  2 Note Off              C# on
 046D980C   1  --     90    24    00    1  C  2 Note Off              C# off
 046D99D4   1  --     90    25    41    1  C# 2 Note On               D on
 046D9ADB   1  --     90    25    41    1  C# 2 Note On               D off
 046D9E2C   1  --     90    25    00    1  C# 2 Note Off              D# on
 046D9F70   1  --     90    25    00    1  C# 2 Note Off              D# off
 046DA4DA   1  --     90    26    43    1  D  2 Note On               C on
 046DA5F4   1  --     90    26    43    1  D  2 Note On               C off
 046DA896   1  --     90    26    00    1  D  2 Note Off              C# on
 046DAA4E   1  --     90    26    00    1  D  2 Note Off              C# off
 046DAE19   1  --     90    27    47    1  Eb 2 Note On               D on
 046DAFBD   1  --     90    27    47    1  Eb 2 Note On               D off
 046DB31F   1  --     90    27    00    1  Eb 2 Note Off              D# on
 046DB320   1  --     90    24    3C    1  C  2 Note On               nothing
 046DB321   1  --     90    24    00    1  C  2 Note Off              --
 046DB322   1  --     90    25    44    1  C# 2 Note On               --
 046DB323   1  --     90    25    00    1  C# 2 Note Off              --
 046DB324   1  --     90    26    42    1  D  2 Note On               --
 046DB325   1  --     90    26    00    1  D  2 Note Off              --
 046DB326   1  --     90    27    3B    1  Eb 2 Note On               --
 046DB327   1  --     90    27    00    1  Eb 2 Note Off              --
 046DB328   1  --     90    24    2E    1  C  2 Note On               --
 046DB329   1  --     90    24    00    1  C  2 Note Off              --
 046DB32A   1  --     90    25    36    1  C# 2 Note On               --
 046DB32B   1  --     90    25    00    1  C# 2 Note Off              --
 046DB32C   1  --     90    26    43    1  D  2 Note On               --
 046DB32D   1  --     90    26    00    1  D  2 Note Off              --
 046DB32E   1  --     90    27    44    1  Eb 2 Note On               --
 046DB5D6   1  --     90    27    00    1  Eb 2 Note Off            D# off

How can I fix this?
Is there some buffer size I can change?
Is there a way to clear the buffer so it doesn't keep the last message?

/Mattias

Add dual role / switchable mode

The Raspberry Pico and my boards have the GPIO24 which can detect if VBUS is coming from USB or not. Therefore, it can detect if the device is used as USB Host or Device.

Would be great to see dual mode / switched mode depending on the state of GPIO24.

Info request

Hello everybody, I'm new to Pico world, that project looks like the one for me but for a thing, I need to send midi messages on a guitar pedalboard that uses usb type c but only works as a device. Would I be able to interact with it just sending midi signals with this code? I don't need to translate from din pins on UART, but just be able to send CCs and PCs over usb but without setting up a midi software on Pc. As I know already all the messages I need to sent, would be possible to just setup a midi host over the native usb of the Pico?

RTP MIDI

It would be very interesting to add RTP MIDI capability to this project for MIDI output over WiFi using the Raspberry Pi Pico W

Request

Hi,

building the executable t is proving a challenge as I have very little experience of C++ on the raspberry pico.

can you upload the .UF2 file to GitHub as I am sure that I am not the only one that would just like to download it and try it without having to go through the build process.

Great project btw.

Compilation error -- EZ_USB_MIDI_HOST 2.0.0

@rppicomidi thanks for sharing your code!
I now have a problem compiling midi2usbhost. Ihave done the setup according to the README.md.
Arduino IDE 1.8.20
MIDI Library 5.0.2 (also tried 4.3.1)
Raspberry PI Pico/RP2040 package 3.8.1.
All other libraries -- latest versions available.
Generic RP2040 selected (tried Feather, Raspberry Pi Pico, but no luck)
I get the following error:

midi2usbhost:51:66: error: 'MidiHostSettings' was not declared in this scope
   51 | MidiInterface<SerialMIDI<HardwareSerial, DefaultSerialSettings>, MidiHostSettings> DINmidi((SerialMIDI<HardwareSerial, DefaultSerialSettings>&)serialDINmidi);
      |                                                                  ^~~~~~~~~~~~~~~~

Please, help with this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.