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){
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