Skip to content
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

midi note-on, velocity zero not handled as note-off #646

Closed
okyeron opened this issue Nov 20, 2018 · 1 comment
Closed

midi note-on, velocity zero not handled as note-off #646

okyeron opened this issue Nov 20, 2018 · 1 comment
Labels
lua

Comments

@okyeron
Copy link
Contributor

@okyeron okyeron commented Nov 20, 2018

while checking out midi with molly_the_poly script tonight I found I'm not getting note off messages while using a QuNexus.

Looking at midi.lua, it appears it does not account for some instruments that do not send a note-off byte, but rather a note-on byte with velocity 0 instead.

For example if I do

m = midi.connect(2)
m.event = function(data)
  local d = midi.to_msg(data)
  
  local status = data[1]
  local data1 = data[2]
  local data2 = data[3]
  print(status .. " " .. data1 .. " ".. data2)
  tab.print(d)
end

returns

144 59 105
vel	105
type	note_on
note	59
ch	1
144 59 0
vel	0
type	note_on
note	59
ch	1

so perhaps this needs to be changed in midi.lua?

   -- note on
  if data[1] & 0xf0 == 0x90 then
    if data[3] > 0 then
    --print("note")
    msg = {
      type = "note_on",
      note = data[2],
      vel = data[3],
      ch = data[1] - 0x90 + 1
    }
    elseif data[3] == 0 then
    --print("noteoff")
    msg = {
      type = "note_off",
      note = data[2],
      vel = data[3],
      ch = data[1] - 0x80 + 1
    }
    end

Should I submit this as a pull request?

Or... are there cases where a note-on, velocity zero should not be considered a note-off?

@tehn
Copy link
Member

@tehn tehn commented Nov 20, 2018

yes that sounds good. send a PR

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

Successfully merging a pull request may close this issue.

None yet
3 participants