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.

83 lines
1.7 KiB

using System;
using System.Reflection;
using Melanchall.DryWetMidi.Common;
using SBRL.Utilities;
namespace MusicBoxConverter
{
class MainClass
{
public static int Main(string[] args)
{
string inputFilename = "";
string outputFilename = "";
bool debug = false;
MusicBox targetMusicBox = MusicBox.Note30Corrected;
for(int i = 0; i < args.Length; i++)
{
switch(args[i])
{
case "-i":
case "--input":
inputFilename = args[++i];
break;
case "-o":
case "--output":
outputFilename = args[++i];
break;
case "--auto-dev":
inputFilename = "/home/sbrl/Music/Sheets/HappyBirthday.midi";
//inputFilename = "/tmp/Scale.midi";
outputFilename = "/tmp/test.svg";
break;
case "--debug":
debug = true;
break;
case "--box":
targetMusicBox = (MusicBox)typeof(MusicBox).GetField(
args[++i],
BindingFlags.GetField |
BindingFlags.Static |
BindingFlags.Public
).GetValue(null);
break;
case "-h":
case "--help":
Console.Error.WriteLine(EmbeddedFiles.ReadAllText("MusicBoxConverter.Help.txt"));
return 0;
default:
Console.Error.WriteLine("Error: Unknown option {0}.", args[i]);
return 1;
}
}
if(inputFilename == string.Empty) {
Console.Error.WriteLine("Error: No input file specified.");
return 1;
}
if(outputFilename == string.Empty) {
Console.Error.WriteLine("Error: No output file specified.");
return 1;
}
MusicBoxScoreGenerator converter = new MusicBoxScoreGenerator(
inputFilename,
targetMusicBox
) {
Debug = debug
};
converter.Output(outputFilename);
return 0;
}
}
}