Skip to content

AttributeError: 'NoteOff' object has no attribute 'velocity' #47

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
touchgadget opened this issue Dec 24, 2021 · 1 comment · Fixed by #48
Closed

AttributeError: 'NoteOff' object has no attribute 'velocity' #47

touchgadget opened this issue Dec 24, 2021 · 1 comment · Fixed by #48

Comments

@touchgadget
Copy link

touchgadget commented Dec 24, 2021

EDIT 2: No, still a problem with the program below but my longer program sort of works.

EDIT 1: SORRY, I updated to the 20211211 libraries and note-off velocity works fine!

This seems similar to #42. Changing velocity to _velocity works around the problem.

import time
import adafruit_midi
import usb_midi

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

MIDI = adafruit_midi.MIDI(midi_in=usb_midi.ports[0], midi_out=usb_midi.ports[1])

while True:
    msg = MIDI.receive()
    if isinstance(msg, NoteOn):
        print(time.monotonic(), 'Note-On', msg.channel, msg.note, msg.velocity)
    elif isinstance(msg, NoteOff):
        print(time.monotonic(), 'Note-Off', msg.channel, msg.note, msg.velocity)
@dhalbert
Copy link
Contributor

Looks like NoteOff needs the same kind of fix as in https://github.com/adafruit/Adafruit_CircuitPython_MIDI/pull/44/files.

In your test program above, there is no msg.velocity, so that printing would fail.

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

Successfully merging a pull request may close this issue.

2 participants