Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for hardware midi input #2

Open
jmej opened this issue May 2, 2017 · 17 comments
Open

add support for hardware midi input #2

jmej opened this issue May 2, 2017 · 17 comments

Comments

@jmej
Copy link
Owner

jmej commented May 2, 2017

I think all this needs is this at the top of midi2dmx.ino:
#include <MIDI.h>

the following inside the setup method:

MIDI.begin(MIDI_CHANNEL_OMNI);
MIDI.setHandleControlChange(OnControlChange);

and this inside the loop:
MIDI.read();

One potential problem:

From reading this: https://www.pjrc.com/teensy/td_libs_MIDI.html
It looks like the library is hard-coded to use the serial port on pins 0 and 1. I used pin 1 for DMX output, and the DIN for MIDI is wired to pin 9 / Serial2

@PaulStoffregen do you know an easy way around that? Probably just hack MIDI.h a little bit?

@PaulStoffregen
Copy link
Contributor

I think all this needs is this at the top of midi2dmx.ino:

No, you've misunderstood. MIDI.h is for normal serial (5 pin DIN) MIDI. This project uses USB MIDI, not serial MIDI.

@jmej
Copy link
Owner Author

jmej commented May 2, 2017

@PaulStoffregen No - this project was designed to use both USB and Serial MIDI on a 5 pin din. Both are on the schematic and board... I'm just finally getting around to implementing it.

This issue is for 5 pin DIN. "Hardware MIDI input"

@PaulStoffregen
Copy link
Contributor

Oh, ok. Then yup, use MIDI.h.

@jmej
Copy link
Owner Author

jmej commented May 2, 2017

@PaulStoffregen - right. Is there a way to specify a different serial port using MIDI.h or do I need to hack the library? The DIN is wired to Serial2, DMX is on Serial1

@PaulStoffregen
Copy link
Contributor

I believe newer versions allow any port to be specified.

Teensyduino might be bundling an older version. For a while MIDI.h was broken on Teensy and the new versions added a lot of complexity, so I didn't update. Haven't looked at this for some time...

@jmej
Copy link
Owner Author

jmej commented May 2, 2017

@PaulStoffregen I'll have to give it a shot. Do you know if there is midi clock implemented in midi.h? If that's also broken it might just be time to abandon that library imo

@PaulStoffregen
Copy link
Contributor

I really do not know. I've not actually use that lib in quite some time. When I have used it, my focus has been mostly on hardware and compatibility testing, not actually making any real MIDI project.

@jmej
Copy link
Owner Author

jmej commented May 3, 2017

@PaulStoffregen teensyduino bundles an older version of midi.h?

It looks like the current versions must work with the teensy since there are issues that reference it: ex: FortySevenEffects/arduino_midi_library#63

I'm guessing the reason you bundle the older version is just that it's the one you've used and tested?

@sid8580
Copy link
Contributor

sid8580 commented Jan 15, 2018

@jmej I updated the MIDI2DMX code so hardware (5 pin DIN) MIDI now works, without impact to USB MIDI functionality. Tested via Ableton Live over USB and Elektron Octatrack over DIN MIDI with a 3 channel DMX relay. I added the code you suggested at the outset of this thread, but added this line above the setup code:

MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, MIDI);

With MIDI.h library 4.3, works fine. I can send you the working version to save a minute, & I'd love to see updates to Instructables and Github to save time and add confidence the hardware MIDI port will indeed work (a potential showstopper for some of us) should less experienced builders want to try the MIDI2DMX. It's an awesome device, thank you for the design.

@jmej
Copy link
Owner Author

jmej commented Jan 16, 2018

@sid8580 nice! Can you make a branch and pull request?

Re: the hardware midi port. I haven't been able to test it myself because unfortunately the chip I designed it for (the pc900) is discontinued - and I don't have any! Hopefully I'll get around to trying it soon - but I maybe should just rev the PCB to use an in production chip at this point..

What changes do you recommend to the instructables and github? I tried to be as clear as I could figure language-wise involving that chip stuff - but I know it's really confusing. I'm just not sure how to state things more clearly...

@PaulStoffregen
Copy link
Contributor

If you rev the PCB for a 6N138 (the best replacement), let's talk about also adding a 5 pin header + an optional USB host connector, and allowing room for Teensy 3.6 to overhang the 28 pins. I'll get you one of those MIDI test boards soon...

@jmej
Copy link
Owner Author

jmej commented Jan 17, 2018

Ok - sounds interesting. Though offhand I'm not sure why USB host would be helpful - do you have an application in mind?

@PaulStoffregen
Copy link
Contributor

One request that comes up occasionally is interfacing USB-only MIDI products to stuff that can only receive serial. But there are now lots of great USB-only MIDI products, like Novation Launchpad, which are great for user interfaces to projects.

Anyway, please check your email. I have some stuff here with your name on it... just need your current mailing address.

@sid8580
Copy link
Contributor

sid8580 commented Jan 20, 2018

@jmej - I figured out how to creach a branch/pull request, should be under Hardware MIDI for your review.
I used this octocoupler and it appears to work fine:
https://www.mouser.com/ProductDetail/638-H11L1

The Instructables page is fine, all I'd suggest is updating it to reflect the hardware MIDI updates once you feel comfortable. It's technical stuff, can't be made fully idiot proof!

I would agree with Paul that adding USB host capability would be very helpful for some. It's got me thinking I'd like to build something to do this (I'm guessing there are plenty of projects already out there to choose from), for my own rig. The need does come up and it could potentially add the ability to route different MIDI signals out of my devices that have both USB and DIN MIDI (reducing the need for external MIDI I/O splitters and whatnot).

@jmej
Copy link
Owner Author

jmej commented Mar 20, 2019

@PaulStoffregen can I use serial1 for midi/din in and DMX out? Or is it better to stick to 2 separate ports for that?
For rev2 I'm considering using teensy pin 0 for hardware/DIN midi in (with a 6n138) and pin 1 for DMX out (using a Max485) but not sure if the libraries will be fighting over serial1.

@jmej jmej closed this as completed Mar 20, 2019
@jmej jmej reopened this Mar 20, 2019
@PaulStoffregen
Copy link
Contributor

can I use serial1 for midi/din in and DMX out?

No, because the baud rates are different. Both pins of the same port run at the same baud rate.

Or is it better to stick to 2 separate ports for that?

Yes

@jmej
Copy link
Owner Author

jmej commented Apr 1, 2019

Good to know - thanks @PaulStoffregen !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants