Browse Source

Bugfix: Correct MusicBox.IsValidNote() logic

main
Starbeamrainbowlabs 3 years ago
parent
commit
42ab1f8494
Signed by: sbrl GPG Key ID: 1BE5172E637709C2
  1. 7
      MusicBoxConverter/MusicBox.cs
  2. 8
      MusicBoxConverter/MusicBoxScoreGenerator.cs

7
MusicBoxConverter/MusicBox.cs

@ -46,14 +46,15 @@ namespace MusicBoxConverter
/// <returns>Whether the note can be played by this music box.</returns>
public bool IsValidNote(Note note)
{
return ValidNotes.Contains(
(note.NoteName.ToString() + note.Octave).Replace("Sharp", "")
return ValidNotes.Contains(
$"{note.NoteName}{note.Octave}".Replace("Sharp", "#")
);
}
public int NoteToBoxNumber(Note note)
{
return ValidNotes.FindIndex((string playableNote) => $"{note.NoteName}{note.Octave}".Replace("Sharp", "#") == playableNote);
string noteCompare = $"{note.NoteName}{note.Octave}".Replace("Sharp", "#");
return ValidNotes.FindIndex((string playableNote) => noteCompare == playableNote);
}
public override string ToString()

8
MusicBoxConverter/MusicBoxScoreGenerator.cs

@ -109,11 +109,9 @@ namespace MusicBoxConverter
{
if(Debug) {
Console.WriteLine(
"[Note] {0}: {1}{2}/{3}",
note.Time,
note.NoteName,
note.Octave,
note.NoteNumber
$"[Note] {note.Time}: " +
$"{note.NoteName}{note.Octave}/{note.NoteNumber} " +
$"-> {SelectedMusicBox.NoteToBoxNumber(note)}"
);
}

Loading…
Cancel
Save