diff --git a/MusicBoxConverter/MusicBox.cs b/MusicBoxConverter/MusicBox.cs index b2e6536..f02d2bc 100644 --- a/MusicBoxConverter/MusicBox.cs +++ b/MusicBoxConverter/MusicBox.cs @@ -22,6 +22,12 @@ namespace MusicBoxConverter } } + public int NoteCount { + get { + return ValidNotes.Count; + } + } + private MusicBox(string inName, List inValidNotes) { Name = inName; @@ -41,6 +47,11 @@ namespace MusicBoxConverter ); } + public int NoteToBoxNumber(Note note) + { + return ValidNotes.FindIndex((string playableNote) => $"{note.NoteName}{note.Octave}".Replace("Sharp", "#") == playableNote); + } + public override string ToString() { return Name; diff --git a/MusicBoxConverter/MusicBoxScoreGenerator.cs b/MusicBoxConverter/MusicBoxScoreGenerator.cs index 781b40a..ff871d8 100644 --- a/MusicBoxConverter/MusicBoxScoreGenerator.cs +++ b/MusicBoxConverter/MusicBoxScoreGenerator.cs @@ -54,7 +54,7 @@ namespace MusicBoxConverter public void Output(string destinationFilename) { - Vector2 area = new Vector2(TrackLength, MaxNoteNumber - MinNoteNumber).Multiply(scaleFactor); + Vector2 area = new Vector2(TrackLength, MusicBox.NoteCount).Multiply(scaleFactor); Vector2 size = area.Add(offset.Multiply(2)).Add(new Vector2(100000, 1000)); SvgWriter svg = new SvgWriter(destinationFilename, size.X.ToString(), size.Y.ToString()); @@ -71,7 +71,7 @@ namespace MusicBoxConverter svg.WriteCircle( new Vector2( offset.X + note.Time * scaleFactor.X, - offset.Y + ((127 - note.NoteNumber) - (127 - MaxNoteNumber)) * scaleFactor.Y + offset.Y + (MusicBox.NoteCount - MusicBox.NoteToBoxNumber(note)) * scaleFactor.Y ), holeSize // radius );