Browse Source

Convert notees from piano stave to music box strip notes

main
Starbeamrainbowlabs 4 years ago
parent
commit
42a03df794
Signed by: sbrl GPG Key ID: 1BE5172E637709C2
  1. 11
      MusicBoxConverter/MusicBox.cs
  2. 4
      MusicBoxConverter/MusicBoxScoreGenerator.cs

11
MusicBoxConverter/MusicBox.cs

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

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

Loading…
Cancel
Save