Bugfix: Correct MusicBox.IsValidNote() logic

This commit is contained in:
Starbeamrainbowlabs 2019-02-23 22:52:45 +00:00
parent a6cf844c4b
commit 42ab1f8494
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 7 additions and 8 deletions

View file

@ -47,13 +47,14 @@ namespace MusicBoxConverter
public bool IsValidNote(Note note) public bool IsValidNote(Note note)
{ {
return ValidNotes.Contains( return ValidNotes.Contains(
(note.NoteName.ToString() + note.Octave).Replace("Sharp", "") $"{note.NoteName}{note.Octave}".Replace("Sharp", "#")
); );
} }
public int NoteToBoxNumber(Note note) 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() public override string ToString()

View file

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