Skip to content

Commit 97db84c

Browse files
authored
Fix wrong bend sounds (#488)
1 parent 648c7ec commit 97db84c

File tree

2 files changed

+286
-51
lines changed

2 files changed

+286
-51
lines changed

src/midi/MidiFileGenerator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ export class MidiFileGenerator {
441441
}
442442

443443
if (initialBend >= 0) {
444-
this._handler.addBend(track.index, noteStart, channel, initialBend);
444+
this._handler.addNoteBend(track.index, noteStart, channel, noteKey, initialBend);
445445
}
446446

447447
//
@@ -832,7 +832,7 @@ export class MidiFileGenerator {
832832
duration = noteDuration.noteOnly;
833833
}
834834
// ensure prebends are slightly before the actual note.
835-
if (bendPoints[0].value > 0 && !note.isContinuedBend) {
835+
if (bendPoints[0].value > 0 && !note.isContinuedBend && noteStart > 0) {
836836
noteStart--;
837837
}
838838
const bendDuration: number = Math.min(
@@ -922,7 +922,7 @@ export class MidiFileGenerator {
922922
break;
923923
case BendStyle.Fast:
924924
const preBendValue: number = MidiFileGenerator.getPitchWheel(note.bendPoints[0].value);
925-
this._handler.addBend(track.index, noteStart, channel, preBendValue | 0);
925+
addBend(noteStart, preBendValue | 0);
926926
if (!finalBendValue || finalBendValue < note.bendPoints[1].value) {
927927
finalBendValue = note.bendPoints[1].value;
928928
}
@@ -948,7 +948,7 @@ export class MidiFileGenerator {
948948
break;
949949
case BendStyle.Fast:
950950
const preBendValue: number = MidiFileGenerator.getPitchWheel(note.bendPoints[0].value);
951-
this._handler.addBend(track.index, noteStart, channel, preBendValue | 0);
951+
addBend(noteStart, preBendValue | 0);
952952
this.generateSongBookWhammyOrBend(
953953
noteStart,
954954
duration,

0 commit comments

Comments
 (0)