Beispiel #1
0
def main():
    global opts, instrument
    parser = optparse.OptionParser()
    parser.add_option('-v', '--volume', dest='volume', default=100, type='int')
    parser.add_option('-s',
                      '--range-start',
                      dest='range_start',
                      default=0,
                      type='int')
    parser.add_option('-e',
                      '--range-end',
                      dest='range_end',
                      default=128,
                      type='int')
    parser.add_option('-i',
                      '--interval',
                      dest='interval',
                      default=0.125,
                      type='float')
    parser.add_option('-n', '--note', dest='note', default=-1, type='int')
    parser.add_option('-p', '--preset', dest='preset', default=0, type='int')
    parser.add_option('-b', '--bank', dest='bank', default=0, type='int')

    opts, args = parser.parse_args()
    sf2path = args[0]
    if opts.note != -1:
        opts.range_start = opts.note
        opts.range_end = opts.note + 1

    gen = cycle(range(opts.range_start, opts.range_end))

    def noteGenerator():
        next = gen.next()
        print 'note', next
        return next

    instrument = Instrument(sf2path, preset=opts.preset, bank=opts.bank)
    player = Player(instrument,
                    noteGenerator,
                    Sustainer(opts.volume),
                    stop=lambda: measuresToTicks(opts.interval))

    clock.schedule(player.play).startLater(1, opts.interval)
    clock.run()
Beispiel #2
0
def main():
    global opts, instrument
    parser = optparse.OptionParser()
    parser.add_option('-v', '--volume', dest='volume', default=100, type='int')
    parser.add_option('-s', '--range-start', dest='range_start', default=0,
                                                                    type='int')
    parser.add_option('-e', '--range-end', dest='range_end', default=128,
                                                                    type='int')
    parser.add_option('-i', '--interval', dest='interval', default=0.125,
                                                                type='float')
    parser.add_option('-n', '--note', dest='note', default=-1, type='int')
    parser.add_option('-p', '--preset', dest='preset', default=0, type='int')
    parser.add_option('-b', '--bank', dest='bank', default=0, type='int')

    opts, args = parser.parse_args()
    sf2path = args[0]
    if opts.note != -1:
        opts.range_start = opts.note
        opts.range_end = opts.note + 1

    gen = cycle(range(opts.range_start, opts.range_end))

    def noteGenerator():
        next = gen.next()
        print 'note', next
        return next

    instrument = Instrument(sf2path, preset=opts.preset, bank=opts.bank)
    player = Player(instrument,
        noteGenerator,
        Sustainer(opts.volume),
        stop=lambda: measuresToTicks(opts.interval)
    )

    clock.schedule(player.play).startLater(1, opts.interval)
    clock.run()
Beispiel #3
0
def hitsomenote():

    # We have no clue what to do with this piano. Let's just
    # hit a note with some random amount of force.

    note = random.choice(scale)
    velocity = random.randint(40, 127)
    instrument.playnote(note, velocity)

    # And we'll take our finger off ... some time later
    release = random.choice((quaver, quarter, half, one_and_half))
    clock.callLater(release, instrument.stopnote, note)


event = clock.schedule(hitsomenote)
event.startAfter((1, 1), (1, 8))

# Now try this exercise from the shell.
#
# >>> event.stopLater(1) # Stop on the next measure
# >>> event.startLater(1, 0.0625) # restart, but this time every semiquaver

# Also try redfining scale to something less ... random.
# Here's another example to play with


def harmonize(steps):
    current = 0
    for step in steps:
        current += step
Beispiel #4
0
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)
change_key_event.startAfter((1,1), (1,1))


# TODO say some things with some enthusiasm ... late
Beispiel #5
0
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)
change_key_event.startAfter((1, 1), (1, 1))

