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

Notes with Velocity of 0 is not always equivalent to Note off #174

Open
yenyesorr opened this issue Feb 12, 2023 · 2 comments
Open

Notes with Velocity of 0 is not always equivalent to Note off #174

yenyesorr opened this issue Feb 12, 2023 · 2 comments

Comments

@yenyesorr
Copy link

Hi,

I am experimenting with ToneJS which internally uses MIDI-FILE to parse and write midi files.

I noticed certain notes were absent in the buffer but present in the midi file. The notes that are absent are the notes with a velocity of 0.

Currently it appears MIDI-FILE might be have a basic default interpretation of velocity of 0 (which is note_off). Instead of a note_off message, one popular convention is to use note_on with a velocity of 0. In this case the midi note number of the two successive notes remain the same.

However there are instances where there could be successive notes with velocity of 0 but with different midi note number.

It appears one of the uses of this information is for initiating and terminating portamento.

Required Change in Midi Parser:

Maybe when the midi note number changes, if MIDI-FILE does not flag these notes with velocity of 0 as note_off, it could probably appear without getting purged by ToneJS (Note: ToneJS does not have entries in the buffer for note_off messages)

Caveat : I am a sort of beginner to both ToneJS and MIDI and do not claim expertise in either. However I checked with certain folks that have better MIDI knowledge who have confirmed that midi note messages with velocity of 0 play an important role and should not be ignored or taken as default note_off interpretation always. It is upto the processing software/ instrument to process it correctly.

@yenyesorr
Copy link
Author

One small correction to the above information.....

The midi note velocity 0 does not immediately have to follow same midi note with non 0 velocity......but can appear at the relevant delta time.

However, if a DIFFERENT midi note with velocity 0 appears without a preceding non 0 velocity, that note should not be treated as note_off as there was no corresponding note_on, but rather left to the processing software/ instrument to decide.

@carter-thaxton
Copy link

While parsing, midi-file does currently interpret velocity 0 noteOn events as noteOff, but it marks then with a byte9 boolean flag, which ToneJS could use to disambiguate these cases.

When writing, midi-file will also honor the byte9 flag to write a noteOff event using byte 0x9 with velocity 0, to support this common non-standard convention.

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

2 participants