コード例 #1
0
ファイル: test_midi.py プロジェクト: csv/beatlounge
 def test_default_velocity(self):
     notePlayer = Player(self.instr1, cycle([0, 1]).next,
                         release=cycle([12]).next,
                         clock=self.clock)
     notePlayer.resumePlaying()
     self.runTicks(48)
     self.assertEquals(self.instr1.plays, [('note', 0, 0, 127),
         ('note', 12, 1, 127), ('note', 24, 0, 127), ('note', 36, 1, 127),
         ('note', 48, 0, 127)])
コード例 #2
0
ファイル: test_midi.py プロジェクト: csv/beatlounge
 def test_player_plays_notes(self):
     notePlayer = Player(self.instr1, cycle([0, 1]).next,
                         velocity=cycle([120]).next,
                         clock=self.clock, interval=self.dtt(1, 4))
     notePlayer.resumePlaying()
     self.runTicks(96)
     expectedPlays = [
         ('note', 0, 0, 120),
         ('note', 24, 1, 120),
         ('note', 48, 0, 120),
         ('note', 72, 1, 120),
         ('note', 96, 0, 120)]
     self.assertEquals(self.instr1.plays, expectedPlays)
     self.failIf(self.instr1.stops)
コード例 #3
0
ファイル: rudiments.py プロジェクト: csv/beatlounge
 def __init__(self, instrument, rudiment, r, l, release=None, **kw):
     """
     @param instrument: The backend instrument (Fsynth instrument etc)
     @param rudiment: A IRudiment provider
     @param r: The "right" note
     @param l: the "left" note
     @param sustainArp: An optional "sustain" value arp.
     """
     self.rudiment = rudiment
     time = rudiment.time(cycle=True).next
     note = OrderedArp(list(rudiment.strokes(r, l, cycle=False)))
     velocity = OrderedArp(list(rudiment.velocity(cycle=False)))
     kw['time'] = time
     kw['velocity'] = velocity
     Player.__init__(self, instrument, note, **kw)
コード例 #4
0
 def __init__(self, instrument, rudiment, r, l, release=None, **kw):
     """
     @param instrument: The backend instrument (Fsynth instrument etc)
     @param rudiment: A IRudiment provider
     @param r: The "right" note
     @param l: the "left" note
     @param sustainArp: An optional "sustain" value arp.
     """
     self.rudiment = rudiment
     time = rudiment.time(cycle=True).next
     note = OrderedArp(list(rudiment.strokes(r, l, cycle=False)))
     velocity = OrderedArp(list(rudiment.velocity(cycle=False)))
     kw['time'] = time
     kw['velocity'] = velocity
     Player.__init__(self, instrument, note, **kw)
コード例 #5
0
ファイル: test_midi.py プロジェクト: csv/beatlounge
 def test_player_skips_noteoff_scheduling_on_None(self):
     notePlayer = Player(self.instr1, cycle([0, 1]).next,
                         velocity=cycle([120]).next,
                         release=cycle([12, None]).next,
                         clock=self.clock, interval=self.dtt(1, 4))
     notePlayer.resumePlaying()
     self.runTicks(96)
     expectedPlays = [
         ('note', 0, 0, 120),
         ('note', 24, 1, 120),
         ('note', 48, 0, 120),
         ('note', 72, 1, 120),
         ('note', 96, 0, 120)]
     self.assertEquals(self.instr1.plays, expectedPlays)
     self.assertEquals(self.instr1.stops,
                       [('note', 12, 0), ('note', 60, 0)])
コード例 #6
0
ファイル: test_midi.py プロジェクト: csv/beatlounge
 def test_player_control_changes(self):
     notePlayer = Player(self.instr1, cycle([0, 1]).next,
                         velocity=cycle([120]).next,
                         cc={'expression': cycle([100, 115, 120]).next,
                             'sustain': cycle([50, 120]).next},
                         clock=self.clock, interval=self.dtt(1, 4))
     notePlayer.resumePlaying()
     self.runTicks(96)
     expectedPlays = [
         ('note', 0, 0, 120),
         ('note', 24, 1, 120),
         ('note', 48, 0, 120),
         ('note', 72, 1, 120),
         ('note', 96, 0, 120)]
     self.assertEquals(self.instr1.plays, expectedPlays)
     self.assertEquals(self.instr1.cc,
                       [(0, {'sustain': 50, 'expression': 100}),
                        (24, {'sustain': 120, 'expression': 115}),
                        (48, {'sustain': 50, 'expression': 120}),
                        (72, {'sustain': 120, 'expression': 100}),
                        (96, {'sustain': 50, 'expression': 115})])
コード例 #7
0
ファイル: test_midi.py プロジェクト: csv/beatlounge
 def test_pause_playing(self):
     notePlayer = Player(self.instr1, cycle([0, 1]).next,
                         velocity=cycle([120]).next,
                         clock=self.clock, interval=self.dtt(1, 4))
     notePlayer.resumePlaying()
     self.runTicks(96)
     expectedPlays = [
         ('note', 0, 0, 120),
         ('note', 24, 1, 120),
         ('note', 48, 0, 120),
         ('note', 72, 1, 120),
         ('note', 96, 0, 120)]
     self.assertEquals(self.instr1.plays, expectedPlays)
     notePlayer.pausePlaying()
     self.runTicks(96)
     notePlayer.resumePlaying()
     self.runTicks(96)
     expectedPlays.extend([
         ('note', 216, 1, 120),
         ('note', 240, 0, 120),
         ('note', 264, 1, 120),
         ('note', 288, 0, 120)])
     self.assertEquals(self.instr1.plays, expectedPlays)
