Exemplo n.º 1
0
def test_pwhite():
    a = iso.PWhite(iso.PConstant(5), iso.PConstant(10))
    a.seed(0)
    assert a.nextn(10) == [9, 8, 7, 6, 7, 7, 8, 6, 7, 7]

    a = iso.PWhite(iso.PConstant(-1.0), iso.PConstant(1.0))
    a.seed(0)
    assert a.nextn(10) == [
        0.6888437030500962, 0.515908805880605, -0.15885683833831,
        -0.4821664994140733, 0.02254944273721704, -0.19013172509917142,
        0.5675971780695452, -0.3933745478421451, -0.04680609169528838,
        0.1667640789100624
    ]
Exemplo n.º 2
0
#!/usr/bin/env python3

#------------------------------------------------------------------------
# isobar: ex-static-pattern
#
# Bind a chord sequence to a static sequence, which is then referenced
# in other patterns.
#------------------------------------------------------------------------

import isobar as iso

key_sequence = iso.PSequence([
    iso.Key("C", "minor"),
    iso.Key("G", "minor"),
    iso.Key("Bb", "major"),
    iso.Key("F", "major"),
])
key = iso.PStaticPattern(key_sequence, 4)
timeline = iso.Timeline(120)
timeline.schedule({"degree": 0, "key": key, "octave": 3})
timeline.schedule({
    "degree": iso.PCreep(iso.PWhite(0, 6), 2, 2, 3),
    "key": key,
    "octave": 6,
    "duration": 0.25
})
timeline.run()
Exemplo n.º 3
0
# symbols:
#  N = generate note node
#  + = transpose up one semitone
#  - = transpose down one semitone
#  [ = enter recursive branch
#  ] = leave recursive branch
#------------------------------------------------------------------------
notes = iso.PLSystem("N+[+N+N--N+N]+N[++N]", depth=4)
notes = notes + 60

#------------------------------------------------------------------------
# use another l-system to generate time intervals.
# take absolute values so that intervals are always positive.
#------------------------------------------------------------------------
times = iso.PLSystem("[N+[NN]-N+N]+N-N+N", depth=3)
times = iso.PAbs(iso.PDiff(times)) * 0.25

#------------------------------------------------------------------------
# ...and another l-system for amplitudes.
#------------------------------------------------------------------------
velocity = (iso.PLSystem("N+N[++N+N--N]-N[--N+N]") + iso.PWhite(-4, 4)) * 8
velocity = iso.PAbs(velocity)

timeline = iso.Timeline(120)
timeline.schedule({"note": notes, "amplitude": velocity, "duration": times})

try:
    timeline.run()
except KeyboardInterrupt:
    timeline.output_device.all_notes_off()