Example #1
0
        public void Test()
        {
            var    testFileName = "MusicXML1.xml";
            string text         = ReadTestData(testFileName);

            //do
            var score = MusicXMLParser.GetScorePartwise(text);

            Assert.Equal(4, score.ScoreParts.Count);
            {
                var part1 = score.ScoreParts.First();
                Assert.Equal("P1", part1.Id);
                Assert.Equal(2, part1.MeasureList.Length);
                var attr = part1.Attribute;
                Assert.Equal(1, attr.Divisions);
                Assert.Equal(4, attr.Time.Beats);
                Assert.Equal(4, attr.Time.BeatType);
                var note1 = part1.MeasureList.First().Notes[0];
                Assert.False(note1.IsUnpitch);
            }
            {
                var part2    = score.ScoreParts[1];
                var measure1 = part2.MeasureList[0];
                Assert.Equal(1, measure1.Number);
                Assert.Equal(4, measure1.Notes.Length);
                var note1 = measure1.Notes[0];
                Assert.False(note1.IsRest);
                Assert.True(note1.IsUnpitch);
                Assert.Equal(1, note1.Duration);
                Assert.Equal(ScoreNoteType.quarter, note1.Type);

                var note2 = measure1.Notes[1];
                Assert.True(note2.IsRest);
            }
        }
Example #2
0
        public void Test_Tempo()
        {
            var    testFileName = "test_tempo.xml";
            string text         = ReadTestData(testFileName);

            //do
            var score = MusicXMLParser.GetScorePartwise(text);

            Assert.Equal(80, score.Tempo);
        }
Example #3
0
        /// <summary>
        /// musicXMLTextから、何Tick目かを表すGameScoreに変換する
        /// </summary>
        /// <param name="musicXMLText"></param>
        /// <param name="movePointInTick">1Tickで動く座標</param>
        /// <returns></returns>
        public GameScore CreateGameScore(string musicXMLText)
        {
            /*
             * 1 tempo = 480 tick
             *
             * part
             *		notes[]
             *				何tick目か: 四分音符 -> 1:0, 2:480, 3:960
             *
             */

            var score = MusicXMLParser.GetScorePartwise(musicXMLText);

            return(CreateGameScore(score));
        }
Example #4
0
        public void Test_Fermata()
        {
            var    testFileName = "test1.xml";
            string text         = ReadTestData(testFileName);

            //do
            var score = MusicXMLParser.GetScorePartwise(text);

            //フェルマータの付いた休符かどうか
            var note1 = score.ScoreParts[0].MeasureList[0].Notes[0];

            Assert.False(note1.HasFermata);

            var note2 = score.ScoreParts[0].MeasureList[0].Notes[1];

            Assert.True(note2.HasFermata);
        }
Example #5
0
        public void PresentationFunctionCauseWebWontWork()
        {
            if (!Directory.Exists("output"))
            {
                Directory.CreateDirectory("output");
            }

            var videoURL  = "https://www.youtube.com/watch?v=pN_gruOjM9I";
            var firstNote = new NoteInstance()
            {
                Note = Notes.D, Octave = 3
            };

            //------------------------------------------------------------------------//
            //var videoURL = "https://www.youtube.com/watch?v=aCJxjDzyAT8";           //
            //var firstNote = new NoteInstance() { Note = Notes.F, Octave = 3 };      //
            //                                                                        //
            //var videoURL = "https://www.youtube.com/watch?v=M4hAK4bTdl4";           //
            //var firstNote = new NoteInstance() { Note = Notes.A, Octave = 3 };      //
            //                                                                        //
            //var videoURL = "https://www.youtube.com/watch?v=p1WCR7vNcIw";           //
            //var firstNote = new NoteInstance() { Note = Notes.E, Octave = 3 };      //
            //------------------------------------------------------------------------//

            var videoDownloader = new VideoDownloader();

            var video = videoDownloader.GetVideoByUrl(new Uri(videoURL));

            var keyboardTiles = new NoteParser().ParseToKeyboardTiles(video, firstNote);

            var musicXmlParser = new MusicXMLParser();

            var musicXML = musicXmlParser.KeyboardTilesToMusicXML(keyboardTiles.ToList(), video.Framecount);

            File.WriteAllText(@"output\musicxml.xml", musicXML);

            // The output file will be inside the /bin/output folder of the NotesheetR.AppTests project
            // Webiste to view the musicxml.xml => https://www.soundslice.com/musicxml-viewer/
        }
Example #6
0
        public void Test_Huten_16th()
        {
            //付点、16分音符のテスト
            var    testFileName = "test1_huten.xml";
            string text         = ReadTestData(testFileName);

            //do
            var score   = MusicXMLParser.GetScorePartwise(text);
            var measure = score.ScoreParts[0].MeasureList[0];
            {
                var note = measure.Notes[0];
                //付点8分音符か
                Assert.Equal(ScoreNoteType.eighth, note.Type);
                Assert.False(note.IsRest);
                Assert.True(note.HasDot);
            }
            {
                var note = measure.Notes[1];
                //16分休符か
                Assert.Equal(ScoreNoteType.sixteenth, note.Type);
                Assert.True(note.IsRest);
                Assert.False(note.HasDot);
            }
            {
                var note = measure.Notes[2];
                //付点8分休符か
                Assert.Equal(ScoreNoteType.eighth, note.Type);
                Assert.True(note.IsRest);
                Assert.True(note.HasDot);
            }
            {
                var note = measure.Notes[3];
                //16分音符か
                Assert.Equal(ScoreNoteType.sixteenth, note.Type);
                Assert.False(note.IsRest);
                Assert.False(note.HasDot);
            }
        }