# TODO say some things with some enthusiasm ... late
Beispiel #6
0
               [38, 53, 55, 67, 69, 74],
               [38, 53, 55, 65, 67, 74],
               [36, 53, 55, 65, 67, 74],
               [36, 55, 57, 65, 67, 74],
               [36, 55, 57, 60, 67, 74],
               [36, 55, 57, 60, 64, 74],
               [36, 55, 57, 60, 64, 80],
               [36, 55, 57, 60, 64, 81],
               [36, 55, 57, 60, 64, 84],
               [36, 55, 57, 60, 63, 84],
               [36, 55, 57, 60, 64, 84],
               [36, 55, 57, 60, 69, 84],
               [36, 55, 57, 60, 69, 81],
               [36, 55, 57, 60, 69, 78],
               [36, 53, 55, 60, 69, 78],
               [36, 53, 55, 62, 69, 78]])

piano = piano_f()
piano.controlChange(reverb=120, sustain=100, chorus=50, vibrato=15)

r = W((0, 5), (12, 2), (-12, 3))
f = lambda chord: [r() + n for n in chord]
arp = ArpMap(f, ChordPatternArp(notes.next(), pattern))

player = ChordPlayer(piano, arp,
                     velocity=OrderedArp([127, 80, 90, 80, 90, 120, 120, 80]),
                     release=RandomArp([11, 10, 9, 8]))
resetter = clock.schedule(lambda: arp.reset(notes.next())
        ).startAfter((2, 1), (2, 1))
player.resumePlaying()
Beispiel #7
0

    # We have no clue what to do with this piano. Let's just
    # hit a note with some random amount of force.

    note = random.choice(scale)
    velocity = random.randint(40, 127)
    instrument.playnote(note, velocity)


    # And we'll take our finger off ... some time later
    release = random.choice((quaver, quarter, half, one_and_half))
    clock.callLater(release, instrument.stopnote, note)


event = clock.schedule(hitsomenote)
event.startAfter((1,1), (1,8))


# Now try this exercise from the shell.
#
# >>> event.stopLater(1) # Stop on the next measure
# >>> event.startLater(1, 0.0625) # restart, but this time every semiquaver

# Also try redfining scale to something less ... random.
# Here's another example to play with

def harmonize(steps):
    current = 0
    for step in steps:
        current += step
Beispiel #8
0
notes = cycle([[38, 50, 62, 65, 69, 80], [38, 50, 62, 65, 69, 84],
               [38, 50, 62, 65, 67, 84], [38, 50, 62, 65, 69, 84],
               [36, 50, 62, 65, 69, 84], [36, 55, 62, 65, 69, 84],
               [36, 55, 62, 67, 69, 84], [36, 55, 60, 67, 69, 84],
               [36, 53, 55, 67, 69, 84], [36, 53, 55, 67, 69, 81],
               [36, 53, 55, 65, 69, 81], [36, 53, 55, 65, 67, 81],
               [38, 53, 55, 65, 67, 81], [38, 53, 55, 67, 69, 81],
               [38, 53, 55, 67, 69, 74], [38, 53, 55, 65, 67, 74],
               [36, 53, 55, 65, 67, 74], [36, 55, 57, 65, 67, 74],
               [36, 55, 57, 60, 67, 74], [36, 55, 57, 60, 64, 74],
               [36, 55, 57, 60, 64, 80], [36, 55, 57, 60, 64, 81],
               [36, 55, 57, 60, 64, 84], [36, 55, 57, 60, 63, 84],
               [36, 55, 57, 60, 64, 84], [36, 55, 57, 60, 69, 84],
               [36, 55, 57, 60, 69, 81], [36, 55, 57, 60, 69, 78],
               [36, 53, 55, 60, 69, 78], [36, 53, 55, 62, 69, 78]])

piano = piano_f()
piano.controlChange(reverb=120, sustain=100, chorus=50, vibrato=15)

r = W((0, 5), (12, 2), (-12, 3))
f = lambda chord: [r() + n for n in chord]
arp = ArpMap(f, ChordPatternArp(notes.next(), pattern))

player = ChordPlayer(piano,
                     arp,
                     velocity=OrderedArp([127, 80, 90, 80, 90, 120, 120, 80]),
                     release=RandomArp([11, 10, 9, 8]))
resetter = clock.schedule(lambda: arp.reset(notes.next())).startAfter((2, 1),
                                                                      (2, 1))
player.resumePlaying()