Ejemplo n.º 1
0
        public void TestConvertMidi()
        {
            // File to test against (result file)
            string baselineFilePath = @"Tests\Passacaglia, Handel_Sample_Cubase_Format0.mid";
            var    baselineFileInfo = new FileInfo(baselineFilePath);
            var    sequenceBaseline = new MidiFileReader().GetSequence(baselineFileInfo);

            // Dump Baseline Midi
            string baselineTextPath = baselineFileInfo.Name + "_dump.txt";

            sequenceBaseline.DumpMidi(baselineTextPath);

            // File to test with
            string fileName = @"Tests\Passacaglia, Handel_Sample.mid";
            var    fileInfo = new FileInfo(fileName);
            var    sequence = new MidiFileReader().GetSequence(fileInfo);

            // Convert Midi to Format 0
            var convertedSequence = sequence.Convert((int)MidiHelper.MidiFormat.SingleTrack, SequenceExtensions.FormatConversionOption.NoteOffZero2NoteOnZero, 480, "SongNameForType0");

            // Dump Converted Midi
            string convertedOutputTextPath = fileInfo.Name + "_converted_dump.txt";

            convertedSequence.DumpMidi(convertedOutputTextPath);

            if (FileCompare(baselineTextPath, convertedOutputTextPath))
            {
                Assert.Pass("The midi files are identical.");
            }
            else
            {
                Assert.Fail("The midi files are different!");
            }
        }
Ejemplo n.º 2
0
        public void TestGenerateMidi()
        {
            //string fileName = @"Tests\Passacaglia, Handel_Sample.mid";
            //string fileName = @"Tests\agnes-release_me.mid";
            string fileName = @"Tests\Passacaglia, Handel_Sample_Cubase_Format0.mid";

            var fileIn   = new FileInfo(fileName);
            var sequence = new MidiFileReader().GetSequence(fileIn);

            string outputTextPath = fileIn.Name + "_dump.txt";

            sequence.DumpMidi(outputTextPath);

            // Generate C# Code
            string outputCodePath = fileIn.Name + "_code.cs";

            sequence.SaveGenerateMidiCode(outputCodePath);

            if (!CompileAndRunSource(outputCodePath))
            {
                Assert.Fail("Could not compile and run generated code!");
            }

            // read the generated midi dump file and compare against original
            if (!FileCompare(outputTextPath, "generated_dump.txt"))
            {
                Assert.Fail("The midi dump files are different!");
            }

            // read the generated midi file and compare against original
            //if (!FileCompare(fileName, "generated.mid")) {
            //	Assert.Fail("The midi files are different!");
            //}

            Assert.Pass("The midi files are identical.");
        }
Ejemplo n.º 3
0
        public void TestReadWriteMidi()
        {
            string inputFileName = @"Tests\Passacaglia, Handel_Sample.mid";

            var fileIn   = new FileInfo(inputFileName);
            var sequence = new MidiFileReader().GetSequence(fileIn);

            string outputTextPath = fileIn.Name + ".txt";

            sequence.DumpMidi(outputTextPath);

            string outputFileName = fileIn.Name + "_parsed.mid";

            sequence.Save(outputFileName);

            if (FileCompare(inputFileName, outputFileName))
            {
                Assert.Pass("The midi files are identical.");
            }
            else
            {
                Assert.Fail("The midi files are different!");
            }
        }