# isobar: ex-subsequence #------------------------------------------------------------------------ import isobar as iso import logging logging.basicConfig(level=logging.DEBUG, format="[%(asctime)s] %(message)s") scale = iso.Scale.pelog sequence = iso.PDegree(iso.PBrown(0, 3, -12, 12), scale) offset = iso.PStutter(iso.pattern.PWhite(0, 4), 2) sequence = iso.PSubsequence(sequence, offset, 4) sequence = iso.PPermut(sequence) sequence = sequence + 64 sequence = iso.PReset(sequence, iso.PImpulse(24)) amp = iso.pattern.PSequence([45, 35, 25, 40]) + iso.PBrown(0, 1, -15, 10) gate = iso.pattern.PBrown(1.5, 0.01, 0.6, 2.5) timeline = iso.Timeline(120) timeline.schedule({ "note": sequence.copy(), "amplitude": amp.copy(), "duration": 0.25, "gate": gate.copy() }) timeline.schedule({ "note": sequence.copy() + 24, "amplitude": amp.copy(),
def test_pimpulse(): a = iso.PImpulse(4) b = iso.PSubsequence(a, 0, 8) assert list(b) == [1, 0, 0, 0, 1, 0, 0, 0]
def test_preset(): a = iso.PSeries(0, 1) b = iso.PReset(a, iso.PImpulse(4)) c = iso.PSubsequence(b, 0, 10) assert list(c) == [0, 1, 2, 3, 0, 1, 2, 3, 0, 1]
def test_pcounter(): a = iso.PCounter(iso.PImpulse(4)) b = iso.PSubsequence(a, 0, 10) assert list(b) == [1, 1, 1, 1, 2, 2, 2, 2, 3, 3]