Beispiel #1
0
 def test_time_signature(self):
     t1 = mparse(parser=TimeSig, expr='7|8')
     self.assertEqual(t1, (7, F(1, 8)))
     t2 = mparse(parser=TimeSig, expr='4|e3')
     self.assertEqual(t2, (4, F(1, 12)))
     t3 = mparse(parser=TimeSig, expr='11|6')
     self.assertEqual(t3, (11, F(1, 6)))
Beispiel #2
0
    def test_notename_to_pc(self):
        note_names = [
            'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'
        ]
        pcs = [mparse(parser=Note, expr=notename) for notename in note_names]
        self.assertEqual(pcs, list(range(12)))

        note_names = [
            'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B'
        ]
        pcs = [mparse(parser=Note, expr=notename) for notename in note_names]
        self.assertEqual(pcs, list(range(12)))
Beispiel #3
0
 def test_notename_with_octave(self):
     note_names = ['C#4', 'Gb6', 'Ab']
     pcs = [
         mparse(parser=NoteOctv, expr=notename) for notename in note_names
     ]
     mid = [PC(pc).midi for pc in pcs]
     self.assertEqual(mid, [61, 90, 68])
Beispiel #4
0
 def test_rhythm_sequence(self):
     text = 'q q x eR e x 1/13^ e. q7 q.+(e/3)R 30*wR h+x'  # showing a plethora of ways rhythm can be expressed
     parsed = mparse(parser=RhythmSeq, expr=text)
     expect = [{
         'fraction': F(1, 4),
         'rest': False,
         'accent': 0
     }, {
         'fraction': F(1, 4),
         'rest': False,
         'accent': 0
     }, {
         'fraction': F(1, 16),
         'rest': False,
         'accent': 0
     }, {
         'fraction': F(1, 8),
         'rest': True,
         'accent': 0
     }, {
         'fraction': F(1, 8),
         'rest': False,
         'accent': 0
     }, {
         'fraction': F(1, 16),
         'rest': False,
         'accent': 0
     }, {
         'fraction': F(1, 13),
         'rest': False,
         'accent': 2
     }, {
         'fraction': F(3, 16),
         'rest': False,
         'accent': 0
     }, {
         'fraction': F(1, 14),
         'rest': False,
         'accent': 0
     }, {
         'fraction': F(5, 12),
         'rest': True,
         'accent': 0
     }, {
         'fraction': F(30, 1),
         'rest': True,
         'accent': 0
     }, {
         'fraction': F(1, 2) + F(1, 16),
         'rest': False,
         'accent': 0
     }]
     self.assertEqual(parsed, expect)
Beispiel #5
0
    def test_(self):

        counter = CounterBases(
            beats_in_bar=4,
            beat_length=NoteDuration(1, 4),
        )
        set_counter_klass(counter)

        count_token = '1.0.1.4'
        val = mparse(CountVector, count_token)
        print(val)
        cpy = val()
        cpy.advance('B', 1)
        print(cpy)

        sub8th = ''
        val = mparse(SubCount16th, sub8th)
        print(val)

        # Now testing Phrase from counts.py
        print(mparse(CountString, '1 2.2 .4 3 3.3 4.1 4.3'))
Beispiel #6
0
    def test_interval_to_num(self):
        intv_names = [
            '1', '2b', '2', '3b', '3', '4', '5b', '5', '6b', '6', '7b', '7'
        ]
        vals = [mparse(parser=Interval, expr=intv) for intv in intv_names]
        self.assertEqual(vals, list(range(12)))

        intv_names = [
            '1', '1#', '2', '2#', '3', '4', '4#', '5', '5#', '6', '6#', '7'
        ]
        vals = [mparse(parser=Interval, expr=intv) for intv in intv_names]
        self.assertEqual(vals, list(range(12)))

        intv_names = [
            '1', 'b2', '2', 'b3', '3', '4', 'b5', '5', 'b6', '6', 'b7', '7'
        ]
        vals = [mparse(parser=Interval, expr=intv) for intv in intv_names]
        self.assertEqual(vals, list(range(12)))

        intv_names = [
            '1', '#1', '2', '#2', '3', '4', '#4', '5', '#5', '6', '#6', '7'
        ]
        vals = [mparse(parser=Interval, expr=intv) for intv in intv_names]
        self.assertEqual(vals, list(range(12)))
Beispiel #7
0
 def test_interval_sequence(self):
     text = '1 2 b3 4 5 b6 b7'
     vals = mparse(parser=IntervalSeq, expr=text)
     self.assertEqual(vals, [0, 2, 3, 5, 7, 8, 10])
Beispiel #8
0
 def test_note_sequence(self):
     text = 'C D E F# G A B'
     pcs = mparse(parser=NoteSeq, expr=text)
     self.assertEqual(pcs, [0, 2, 4, 6, 7, 9, 11])
Beispiel #9
0
 def test_counting_in_tuplets(self):
     text = '1 .2 .3 .5 2.2 .1 .3'
     parsed = mparse(parser=BeatSeqN, expr=text)
     expect = [(0, 0), 1, 2, 4, (1, 1), 0, 2]
     self.assertEqual(parsed, expect)
Beispiel #10
0
 def test_counting_in_sixteenths(self):
     text = '1 2n 3 n n 1 2n 3 n 4'
     parsed = mparse(parser=BeatSeq16, expr=text)
     expect = [(0, 0), (1, 2), (2, 0), 2, 2, (4, 0), 1, 2, 3, (5, 0)]
     self.assertEqual(parsed, expect)