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