News:

SMF for DIYStompboxes.com!

Main Menu

merge multiple MIDI in

Started by Dimitree, March 27, 2014, 07:25:19 PM

Previous topic - Next topic

Dimitree

hello everyone
I'm using an atmega328p (same as arduino uno) to control a sound module chip (that produces sounds from midi notes).
However atmega328p only have 1 UART, so I can't have more than one midi input, but I need two.
Is there any way to merge those 2 inputs on the same UART?

I don't want to use software serial emulations. I can't use I2C/SPI -> UART chips since these (along with their needed components) take too much space on my pcb and the thing starts to get too complicated.

Ground Control

I highly recommend the MIDI Solutions gear.
Cheap, work great, require no external power.

2-In 1-Out


4-In 1-Out

tommy.genes

Curious why you don't want to use software serial emulations. I wouldn't think MIDI is that demanding in terms of serial throughput, RAM or processor cycles. If you're worried about performance differences between the UART and the soft serial, make both MIDI ins soft serial ports and leave the UART out of it (or use it for something else).

As for merging two MIDI signals on the same UART, you risk having two MIDI messages from different sources arrive at the same time and, since they are physically connected to the same pins, they would interfere with each other and corrupt the information. If you are fairly certain that won't happen, you could risk just trying the MIDI y-cable approach, but since you're bothering to design/fabricate a PCB, I'm guessing this is meant to be a pretty permanent solution and worthy of good design practice.

What are your MIDI sources (keyboards, laptops etc.)? Might one of them have a merge or thru function, i.e. let you plug A into B and configure B to forward messages from A as well as its own messages?

-- T. G. --
"A man works hard all week to keep his pants off all weekend." - Captain Eugene Harold "Armor Abs" Krabs

Dimitree

Quote
Curious why you don't want to use software serial emulations. I wouldn't think MIDI is that demanding in terms of serial throughput, RAM or processor cycles. If you're worried about performance differences between the UART and the soft serial, make both MIDI ins soft serial ports and leave the UART out of it (or use it for something else).

As for merging two MIDI signals on the same UART, you risk having two MIDI messages from different sources arrive at the same time and, since they are physically connected to the same pins, they would interfere with each other and corrupt the information. If you are fairly certain that won't happen, you could risk just trying the MIDI y-cable approach, but since you're bothering to design/fabricate a PCB, I'm guessing this is meant to be a pretty permanent solution and worthy of good design practice.

I didn't want to use soft serial because I thought there was the possibility to use a simple logic IC to merge the 2 signals, obviously I was wrong :)
Like this:
http://www.sonelec-musique.com/images/electronique_midi_merger_001.gif
but I can't see (as you pointed out) how can this prevent collision between 2 messages from 2 sources at the same time.
Indeed I didn't want to use a simple Y cable approach to merge, but an active part.

Quote
What are your MIDI sources (keyboards, laptops etc.)? Might one of them have a merge or thru function, i.e. let you plug A into B and configure B to forward messages from A as well as its own messages?

no unfortunately they don't have a merge o thru function

slacker

Could you use something like a CD4066 switch to select which MIDI line you connect to the UART? Maybe flip back and forth between each one listening for traffic and once you detect some stay on that line until it's finished? I don't know enough about MIDI to know if that sort of approach would work.

TheWinterSnow

Multiplexing will be your friend.  MUX the midi channels to one one UART input and have a soft DEMUX, that way if two midi data streams come in at the same time, you don't get errors.

tommy.genes

Quote from: Dimitree on March 28, 2014, 12:17:47 PM
I didn't want to use soft serial because I thought there was the possibility to use a simple logic IC to merge the 2 signals, obviously I was wrong :)
Like this:
http://www.sonelec-musique.com/images/electronique_midi_merger_001.gif
but I can't see (as you pointed out) how can this prevent collision between 2 messages from 2 sources at the same time.
Indeed I didn't want to use a simple Y cable approach to merge, but an active part.

That's a very well-designed interface, including opto-isolation and phantom power per the MIDI standard, but I also do not see where it would prevent collisions. I'd be curious how many commercial MIDI mergers take this same approach. Maybe MIDI message collisions are just not that common in actual practice. Unlike computer network protocols, say TCP/IP, there is no retry to resend lost messages. You get a dropped or bum note, then the performance goes on.

TheWinterSnow is on to something with the multiplexing idea. Read this short Arduino forum thread to the end. With something like this switching between your two MIDI inputs at twice the baud rate of the MIDI transmission, and the UART set to that same doubled rate, I think you could effectively get two inputs muxed onto one UART.

-- T. G. --
"A man works hard all week to keep his pants off all weekend." - Captain Eugene Harold "Armor Abs" Krabs