MIDI keyboards?


22 posts
by liz » Tue Jun 12, 2012 11:35 pm
I just had someone ask me (or, more accurately, the Raspberry Pi Twitter account) how to hook up a MIDI keyboard - and although usually pretty glib, I wasn't able to help. Anyone had a go yet?
--
Head of Comms, Raspberry Pi Foundation
User avatar
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 4094
Joined: Thu Jul 28, 2011 7:22 pm
by ukscone » Tue Jun 12, 2012 11:41 pm
i've seen usb midi dongles around the internets so i would cautiously presume that software/drivers willing they'd work
User avatar
Forum Moderator
Forum Moderator
Posts: 2786
Joined: Fri Jul 29, 2011 2:51 pm
by TonyD » Wed Jun 13, 2012 12:52 pm
Shameless Plug ;-) I designed a serial based, the link to the design is in http://elinux.org/RPi_Expansion_Boards look for "RPi MIDI Breakout Board". You could build the circuit on strip board.
Tony
User avatar
Posts: 341
Joined: Thu Sep 08, 2011 10:58 am
Location: Newcastle, UK
by finnw » Wed Jun 13, 2012 11:44 pm
The easiest way is probably a USB<->MIDI adapter.

Most of them work with the generic driver (part of ALSA. See the discussion here.)

Look for one that does not require a driver CD under Windows (like this one) as these are most likely to work with the generic driver.
Posts: 24
Joined: Wed May 16, 2012 7:05 pm
by cheery » Thu Jun 14, 2012 8:20 am
There's a standard protocol for having MIDI through USB. Linux supports it readily.

I have an USB-pluggable MIDI keyboard I'm going to try with Raspberry Pi. It looks a lot like it'd have internal MIDI-USB chip.
User avatar
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm
by JonB » Thu Jun 14, 2012 8:43 am
I have an M-Audio Keystation Midi / USB keyboard. I could try that - but I can't play for toffee - and I haven't got sound working on my Pi yet.

:cry:
Posts: 218
Joined: Tue Nov 29, 2011 9:26 pm
by SN » Thu Jun 14, 2012 8:57 am
I also have access to a MIDI Keyboard (and a Casio electronic piano thingummy) with a MIDI -> USB cable - laughingly it wouldn't work with a Sequencer running on a Macbook but worked a treat on gold old Windows XP

Can anyone recommend a Linux MIDI Player I can try (lets do output first!) which is available for the Pi?

EDIT: Will mplayer or omxplayer do it?
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1008
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by RMW5 » Fri Jun 22, 2012 5:15 pm
Rosegarden has been around for a very long time and is a MIDI editor as well as a sequencer.

http://en.wikipedia.org/wiki/Rosegarden
Posts: 47
Joined: Fri Dec 23, 2011 4:31 pm
by Gert van Loo » Sun Jun 24, 2012 6:24 pm
I did MIDI many years ago. Connected it to a ZX spectrum. It is the standard RS232 interface but at a non-standar baudrate: 31.25 kbaud.
So yes the Pi can do MIDI. You need an RS232 converter and set the baudrate to 31.25K and off you go.
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2053
Joined: Tue Aug 02, 2011 7:27 am
by gritz » Sun Jun 24, 2012 8:44 pm
Gert van Loo wrote:I did MIDI many years ago. Connected it to a ZX spectrum. It is the standard RS232 interface but at a non-standar baudrate: 31.25 kbaud.
So yes the Pi can do MIDI. You need an RS232 converter and set the baudrate to 31.25K and off you go.


A "proper" MIDI connection (I mean the 5-pin din variety) is a 5mA current loop with an opto isolator between keyboard and UART / microcontroller / Pi, etc:

Image

Bear in mind that the image shows a 5V application. :)
Posts: 449
Joined: Sat Jan 28, 2012 2:33 am
by RMW5 » Tue Jun 26, 2012 5:21 pm
liz wrote:I just had someone ask me (or, more accurately, the Raspberry Pi Twitter account) how to hook up a MIDI keyboard - and although usually pretty glib, I wasn't able to help. Anyone had a go yet?


Not quite the same thing, but I hooked up my R-Pi to a Roland XV-3080 synth module through a Roland UA-100 USB->Midi module (but you can use any ALSA-compatible USB/MIDI adapter and they needn't cost much more than $10), and it worked almost straight out of the box playing back .mid files using "amidiplay" (part of the ALSA package).

The only issue was that the USB/Midi adapter wasn't recognised on reboot, but was recognised when the module was powered off and back on.

The R-Pi is as good as any of the Roland/Yamaha sequencer modules at driving external synths using MIDI.
Posts: 47
Joined: Fri Dec 23, 2011 4:31 pm
by Neil » Wed Jun 27, 2012 4:16 pm
gritz wrote:
Gert van Loo wrote:I did MIDI many years ago. Connected it to a ZX spectrum. It is the standard RS232 interface but at a non-standar baudrate: 31.25 kbaud.
So yes the Pi can do MIDI. You need an RS232 converter and set the baudrate to 31.25K and off you go.


A "proper" MIDI connection (I mean the 5-pin din variety) is a 5mA current loop with an opto isolator between keyboard and UART / microcontroller / Pi, etc:

Image

Bear in mind that the image shows a 5V application. :)


