Shift up to hide dead space at the top

This commit is contained in:
Starbeamrainbowlabs 2017-12-03 11:36:47 +00:00
parent d527ac2184
commit 0d48715361
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 18 additions and 7 deletions

View file

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

View file

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

View file

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