예제 #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);
            }
        }
예제 #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);
        }
예제 #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));
        }
예제 #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);
        }
예제 #5
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);
            }
        }