24 lines
725 B
C#
24 lines
725 B
C#
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]", ""));
|
|
NoteName noteName = (NoteName)Enum.Parse(typeof(NoteName), noteLetter);
|
|
return new Note(noteName, octave);
|
|
}
|
|
}
|
|
} |