Yeah, I had this discussion with the MIDI Association a while back about anything other than 5V:

http://www.midi.org/cgi-bin/forum/forum ... 171180161/

:roll:
Posts: 89
Joined: Thu Sep 29, 2011 7:10 am
by NielsMayer » Mon Aug 13, 2012 4:33 am
A little late to reply, but found this thread in a search.

My progress so far re: MIDI - http://www.nielsmayer.com/bin/view/Rasp ... h+Rasbpian

Would love to hear of alternatives using built in ports as ultimately I'd like to use get TTL-level MIDI and feed it to a Yamaha db50/db60 synth clone ( http://linuxaudio.org/mailarchive/lau/2010/7/3/171112 ) then use http://qmidinet.sourceforge.net/qmidinet-index.html to turn the 'pi into a "ethersynth" .

-- Niels
http://www.nielsmayer.com/
Posts: 13
Joined: Mon Aug 13, 2012 4:25 am
by Baggypants » Mon Aug 13, 2012 7:15 pm
Hi Niels. I'm a bit confused by your link. have you actually got jackd running in rpi?
I've not been able to get it to run at all using the inbuilt sound device.

I've done some stuff with Fluidsynth (qsynth command line only) and amsynth you can see here
viewtopic.php?p=141908#p141908
Posts: 10
Joined: Tue May 08, 2012 10:46 pm
by mahjongg » Mon Aug 13, 2012 7:46 pm
The actual interface as shown here is readily adaptable for 3V3 use, but is the PI able to generate the 31.25 KBPs baudrate? That is the bigger question IMHO.
User avatar
Forum Moderator
Forum Moderator
Posts: 5480
Joined: Sun Mar 11, 2012 12:19 am
by Neil » Tue Aug 14, 2012 9:44 am
mahjongg wrote:The actual interface as shown here is readily adaptable for 3V3 use, but is the PI able to generate the 31.25 KBPs baudrate? That is the bigger question IMHO.


Easily.
Posts: 89
Joined: Thu Sep 29, 2011 7:10 am
by mahjongg » Wed Aug 15, 2012 12:05 am
Okay then, I suppose that using the UART for a MIDI port would be quite easy.
To drive the LED of the transmit opto coupler would take just a transistor and a resistor, and interfacing the photo transistor of the receiver would be even easier, the only complication would be when you want to echo the MIDI in to MIDI loop-through, but that would also be solvable with just a few transistors and resistors.

The rest is just software.
User avatar
Forum Moderator
Forum Moderator
Posts: 5480
Joined: Sun Mar 11, 2012 12:19 am
by Neil » Wed Aug 15, 2012 8:52 am
There is no opto-coupler on the transmit, only on the receive. See the schematic above showing how to do in/thru/out.
Posts: 89
Joined: Thu Sep 29, 2011 7:10 am
by mahjongg » Thu Aug 16, 2012 12:48 am
Neil wrote:There is no opto-coupler on the transmit, only on the receive. See the schematic above showing how to do in/thru/out.

Sorry was being a bit obtuse here, I meant the optocoupler in the receiver of the other MIDI device that this MIDI unit is sending current to. Calling it the "Transmit opto coupler" is indeed a bit strange.

So the PI, with the help of a simple transistor outputs a current that lights up the LED of the optocoupler in the receiver of the other MIDI device, its that optocoupler that I'm talking about, not the one built into this interface.
User avatar
Forum Moderator
Forum Moderator
Posts: 5480
Joined: Sun Mar 11, 2012 12:19 am
by Neil » Thu Aug 16, 2012 8:40 am
mahjongg wrote:
Neil wrote:There is no opto-coupler on the transmit, only on the receive. See the schematic above showing how to do in/thru/out.

Sorry was being a bit obtuse here, I meant the optocoupler in the receiver of the other MIDI device that this MIDI unit is sending current to. Calling it the "Transmit opto coupler" is indeed a bit strange.

So the PI, with the help of a simple transistor outputs a current that lights up the LED of the optocoupler in the receiver of the other MIDI device, its that optocoupler that I'm talking about, not the one built into this interface.

Ok, yes, you just need two transistors (one to invert, one to drive), or you could use a 7404 hex inverter (less soldering :D ). You need to invert because the UART idles high (+V) and MIDI idles low (no current). Again, check the schematic posted by Gritz or the one on the MIDI.org website:

http://www.midi.org/techspecs/electrispec.php

Neil
Posts: 89
Joined: Thu Sep 29, 2011 7:10 am
by mahjongg » Fri Aug 17, 2012 5:51 pm
Problem with a TTL inverters is that either you power them with 5V, and get problems with level conversion thrown in, or you need an inverter that works on 3V3, but have to adjust the resistors for a lower output voltage. But yes, in principle that is what should work.
User avatar
Forum Moderator
Forum Moderator
Posts: 5480
Joined: Sun Mar 11, 2012 12:19 am
by gazzatopdude » Mon Sep 23, 2013 3:35 pm
Hi
I have a raspberry PI on latest raspian.
I also have a CASIO CTK 700 keyboard and I want to connect via MIDI
what is the best solution?
USB or serial?
Whats the best advice?
Best Regards
Posts: 10
Joined: Sun Sep 15, 2013 10:15 am