Exemple #1
0
        private Score ParseTex(string tex)
        {
            var import = new AlphaTexImporter();

            import.Init(new StreamWrapper(new MemoryStream(Encoding.UTF8.GetBytes(tex))));
            return(import.ReadScore());
        }
        private Score ParseTex(string tex)
        {
            var importer = new AlphaTexImporter();

            importer.Init(TestPlatform.CreateStringReader(tex));
            return(importer.ReadScore());
        }
Exemple #3
0
        public override void Tex(string contents)
        {
            var parser = new AlphaTexImporter();
            var data   = ByteBuffer.FromBuffer(Std.StringToByteArray(contents));

            parser.Init(data);
            ScoreLoaded(parser.ReadScore());
        }
 private void Tex(string contents)
 {
     try
     {
         var parser = new AlphaTexImporter();
         var data   = ByteBuffer.FromBuffer(Std.StringToByteArray(contents));
         parser.Init(data);
         ScoreLoaded(parser.ReadScore());
     }
     catch (Exception e)
     {
         Error(e);
     }
 }
Exemple #5
0
 public void Tex(string contents)
 {
     Element.classList.add("loading");
     try
     {
         var parser = new AlphaTexImporter();
         var data   = ByteBuffer.FromBuffer(Std.StringToByteArray(contents));
         parser.Init(data);
         ScoreLoaded(parser.ReadScore());
     }
     catch (Exception e)
     {
         Error("import", e);
     }
 }
        public void TestPcmGeneration()
        {
            var tex = "\\tempo 102 \\tuning E4 B3 G3 D3 A2 E2 \\instrument 25 . r.8 (0.4 0.3 ).8 " +
                      "(-.3 -.4 ).2 {d } | (0.4 0.3 ).8 r.8 (3.3 3.4 ).8 r.8 (5.4 5.3 ).4 r.8 (0.4 0.3 ).8 |" +
                      " r.8 (3.4 3.3 ).8 r.8 (6.3 6.4 ).8 (5.4 5.3 ).4 {d }r.8 |" +
                      " (0.4 0.3).8 r.8(3.4 3.3).8 r.8(5.4 5.3).4 r.8(3.4 3.3).8 | " +
                      "r.8(0.4 0.3).8(-.3 - .4).2 { d } | ";
            var importer = new AlphaTexImporter();

            importer.Init(TestPlatform.CreateStringReader(tex));
            var score = importer.ReadScore();

            var midi = new MidiFile();
            var gen  = new MidiFileGenerator(score, null, new AlphaSynthMidiFileHandler(midi));

            gen.Generate();

            var testOutput = new TestOutput();
            var synth      = new AlphaSynth(testOutput);

            synth.LoadSoundFont(TestPlatform.LoadFile("TestFiles/Audio/default.sf2"));
            synth.LoadMidi(midi);

            synth.Play();

            var finished = false;

            synth.Finished += b => finished = true;

            while (!finished)
            {
                testOutput.Continue();
            }

            //Console.WriteLine(testOutput.Samples.Count);
            //using (var writer = new BinaryWriter(new FileStream("test.pcm", FileMode.Create, FileAccess.Write)))
            //{
            //    for (int i = 0; i < testOutput.Samples.Count; i++)
            //    {
            //        writer.Write(testOutput.Samples[i]);
            //    }
            //}
        }
Exemple #7
0
        public static async Task RunVisualTestTex(string tex, string referenceFileName,
                                                  Settings?settings     = null,
                                                  IList <double>?tracks = null, string?message = null)
        {
            try
            {
                if (settings == null)
                {
                    settings = new Settings();
                }

                var importer = new AlphaTexImporter();
                importer.Init(ByteBuffer.FromString(tex), settings);
                var score = importer.ReadScore();

                await VisualTestHelper.RunVisualTestScore(score, referenceFileName, settings,
                                                          tracks, message);
            }
            catch (Exception e)
            {
                Assert.Fail($"Failed to run visual test {e}");
            }
        }
Exemple #8
0
        public void TestDisplayTranspositionPitchResultsInAccidental()
        {
            var import = new AlphaTexImporter();

            import.Init(ByteBuffer.FromBuffer(Encoding.UTF8.GetBytes("\\tuning none . e3.8")));
            var score = import.ReadScore();

            var settings = Settings.Defaults;

            // no transposition
            settings.TranspositionPitches = new [] { 0 };
            ModelUtils.ApplyPitchOffsets(settings, score);
            var helper     = new AccidentalHelper();
            var accidental = helper.ApplyAccidental(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            var line       = helper.GetNoteLine(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);

            Assert.AreEqual(AccidentalType.None, accidental);
            Assert.AreEqual(17, line);

            // one semitone up => one line up
            settings.TranspositionPitches = new[] { 1 };
            ModelUtils.ApplyPitchOffsets(settings, score);
            helper     = new AccidentalHelper();
            accidental = helper.ApplyAccidental(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            line       = helper.GetNoteLine(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            Assert.AreEqual(AccidentalType.None, accidental);
            Assert.AreEqual(16, line);

            // two semitones up => one line up + sharp
            settings.TranspositionPitches = new[] { 2 };
            ModelUtils.ApplyPitchOffsets(settings, score);
            helper     = new AccidentalHelper();
            accidental = helper.ApplyAccidental(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            line       = helper.GetNoteLine(score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Notes[0]);
            Assert.AreEqual(AccidentalType.Sharp, accidental);
            Assert.AreEqual(16, line);
        }