Browse Source

Shift up to hide dead space at the top

main
Starbeamrainbowlabs 4 years ago
parent
commit
0d48715361
Signed by: sbrl GPG Key ID: 1BE5172E637709C2
  1. 15
      MusicBoxConverter/MusicBox.cs
  2. 8
      MusicBoxConverter/MusicBoxScoreGenerator.cs
  3. 2
      MusicBoxConverter/Utilities/NoteUtilities.cs

15
MusicBoxConverter/MusicBox.cs

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Melanchall.DryWetMidi.Smf.Interaction;
namespace MusicBoxConverter
@ -10,12 +10,25 @@ namespace MusicBoxConverter
public string Name { get; private set; }
public List<string> ValidNotes { get; private set; }
public Note LowestNote {
get {
return NoteUtilities.StringToNote(ValidNotes.First());
}
}
public Note HighestNote {
get {
return NoteUtilities.StringToNote(ValidNotes.Last());
}
}
private MusicBox(string inName, List<string> inValidNotes)
{
Name = inName;
ValidNotes = inValidNotes;
}
/// <summary>
/// Calculates whether the specified note can be played by this music box.
/// </summary>

8
MusicBoxConverter/MusicBoxScoreGenerator.cs

@ -28,15 +28,13 @@ namespace MusicBoxConverter
public int MaxNoteNumber {
get {
// TODO: Update to get the max note number supported by the music box
return AllNotes().Max((Note note) => note.NoteNumber);
return MusicBox.HighestNote.NoteNumber;
}
}
public int MinNoteNumber {
get
{
// TODO: Update to get the min note number supported by the music box
return AllNotes().Min((Note note) => note.NoteNumber);
return MusicBox.LowestNote.NoteNumber;
}
}
@ -73,7 +71,7 @@ namespace MusicBoxConverter
svg.WriteCircle(
new Vector2(
offset.X + note.Time * scaleFactor.X,
offset.Y + note.NoteNumber * scaleFactor.Y
offset.Y + note.NoteNumber * scaleFactor.Y - MinNoteNumber
),
holeSize // radius
);

2
MusicBoxConverter/Utilities/NoteUtilities.cs

@ -18,7 +18,7 @@ namespace MusicBoxConverter
string noteLetter = Regex.Replace(note, "[0-9]", "").Replace("#", "Sharp");
int octave = int.Parse(Regex.Replace(note, "[^0-9]", ""));
NoteName noteName = (NoteName)Enum.Parse(typeof(NoteName), noteLetter);
return new Note(noteName, 4);
return new Note(noteName, octave);
}
}
}
Loading…
Cancel
Save