Open page200 opened 1 year ago
Thanks for notifying us! Unfortunately I have no idea how to implement it, so I hope someone else will.
This is achieved by three to four consecutive MIDI control messages. In hexadecimal, they look like this:
B06500 B06400 B00602 B02604
The "0" after the "B" is the MIDI channel (for example zeroth channel that plays a guitar) for which the pitch-bend range is being set. The "02" in the end of the third message is the number of semitones by which the pitch can bend. The "04" in the end of the fourth message is the number of cents to be added to the semitones. The last message is optional, i.e. if there is no message of the form /B.26../ (like "B02604" in the example) then the number of cents is zero.
Here is an example MIDI file where this happens around the 65th MIDI message in the file.
Here's my fix of this issue in a "fork" of MIDIFile.js: Commit: https://github.com/surikov/webaudiofont/compare/master...page200:webaudiofont:master Pull request: https://github.com/surikov/webaudiofont/pull/95/commits/64ffca58d26d9ca78e433eed562d9268ed7bee9e
I haven't checked whether such a fix belongs into https://github.com/nfroidure/midifile or https://github.com/nfroidure/midievents. Anyway, probably these two repos should be updated to the aforementioned "fork" because that "fork" has things like slides
(pitch bend) and parseSong()
, which https://github.com/nfroidure/midifile doesn't seem to have yet.
@page200 this repository is meant to be used per other libraries and is just providing a midi file reader. Best practices is not to copy/paste the code but use the library and provide pull requests to the repository in order to allow all users to benefit from the changes for their various needs (see dependent packages)..
Feel free to report those changes via a pull request if you think it will be interesting for other users.
In MIDI, the pitch-bend range is
2
per default, but can be modified via specific RPN messages, usually followed by specific "Data Entry" messages: http://midi.teragonaudio.com/tech/midispec/rpn.htmPlease take those MIDI messages into account, so that the pitch bend is correct.
Examples where MIDIFile.js does not take those MIDI messages into account correctly are discussed at https://github.com/surikov/webaudiofont/issues/93
Thank you!