Skip to content

Commit da18f23

Browse files
Bug fix in replacing note with length replace and improvement in MIDI file player
- The bug in replacing note with length replace that causes to not replace length when note and length is replaced same time. - The MIDI file player is improved to reduce crackling sounds and inconsistencies.
1 parent 0546441 commit da18f23

6 files changed

Lines changed: 1251 additions & 10 deletions

File tree

NeoBleeper/MIDIFilePlayer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ private async Task PlayMultipleNotesAsync(int[] frequencies, int duration, Cance
836836
int currentNoteIndex = i;
837837
HighlightNoteLabel(currentNoteIndex);
838838
// Run the actual sound generation off the calling context but avoid spinning extra Task.Run loops.
839-
await Task.Run(() => NotePlayer.PlayNote(frequencies[currentNoteIndex], notePlayDuration), token);
839+
await Task.Run(() => NotePlayer.PlayNoteWithoutGap(frequencies[currentNoteIndex], notePlayDuration), token);
840840
UnHighlightNoteLabel(currentNoteIndex);
841841

842842
int gap = Math.Max(0, timePerNote - notePlayDuration);
@@ -867,7 +867,7 @@ private async Task PlayMultipleNotesAsync(int[] frequencies, int duration, Cance
867867
notePlayDuration = interval;
868868

869869
HighlightNoteLabel(noteIndex);
870-
await Task.Run(() => NotePlayer.PlayNote(frequencies[noteIndex], notePlayDuration), token);
870+
await Task.Run(() => NotePlayer.PlayNoteWithoutGap(frequencies[noteIndex], notePlayDuration), token);
871871
UnHighlightNoteLabel(noteIndex);
872872

873873
// Wait until next note time (approximate)
@@ -1631,7 +1631,7 @@ private async Task ProcessCurrentFrame()
16311631
var frequencies = filteredNotes.Select(note => NoteToFrequency(note)).ToArray();
16321632
if (frequencies.Length == 1)
16331633
{
1634-
await Task.Run(() => NotePlayer.PlayNote(frequencies[0], durationMsInt), token);
1634+
await Task.Run(() => NotePlayer.PlayNoteWithoutGap(frequencies[0], durationMsInt), token);
16351635
}
16361636
else
16371637
{

NeoBleeper/MainWindow.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,28 +935,28 @@ private void ReplaceNoteAndLengthOfLine(string note)
935935
{
936936
Line.note1 = note;
937937
ReplaceLengthWithoutSavingToMemento();
938-
var replaceNoteCommand = new ReplaceNoteAndLengthCommand(listViewNotes, listViewNotes.SelectedItems[0].SubItems[0].Text, 1, note);
938+
var replaceNoteCommand = new ReplaceNoteAndLengthCommand(listViewNotes, Line.length, 1, note);
939939
commandManager.ExecuteCommand(replaceNoteCommand);
940940
}
941941
if (add_as_note2.Checked == true)
942942
{
943943
Line.note2 = note;
944944
ReplaceLengthWithoutSavingToMemento();
945-
var replaceNoteCommand = new ReplaceNoteAndLengthCommand(listViewNotes, listViewNotes.SelectedItems[0].SubItems[0].Text, 2, note);
945+
var replaceNoteCommand = new ReplaceNoteAndLengthCommand(listViewNotes, Line.length, 2, note);
946946
commandManager.ExecuteCommand(replaceNoteCommand);
947947
}
948948
if (add_as_note3.Checked == true)
949949
{
950950
Line.note3 = note;
951951
ReplaceLengthWithoutSavingToMemento();
952-
var replaceNoteCommand = new ReplaceNoteAndLengthCommand(listViewNotes, listViewNotes.SelectedItems[0].SubItems[0].Text, 3, note);
952+
var replaceNoteCommand = new ReplaceNoteAndLengthCommand(listViewNotes, Line.length, 3, note);
953953
commandManager.ExecuteCommand(replaceNoteCommand);
954954
}
955955
if (add_as_note4.Checked == true)
956956
{
957957
Line.note4 = note;
958958
ReplaceLengthWithoutSavingToMemento();
959-
var replaceNoteCommand = new ReplaceNoteAndLengthCommand(listViewNotes, listViewNotes.SelectedItems[0].SubItems[0].Text, 4, note);
959+
var replaceNoteCommand = new ReplaceNoteAndLengthCommand(listViewNotes, Line.length, 4, note);
960960
commandManager.ExecuteCommand(replaceNoteCommand);
961961
}
962962
isModified = true;

NeoBleeper/MainWindow.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@
12011201
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
12021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JQAU8BmwMkATX/ACEAAw0BEQJdAVsBygHgAZYBFwH/Ad8BlAEVAf8B
61976197
3gGSARQB/wHdAY8BEQH/AdwBjQEQAf8B2wGKAQ4B/wOAAf4DPQFo/wAVAAMtAUUB4wGeARwB/wHiAZsB
61986198
GgH/AeEBmQEZAf8B4AGWARcB/wHfAZQBFQH/Ad4BkgEUAf8B3QGPAREB/wHcAY0BEAH/AdsBigEOAf8B

0 commit comments

Comments
 (0)