def test_pchoice(): a = iso.PChoice(iso.PSequence([[0, 1, 2, 3], [4, 5, 6, 7]])) a.seed(0) expected = [3, 7, 0, 6, 3, 7, 2, 7, 2, 5, 1, 6, 1, 4, 2, 5, 2, 4, 0, 6] assert a.nextn(20) == expected a.reset() assert a.nextn(20) == expected
def test_pchoice_weighted(): a = iso.PChoice(iso.PSequence([[0, 1, 2, 3], [4, 5, 6, 7]]), iso.PSequence([[1, 0.5, 0.25, 0.1]])) a.seed(0) expected = [2, 5, 0, 4, 0, 4, 1, 4, 0, 5, 2, 4, 0, 5, 1, 4, 2, 7, 1, 6] assert a.nextn(20) == expected a.reset() assert a.nextn(20) == expected
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(), "duration": 0.5, "gate": gate.copy() }) timeline.schedule({ "note": sequence.copy() - 24, "amplitude": 10 + amp.copy() * 0.5, "duration": iso.PChoice([4, 4, 6, 8]), "gate": gate.copy() }) try: timeline.run() except KeyboardInterrupt: timeline.output_device.all_notes_off()