Convert notees from piano stave to music box strip notes

This commit is contained in:
Starbeamrainbowlabs 2017-12-03 14:38:31 +00:00
parent e5331328f1
commit 42a03df794
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
2 changed files with 13 additions and 2 deletions

View File

@ -22,6 +22,12 @@ namespace MusicBoxConverter
}
}
public int NoteCount {
get {
return ValidNotes.Count;
}
}
private MusicBox(string inName, List<string> 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;

View File

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