[LAD] MIDI in jack

Flávio Schiavoni fls at rendera.com.br
Mon Jul 7 16:00:53 UTC 2014


Great! I dunno if you need to argue about why to develop it because it 
sounds to me a nice project.
You are right about the key_press / key_release events, a kb can trigger 
both.
You said you already know how to capture kb events without a kernel 
module.
Do you need to run it with sudo?
I'm asking it to try to help with your other doubt involving Jack MIDI 
or ALSA MIDI.
Here goes my 3 cents.
If you need to run it with sudo, maybe the best approach is to divide 
the system in a client / server paradigm.
One part is the kb event capture, running with sudo, and the other one 
to generate MIDI events, in user space, no matter which API is used.
You can use RPC, DBUS or a UDP socket in localhost to exchange data 
between both parts.
So, a kb event capture daemon will act as a server getting kb events and 
sending it through a UDP connectionless socket, for instance.
It is fast enough.
The Jack / ALSA MIDI part will act as a client listening the UDP port, 
capturing the kb events and generating the MIDI event.
The user will have to start the daemon (server) with sudo and the client 
in user space and maybe you can have a nice app granting the user a 
choice between ALSA or JACK implementation.

Best regards!

Schiavoni

Em 07-07-2014 03:54, Len Ovens escreveu:
> On Mon, 7 Jul 2014, Flávio Schiavoni wrote:
> 
>> It sounds to me like a keylogger as the input + MIDI (Jack or ALSA) as 
>> output. Maybe a ring buffer or something in between.
>> 
>> If a keylogger is the kind of input you wish:
>> https://www.thc.org/papers/writing-linux-kernel-keylogger.txt
> 
> Key logger yes, but not built into the kernel... I remember rolling a
> kernel with the install (before modules showed up) and for every
> update too, but I already have examples that work after the kernel,
> but before X.
> 
>> Trying to guess a naive code implementation, I foresee two problems:
>> - If one press a key and keep it pressed, the computer keyboard 
>> repeeeeeeeeeeeeeeeeeeeeat the key, generating several NOTE_ON midi 
>> events.
> 
> Yes, that can be generated inside the kb. And as I want to use a USB
> Kb, it could be worse. I think the typmatic rate can be changed
> though... Yup, if X can turn it off, so can I. actkbd allows setting
> changes based on key up or down.
> 
>> - Without a high level API I don´t know if you will have a KEY_RELEASE 
>> event to generate a NOTE_OFF event. If you have it you can solve the 
>> former problem.
> 
> According to what I have read (I may be wrong, or it may not apply to
> all KB) when the kb repeats it sends both on and off. So turning it
> off seems like a good idea.
> 
> I wasn't thinking of making a synth kb to turn notes off and on, but
> some of the sw seems to do that just fine, X based or event based.
> 
> I want to do this in steps:
> - Use a laptop extra number kb for transport control.
> - Split the system kb to do the same thing
> - play with a second keyboard see if I can get encoders to make sense.
> 
> This is the hardware I have on hand. If it works the way I want I will
> try further mods. The LSMI project puts it into words better than I
> do. It also says old AT kb are best.... I have one, but do not want
> break it because the touch is so nice, I have been buying MB that it
> will work with. USB kb are cheap at $3 if you know where to look. I
> can afford to break one. I will never be able to press all the keys at
> the same time, there will many key combinations that will not work
> too, but there may be still a lot of uses for it.
> 
> The big thing is it will teach me more about code and the system. I
> could just go and buy a midi controler.
> 
> 
> --
> Len Ovens
> www.ovenwerks.net


More information about the Linux-audio-dev mailing list