Commit 36cae131 authored by Koen Martens's avatar Koen Martens

Rename client, prevent repeating sounds

parent 7407cd4c
#!/usr/bin/env python3
"""JACK client that prints all received MIDI events."""
import jack
import binascii
import mido
......@@ -9,7 +7,7 @@ import queue
import soundfile as sf
import numpy as np
client = jack.Client('MIDI-Monitor')
client = jack.Client('MIDI Music Trainer')
midi_port = client.midi_inports.register('input')
audio_port = client.outports.register('verdict')
......@@ -23,12 +21,8 @@ block_size = client.blocksize
@client.set_process_callback
def process(frames):
for offset, data in midi_port.incoming_midi_events():
# print('{0}: 0x{1}'.format(client.last_frame_time + offset,
# binascii.hexlify(data).decode()))
# print(data[:])
parser.feed(data[:])
for message in parser:
# print(f'queue {message}')
message_queue.put(message)
try:
data = audio_queue.get_nowait()
......@@ -86,8 +80,10 @@ with client:
print(f'get {message}')
if message.type == 'note_on':
notes_on.add(message.note)
else:
elif message.type == 'note_off':
notes_on.remove(message.note)
else:
continue
print(notes_on)
print([describe_note(note) for note in notes_on])
verdict = judge_notes(notes_on)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment