Skip to content

NoteOff does not return a note value #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DyerMaker953 opened this issue Sep 17, 2021 · 3 comments
Closed

NoteOff does not return a note value #43

DyerMaker953 opened this issue Sep 17, 2021 · 3 comments

Comments

@DyerMaker953
Copy link

Hi,

I'm trying to trigger LED lights on and off based on corresponding midi notes received.
I noticed when a NoteOn event is receive, the midi.receiver() captures a 'note' value, which I can use to identify the note/source. However, when NoteOff is received, there is no value assigned to 'note', and I'm unable to figure out how to tell which source generated the NoteOff signal.

Curious if this is intentional, or am I perhaps doing something incorrectly?

Thanks!

@tannewt
Copy link
Member

tannewt commented Sep 17, 2021

It looks like it should work. Please post your test code and let us know what is generating the MIDI NoteOff message. Thanks!

@DyerMaker953
Copy link
Author

DyerMaker953 commented Sep 17, 2021

Thanks for the quick reply! I've stripped down the code I'm using to make it a little simpler, but still replicate what I'm seeing.
I'm mostly working with a Roland TD-17 drum module, but also have a Korg Kross 2 keyboard which is having the same result.

If I run either of these devices through my computer into 'MidiView', I see notes specified for both NoteOn and NoteOff events.

I'm running my code on a Feather M4 Express using an rx/tx uart midi breakout board.

import board
import busio
import adafruit_midi

from adafruit_midi.note_off import NoteOff
from adafruit_midi.note_on import NoteOn
from adafruit_midi.midi_message import MIDIUnknownEvent

# Import MIDI
MIDI_channel = 10
uart = busio.UART(board.TX, board.RX, baudrate=31250, timeout=0.001)  # initialize UART
midi = adafruit_midi.MIDI(
    midi_out=uart, midi_in=uart, in_channel=MIDI_channel - 1, debug=False
    )

# Main Loop
while True:
    msg = midi.receive()

    if isinstance(msg, NoteOn) and msg.velocity != 0:
        print(msg.note, ":", msg.velocity, ":", msg.channel+1)
        

    elif (isinstance(msg, NoteOn) and msg.velocity == 0) or (isinstance(msg, NoteOff)):
        print(msg.note, ":", msg.velocity, ":", msg.channel+1)


    elif isinstance(msg, MIDIUnknownEvent) and msg.status != 254 and msg.status != 248:
        print("MIDIUnknownEvent:", msg.status)


code.py output:
81 : 81 : 10
Traceback (most recent call last):
  File "code.py", line 26, in <module>
AttributeError: 'NoteOff' object has no attribute 'note'

@kevinjwalters
Copy link

NoteOff is currently broken, see #42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants