コード例 #1
0
        public void staffInformationTest()
        {
            LilypondComposer comp  = new LilypondComposer();
            D_Staff          staff = new D_Staff();

            staff.tempo = 120;
            staff.clef  = clef.g_key;
            staff.addMeasure(1, 4, 0);
            D_Bar bar = new D_Bar(2);

            bar.addNote(new D_Note(NoteLevel.A, 1, 4));
            bar.addNote(new D_Note(NoteLevel.B, 1, 4));
            bar.addNote(new D_Note(NoteLevel.C, 1, 5));
            bar.addNote(new D_Note(NoteLevel.D, 1, 5));
            staff.addBar(bar);

            bar = new D_Bar(2);
            bar.addNote(new D_Note(NoteLevel.E, 1, 5));
            bar.addNote(new D_Note(NoteLevel.F, 1, 5));
            bar.addNote(new D_Note(NoteLevel.G, 1, 5));
            bar.addNote(new D_Note(NoteLevel.A, 1, 5));
            staff.addBar(bar);

            bar = new D_Bar(2);
            bar.addNote(new D_Note(NoteLevel.B, 1, 5));
            bar.addNote(new D_Note(NoteLevel.C, 1, 6));
            staff.addBar(bar);

            Assert.AreEqual("\\relative c{\r\n\\clef treble\r\n\\tempo 4=120\r\n\\time 2/4\r\n", comp.composeLilypondFromStaff(staff));
        }
コード例 #2
0
        public void TestGetMeasures()
        {
            D_Staff staff = new D_Staff();

            staff.addMeasure(4, 4, 0, 500);
            staff.addMeasure(8, 8, 500, 1000);
            staff.addMeasure(11, 12, 1000, 2000);

            D_Measure test_measure;

            // 4,4 at 0
            test_measure = staff.getMeasure(0);
            Assert.AreEqual(test_measure.beats_per_bar, 4);
            Assert.AreEqual(test_measure.beat_length, 4);

            // 4,4 at 250
            test_measure = staff.getMeasure(250);
            Assert.AreEqual(test_measure.beats_per_bar, 4);
            Assert.AreEqual(test_measure.beat_length, 4);

            // 8,8 at 500
            test_measure = staff.getMeasure(500);
            Assert.AreEqual(test_measure.beats_per_bar, 4);
            Assert.AreEqual(test_measure.beat_length, 4);

            // 8,8 at 750
            test_measure = staff.getMeasure(750);
            Assert.AreEqual(test_measure.beats_per_bar, 8);
            Assert.AreEqual(test_measure.beat_length, 8);

            // 11,12 at 1200
            test_measure = staff.getMeasure(1200);
            Assert.AreEqual(test_measure.beats_per_bar, 11);
            Assert.AreEqual(test_measure.beat_length, 12);
        }
コード例 #3
0
        public void TestSetMeasureEndTimesStaff1Measure()
        {
            D_Staff staff = new D_Staff();

            staff.num_of_beats = 1000;

            staff.addMeasure(4, 4, 0);
            staff.setMeasureEndTimes();

            Assert.AreEqual(1001, staff.measures[0].end_beat);
        }
コード例 #4
0
        public string composeLilypondFromStaff(D_Staff staff)
        {
            string lilypondString       = "";
            int    current_scope_octave = 0;

            composeRelativeInformation(staff.bars[0].notes[0], ref lilypondString, ref current_scope_octave);
            composeClefInformation(staff.clef, ref lilypondString);
            composeTempoInformation(staff.tempo, ref lilypondString);
            composeMeasureInformation(staff.measures[0], ref lilypondString);
            composeBars(staff.bars, ref lilypondString, ref current_scope_octave);

            lilypondString += "}";

            return(lilypondString);
        }