Skip to content

Commit

Permalink
skip errors
Browse files Browse the repository at this point in the history
  • Loading branch information
surikov committed Aug 3, 2023
1 parent 8d3bbeb commit f07753b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/MIDIFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,8 @@ MIDIFile.prototype.parseSong = function () {
(expectedPitchBendRangeMessageNumber == 4 && events[i].param1 == 0x26)
) {
if (expectedPitchBendRangeMessageNumber > 1 && events[i].channel != expectedPitchBendRangeChannel) {
throw Error('Unexpected channel number in non-first pitch-bend RANGE (SENSITIVITY) message. MIDI file might be corrupt.');
//throw Error('Unexpected channel number in non-first pitch-bend RANGE (SENSITIVITY) message. MIDI file might be corrupt.');
//don't care
}
expectedPitchBendRangeChannel = events[i].channel;
if (expectedPitchBendRangeMessageNumber == 3) {
Expand Down Expand Up @@ -1151,7 +1152,8 @@ MIDIFile.prototype.parseSong = function () {
}
if (expectedPitchBendRangeMessageNumberOld == expectedPitchBendRangeMessageNumber) { // If the current message wasn't an expected pitch-bend range message
if (expectedPitchBendRangeMessageNumberOld >= 2 && expectedPitchBendRangeMessageNumberOld <= 3) {
throw Error('Pitch-bend RANGE (SENSITIVITY) messages ended prematurely. MIDI file might be corrupt.');
//throw Error('Pitch-bend RANGE (SENSITIVITY) messages ended prematurely. MIDI file might be corrupt.');
//don't care
}
if (expectedPitchBendRangeMessageNumberOld == 4) { // The fourth message is optional, so since it wasn't sent, the setting of the pitch-bend range is done, and we might expect the first pitch-bend range message some time in the future
expectedPitchBendRangeMessageNumber = 1;
Expand Down

1 comment on commit f07753b

@page200
Copy link
Contributor

@page200 page200 commented on f07753b Aug 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe display a warning like "MIDI file might be corrupt. Please send us the file via https://github.com/surikov/webaudiofont/issues/new?assignees=page200&title=MIDI%20file%20with%20incomplete%20pitch-bend%20range%20messages so that we can decide whether resetting expectedPitchBendRangeMessageNumber to 1 is better for recovering from such cases."

Please sign in to comment.