コード例 #8
0
# random.choice(), if you care. Also N is special function to represent and
# return None (this translates to a pause in playing).

notes = cycle([R(60, 64, 67, 69), R(36, 48, 60, N), R(48, 52, 55),
               R(36, 40, 43, 45)]).next


# Next we'll create a callable for our velocity.

velocity = cycle([120, 80, 89, 83]).next


# Finally let's create a Player whick takes as its arguments (amongst, some
# other things), the notes generator and veocity functions from above. The
# argument stop is function which returns a "release" time (for stop notes
# played). The interval is the interval between note plays.

player = Player(piano, notes, velocity,
                release=(random.randint(12, 48) for i in cycle([1])).next,
                interval=dtt(1,8))


player.resumePlaying()

# Now try this exercise from the shell.
#
# player.stopPlaying() # Stop on the next measure
# player.interval = 0.125
# player.startPlaying()
# player.instr = bass_f()
コード例 #9
0
ファイル: song4.py プロジェクト: csv/beatlounge
from tutor.complib import piano_f, kit_f


dtt = clock.meter.dtt

notes = Adder(OctaveArp(OrderedArp([60, 48, 62, 64, 69, 71, 46])))
notes.arp.octaves = 2
notes.arp.oscillate = True
notes.amount = 12

velocity = Adder(OrderedArp([120,80,89,83,120,120,80,79]))

piano = piano_f()
pianoPlayer = Player(piano, notes, velocity,
                     release=lambda: random.randint(12,60),
                     interval=dtt(1,16))
pianoPlayer.resumePlaying()


kit = kit_f()
drumRudiment = FiveStrokeRoll()
drumPlayer = RudimentSchedulePlayer(kit, drumRudiment, 51, 48)
drumPlayer.resumePlaying()

# Now we see how we can set up a simple "process" to change the key periodically

keys = cycle([-18] * 8 + [-18,-37,-18,-37] * 4 + [-18,-26,-18,-26,-37,-26,-18])
def change_key():
    notes.amount = keys.next()
change_key_event = clock.schedule(change_key)
コード例 #10
0
ファイル: song3.py プロジェクト: csv/beatlounge
from bl.instrument.fsynth import Layer
from bl.scheduler import clock

from tutor.complib import bass_f, kit_f


dtt = clock.meter.dtt

notes1 = Adder(RandomArp())
notes1.reset([60, 60, 62, 60, 60, 60, 60, 61, 48, 50, 60, 60, 60, 60, 60, 71,
              60, 60,60,60,60,60,60,50])
notes1.amount = -18
velocity1 = Adder(OrderedArp([120,80,89,83,120,120,80,79]))
bass = bass_f()
bass_player = Player(bass, notes1, velocity1,
                     release=(lambda: random.randint(12,60)),
                     interval=dtt(1,16))
bass_player.resumePlaying()


notes2 = Adder(RandomArp())
notes2.reset([60, 60, 62])
notes2.amount = -18
velocity2 = Adder(OrderedArp([120,80,120,83,120,110,90,100]))
kit = kit_f()
kit_player = Player(kit, notes2, velocity2,
                    release=(lambda: random.randint(12,60)),
                    interval=dtt(1,16))
kit_player.resumePlaying()

コード例 #11
0
from tutor.complib import piano_f, kit_f

dtt = clock.meter.dtt

notes = Adder(OctaveArp(OrderedArp([60, 48, 62, 64, 69, 71, 46])))
notes.arp.octaves = 2
notes.arp.oscillate = True
notes.amount = 12

velocity = Adder(OrderedArp([120, 80, 89, 83, 120, 120, 80, 79]))

piano = piano_f()
pianoPlayer = Player(piano,
                     notes,
                     velocity,
                     release=lambda: random.randint(12, 60),
                     interval=dtt(1, 16))
pianoPlayer.resumePlaying()

kit = kit_f()
drumRudiment = FiveStrokeRoll()
drumPlayer = RudimentSchedulePlayer(kit, drumRudiment, 51, 48)
drumPlayer.resumePlaying()

# Now we see how we can set up a simple "process" to change the key periodically

keys = cycle([-18] * 8 + [-18, -37, -18, -37] * 4 +
             [-18, -26, -18, -26, -37, -26, -18])

コード例 #12
0
ファイル: song3.py プロジェクト: csv/beatlounge
from tutor.complib import bass_f, kit_f

dtt = clock.meter.dtt

notes1 = Adder(RandomArp())
notes1.reset([
    60, 60, 62, 60, 60, 60, 60, 61, 48, 50, 60, 60, 60, 60, 60, 71, 60, 60, 60,
    60, 60, 60, 60, 50
])
notes1.amount = -18
velocity1 = Adder(OrderedArp([120, 80, 89, 83, 120, 120, 80, 79]))
bass = bass_f()
bass_player = Player(bass,
                     notes1,
                     velocity1,
                     release=(lambda: random.randint(12, 60)),
                     interval=dtt(1, 16))
bass_player.resumePlaying()

notes2 = Adder(RandomArp())
notes2.reset([60, 60, 62])
notes2.amount = -18
velocity2 = Adder(OrderedArp([120, 80, 120, 83, 120, 110, 90, 100]))
kit = kit_f()
kit_player = Player(kit,
                    notes2,
                    velocity2,
                    release=(lambda: random.randint(12, 60)),
                    interval=dtt(1, 16))
kit_player.resumePlaying()