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)
{
return ValidNotes.Contains(
(note.NoteName.ToString() + note.Octave).Replace("Sharp", "")
$"{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()

View file

@ -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)}"
);
}