From 42ab1f84941cd6e1c55704e43a1fde2342899715 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 23 Feb 2019 22:52:45 +0000 Subject: [PATCH] Bugfix: Correct MusicBox.IsValidNote() logic --- MusicBoxConverter/MusicBox.cs | 7 ++++--- MusicBoxConverter/MusicBoxScoreGenerator.cs | 8 +++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/MusicBoxConverter/MusicBox.cs b/MusicBoxConverter/MusicBox.cs index a39d265..bdb9d44 100644 --- a/MusicBoxConverter/MusicBox.cs +++ b/MusicBoxConverter/MusicBox.cs @@ -46,14 +46,15 @@ namespace MusicBoxConverter /// Whether the note can be played by this music box. 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() diff --git a/MusicBoxConverter/MusicBoxScoreGenerator.cs b/MusicBoxConverter/MusicBoxScoreGenerator.cs index 3254d3d..e1e51f1 100644 --- a/MusicBoxConverter/MusicBoxScoreGenerator.cs +++ b/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)}" ); }