[LAU] GPIO to alsa

Raphaël Mouneyres rmouneyres at gmail.com
Sun Feb 28 19:47:59 UTC 2016


> I was originally planning to take my $3 keyboard and cut it up into 4 switch rows and rewire it, and plug the USB into into my RPi... done, I have the SW to compile on the rpi already to go :) The "rollover" is only 4 and it would probably be nice to have more, but a lot of the mechanical KB have "n rollover" if they are used with PS2. So I am going to see if I can set up one of the RPi serial lines to deal with that.

hello Len, I had deep^ly looked at you excellent work with this keyboard midi controller when you mentioned it on the list. Excellent work !

> 
>> After searching for information, nothing revelant was found, except a experimental python script to read gpio and using the mididings library to output messages.
> 
> What kind of a keyboard for what use? If you mean a piano style keyboard then latency becomes more important. I would suggest script may not be the best way to go. c or c++ makes more sense.

oops, yes my question is about Piano/Organ keyboards.
C programming is the intended way 

> 
>> Is there a existing project which would scan rows/colums of a keyboard from the designated(configured) gpios, and throw midi message to an alsa midi port ?
> 
> My next phase for midikb (the SW I used above) is to add ALSA MIDI to the mix. However, have you looked at:
> http://ucapps.de/
> http://wiki.midibox.org/
> They do not use the RPi mostly because this project has been around longer than the RPi.

Let me explain why I try to know if this is possible :
The raspberry board is intended to run a single organ/piano application (jackd is not mandatory here) as a standalone board.
In order to keep the keyboard size and electronics to a minimum, using the onboard gpios for keyboard scanning would be wonderfull.
Be aware that for now the raspberry is running perfectly with a cheap USB MIDI keyboard.

> 
>> Would such a program better be a kernel module or a userland program ?
> 
>  Making a kernel module/patch is at another level of programming which i may attempt some day by starting with the snd-serial-u16550 or mpu401 code.

This is why it could be a good training for me aswell.
Using the snd-serial-u16550 and adding the scanning code was part of the plan, and I was wondering if anyone tried it before. 
It looks like nobody did ;)

> Placement of diodes on switches is important to allow chording (more than one switch at a time).

The keyboards I have (from unrepaired pianos/organs) have all the diode matrix in place. Ready to use.

> After you have this input you will want to do some debounce. Then you have a list of keys that are down. What you do with them from there is up to you, some kind of a lookup table to convert from key to MIDI note... 8 address by 8 data lines will give you 64 keys. Thats 16 GPIO lines for no external circuitry. The RPi is not overflowing with gpio that are not multipurpose... so maybe try this:
> http://pi.gadgetoid.com/article/building-the-pico-piduino

this is only a lightweight arduino way to do the thing, I would not learn anything new using this µp, and I love to learn new things.
Would it be that nobody tried it before because it is so easy to do with an external µp ?

> or this:
> http://www.hardkernel.com/main/products/prdt_info.php?g_code=G135390529643

would better use multiplexers on the GPIOs

> 
> Not very comprehensive for sure. However, that is what DIY is all about, Take the bits, do research, make something new.

indeed, your answers are part of the quest.

Raphaël


More information about the Linux-audio-user mailing list