Re: [keykit] Digest for keykit@googlegroups.com - 3 updates in 1 topic

23 views
Skip to first unread message

Mike Edwards

unread,
Oct 24, 2017, 1:54:03 AM10/24/17
to key...@googlegroups.com
I would be interested to hear if alsa midi in is working on the Linux version

On 24 Oct 2017 5:57 a.m., <key...@googlegroups.com> wrote:
Luka...@web.de: Oct 23 12:30PM -0700

Hello,
I am completely new to keykit, but after reading and searching for a
solution many hours I could not find an answer.
My e drumset is connected via midi to usb to my computer. However, when I
play two pads at the same time, one pad plays two noteon signals instead of
noteon and noteoff. So I want to connect my midi controller to keykit to
send a noteoff signal instead of a second noteon signal and then redirect
the output to hydrogen.
So my question is: how to connect my midi controller output to keykit and
the keykit output to hydrogen? I cannot see keykit midi ports in qjackctl
in the ALSA-MIDI tab and hat no success creating ports in keykit with the
port enabler tool.
I would be glad if someone could provide e a resource which explains how to
do this.
Thanks in advance.
 
Lukas
Tim Thompson <m...@timthompson.com>: Oct 23 02:51PM -0700

I only use Windows for keykit things, so can't help you very much with
Linux-specific questions on MIDI routing. Keykit doesn't create MIDI
ports, it only lets you see and enable ports that the OS already knows
about. On Windows, MIDI ports for internal routing can be created with
software like LoopBe which you can find at http://www.nerds.de/ .
 
...Tim...
 
Olaf Schulz <funwit...@googlemail.com>: Oct 24 12:39AM +0200

Hello Lukas,
 
I would suggest to use the following Keykit functions.
 
       Name: outport (lib/util2.k:197)
      Usage: outport(port)
Description: Opena a MIDI output port
 
       Name: inport (lib/util2.k:189)
      Usage: inport(port)
Description: Open a MIDI input port
 
       Name: mapport (lib/util2.k:201)
 
      Usage: mapport(ip, op)
Description: -
 
 
I can not test it for inputs, because I had no input device connected,
but the following function opens up an output.
Open lib/keylocal.k (and/or copy it a folder up?!) and replace the
original keylocal()-function with
 
# Setup a ALSA connection
# Adapt connect_alsa.sh on your environment if ness.
function enable_output(){
  Contribdir = "contrib"
   if( Machine == "linux" || Machine == "unix" ){
        outalsa = outport(1)
        mapport(0,outalsa)
        # system("Optional command to connect to new created port")
   }
}
 
(You could also call this manually from keykits window.)
After this, I could connect to with aconnect (or in qjackctl under
Connect>Alsa). Probably you could just add two lines to enable an
'inport', too.
 
Regards Olaf
 
 
Am 23. 10.2017 um 23:51 schrieb Tim Thompson:
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to keykit+unsubscribe@googlegroups.com.

Olaf Schulz

unread,
Oct 24, 2017, 11:33:06 AM10/24/17
to key...@googlegroups.com

Am 24.10.2017 um 07:54 schrieb Mike Edwards:
I would be interested to hear if alsa midi in is working on the Linux version


I've now tested it. First off all I should note, that the port enabler tool of keykit
works as expected. After enabling the input port, Keykit was listed listed as midi input decive (aconnect -l)
I've converted the code into a function, which can be called at startup:

# Input args: name - like name in Midi Port Enabler, i.e 'in 1'
function enable_input(name){


  if( Machine == "linux" || Machine == "unix" ){
    inports = midi("input", "list")
    t = "input"
    bfound = 0
    for( p in inports ){
      if( inports[p] == name ){
        bfound = 1
        if ( midi(t,"isopen",p) ){
          print("MIDI "+t+" "+string(p)+" was already open.")
        }else{
          print("Open MIDI "+t+" "+string(p)+"")
          midi(t,"open",p)
        }  
        break;
      }  
    }  
    if( bfound == 0){
      print("Input name not found. Available are:")
      print(inports)
    }  
  }else{
    print("Function had no effect on "+Machine)
  }
}


In Keykit, I call „enable_input("in 1")“, the „enable_output()“ function of the previous post and then
user@rpi3:~/software/keykit $aconnect 20:0 129:1
user@rpi3:~/software/keykit $aconnect 128:0 129:0
user@rpi3:~/software/keykit $ aconnect -l
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 20: 'Portable Grand' [type=kernel]
    0 'Portable Grand MIDI 1'
        Connecting To: 129:1
client 128: 'FLUID Synth (19704)' [type=user]
    0 'Synth input port (19704:0)'
        Connected From: 129:0
client 129: 'keykit' [type=user]
    0 'keykit          '
        Connecting To: 128:0     <--- Ok
    1 'keykit          '
        Connected From: 20:0  <--- Ok

As documented on http://nosuch.com/keykit/doc/doc/tutorial.html, Keykit redirects the input to the output
and store the notes into 'Recorded'

I should be note that print(Recorded) tells us that the recorded notes contain the absolute time stamp. Replaying
such input needs a shift.

Finally, I want come back to the original question. I've wrote this test script, which reacts at each keyup (not on keypress?!) of my keyboard.
Hope this helps out to find a solution for the No-NOTEOFF-problem.
(@Tim: Or exists an 'event hander' for the input which can be replaced/overwritten? This would be a better approach.)

function test_rec()
{
  RUN_TEST = 1
 # Merge = 0  # Do not propagate midi input to midi output
  print("Loop started")
  while (RUN_TEST) {
    bNewData = 0
    for( note in Recorded ){
      time_offset = note.time
      bNewData = 1
      break; # Abort after first note. I just need the earliest.
    }  
    if( bNewData ){
      ph = Recorded
      Recorded = ''  # Clears recording

      # TODO: Made a distinction if this should be a NOTEON or NOTEOFF ...
      if( 1 ){
        # ph.time -= time_offset
        ph.time = 0
        ph.type = NOTEOFF
        print(ph)
        realtime(ph, Now)
        realtime('do4v120', Now)  # Just for debugging...
      }  
    }  
    sleeptill(Now+1)
  }
  print("Loop quited")
}


Regards Olaf
Reply all
Reply to author
Forward
0 new messages