Converts MIDI files into music box scores that are ready to print.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
818 B

using System;
using System.Text.RegularExpressions;
using Melanchall.DryWetMidi.Smf.Interaction;
using Melanchall.DryWetMidi.Common;
using System.Reflection;
namespace MusicBoxConverter
{
static class NoteUtilities
{
public static string NoteToString(Note note)
{
return $"{note.NoteName}{note.Octave}";
}
public static Note StringToNote(string note)
{
string noteLetter = Regex.Replace(note, "[0-9]", "").Replace("#", "Sharp");
int octave = int.Parse(Regex.Replace(note, "[^0-9]", ""));
Melanchall.DryWetMidi.MusicTheory.NoteName noteName = (Melanchall.DryWetMidi.MusicTheory.NoteName)Enum.Parse(typeof(Melanchall.DryWetMidi.MusicTheory.NoteName), noteLetter);
return new Note(noteName, octave);
}
}
}