import sys
sys.path.append("../")

from midiutil.TrackGen import LoopingArray
from midiutil.MidiGenerator import MidiGenerator

midiGenerator = MidiGenerator(tempo=120)

x = LoopingArray([5,1,6])
note = 0
scale = []
for _ in range(10):
    scale += [36+note]
    note += x.next()

tracks = {
          'Bass track': {
                         'notearrays': [
                                        {
                                         'beat': LoopingArray([(0.25,1.0)]),
                                         'notearray': LoopingArray([[x] for x in scale],
                                                                   functioniterator=[
                                                                                     ('add',LoopingArray([1,2,3,4,5])),
                                                                                     ('dec',LoopingArray([0,0,1,2])),
                                                                                     ]),
                                         'velocities': LoopingArray([x for x in range(100,110)],
                                                                    functioniterator=[
                                                                                      ('add',LoopingArray([1,2,4,1,3])),
                                                                                     ('dec',LoopingArray([0,7,3,2])),
                                                                                      ])
                                        }
    def testLoopingArray(self):
        l = LoopingArray([1, 2, 3, 4, 5])
        
        assert l.next() == 1
        assert l.next() == 2
        assert l.next() == 3
        assert l.next() == 4
        assert l.next() == 5
        assert l.next() == 1
        
        l = LoopingArray([1, 2, 3, 4, 5], [('add', StaticIterator(value=2))])
        
        assert l.next() == 1
        assert l.next() == 3
        assert l.next() == 5
        assert l.next() == 2
        
        l = LoopingArray([1, 2, 3, 4, 5], [('add', StaticIterator(value=2)), ('dec', StaticIterator(value=1))])
        
        assert l.next() == 1
        assert l.next() == 2
        assert l.next() == 3
        assert l.next() == 4
        assert l.next() == 5
        assert l.next() == 1

        l = LoopingArray([1, 2, 3, 4, 5], [('add', StaticIterator(value=1)), ('dec', StaticIterator(value=2))])
        
        assert l.next() == 1
        assert l.next() == 5
        assert l.next() == 4
        assert l.next() == 3
        assert l.next() == 2
        assert l.next() == 1
        assert l.next() == 5
Exemple #3
0
    def testLoopingArray(self):
        l = LoopingArray([1, 2, 3, 4, 5])

        assert l.next() == 1
        assert l.next() == 2
        assert l.next() == 3
        assert l.next() == 4
        assert l.next() == 5
        assert l.next() == 1

        l = LoopingArray([1, 2, 3, 4, 5], [('add', StaticIterator(value=2))])

        assert l.next() == 1
        assert l.next() == 3
        assert l.next() == 5
        assert l.next() == 2

        l = LoopingArray([1, 2, 3, 4, 5], [('add', StaticIterator(value=2)),
                                           ('dec', StaticIterator(value=1))])

        assert l.next() == 1
        assert l.next() == 2
        assert l.next() == 3
        assert l.next() == 4
        assert l.next() == 5
        assert l.next() == 1

        l = LoopingArray([1, 2, 3, 4, 5], [('add', StaticIterator(value=1)),
                                           ('dec', StaticIterator(value=2))])

        assert l.next() == 1
        assert l.next() == 5
        assert l.next() == 4
        assert l.next() == 3
        assert l.next() == 2
        assert l.next() == 1
        assert l.next() == 5
Exemple #4
0
import sys
sys.path.append("../")

from midiutil.TrackGen import LoopingArray

if __name__ == '__main__':
    arr = LoopingArray(
                       [x for x in range(128)],
                       functioniterator=[
                                         ('add', LoopingArray([1, 2, 3], functioniterator=[
                                                                                         ('add', LoopingArray([1, 2, 3], functioniterator=[
                                                                                                                                           ('add', LoopingArray([1,2,3], id='      array4', debug=True))
                                                                                                                                           ],
                                                                                                              id='    array3', debug=True)
                                                                                          )
                                                                                         ],
                                                              id='  array2', debug=True)
                                          )
                                         ],
                       id='array1', debug=True
                       )
    
    for _ in range(20):
        arr.next()
Exemple #5
0
from midiutil.TrackGen import LoopingArray

if __name__ == '__main__':
    arr = LoopingArray([x for x in range(128)],
                       functioniterator=[
                           ('add',
                            LoopingArray([1, 2, 3],
                                         functioniterator=[
                                             ('add',
                                              LoopingArray(
                                                  [1, 2, 3],
                                                  functioniterator=[
                                                      ('add',
                                                       LoopingArray(
                                                           [1, 2, 3],
                                                           id='      array4',
                                                           debug=True))
                                                  ],
                                                  id='    array3',
                                                  debug=True))
                                         ],
                                         id='  array2',
                                         debug=True))
                       ],
                       id='array1',
                       debug=True)

    for _ in range(20):
        arr.next()