Convert notees from piano stave to music box strip notes
This commit is contained in:
parent
e5331328f1
commit
42a03df794
2 changed files with 13 additions and 2 deletions
|
@ -22,6 +22,12 @@ namespace MusicBoxConverter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int NoteCount {
|
||||||
|
get {
|
||||||
|
return ValidNotes.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private MusicBox(string inName, List<string> inValidNotes)
|
private MusicBox(string inName, List<string> inValidNotes)
|
||||||
{
|
{
|
||||||
Name = inName;
|
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()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Name;
|
return Name;
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace MusicBoxConverter
|
||||||
|
|
||||||
public void Output(string destinationFilename)
|
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));
|
Vector2 size = area.Add(offset.Multiply(2)).Add(new Vector2(100000, 1000));
|
||||||
|
|
||||||
SvgWriter svg = new SvgWriter(destinationFilename, size.X.ToString(), size.Y.ToString());
|
SvgWriter svg = new SvgWriter(destinationFilename, size.X.ToString(), size.Y.ToString());
|
||||||
|
@ -71,7 +71,7 @@ namespace MusicBoxConverter
|
||||||
svg.WriteCircle(
|
svg.WriteCircle(
|
||||||
new Vector2(
|
new Vector2(
|
||||||
offset.X + note.Time * scaleFactor.X,
|
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
|
holeSize // radius
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue