Skip to content

Commit

Permalink
Fix MIDI dialog crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
BleuBleu committed Nov 25, 2021
1 parent 5397781 commit 8ae21a1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions FamiStudio/Source/UI/Common/MidiImportDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void Properties_PropertyChanged(PropertyPage props, int propIdx, int row
var newChannelCount = Channel.GetChannelCountForExpansionMask(expansionMask, 8);
var oldChannelCount = channelSources.Length;

var maxChannelIndex = 3;
var maxChannelIndex = 2;
for (int i = 0; i < oldChannelCount; i++)
{
if (channelSources[i].type == MidiSourceType.Channel && channelSources[i].index != 9)
Expand All @@ -76,7 +76,9 @@ private void Properties_PropertyChanged(PropertyPage props, int propIdx, int row

for (int i = oldChannelCount; i < newChannelCount; i++)
{
channelSources[i] = new MidiFileReader.MidiSource() { index = maxChannelIndex++ };
maxChannelIndex = Math.Min(maxChannelIndex + 1, 15);
if (maxChannelIndex == 9) maxChannelIndex++;
channelSources[i] = new MidiFileReader.MidiSource() { index = maxChannelIndex };
}

UpdateListView();
Expand Down

0 comments on commit 8ae21a1

Please sign in to comment.