#!/usr/bin/env python3 #------------------------------------------------------------------------ # isobar: ex-lsystem-stochastic # # Generates a stochastic L-system arpeggio #------------------------------------------------------------------------ import isobar as iso import logging logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s") notes = iso.PLSystem("N[+N--?N]+N[+?N]", depth=4) notes = iso.PDegree(notes, iso.Scale.majorPenta) notes = notes % 36 + 52 timeline = iso.Timeline(180) timeline.schedule({"note": notes, "duration": 0.25}) timeline.run()
def test_plsystem(): a = iso.PLSystem("N[-N++N]-N", 1) assert list(a) == [0, -1, 1, -1] a = iso.PLSystem("N[-N++N]-N", 2) assert list(a) == [0, -1, 1, -1, -2, -3, -1, -3, -1, -2, 0, -2, -2, -3, -1, -3]
import isobar as iso import logging logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s") #------------------------------------------------------------------------ # Generate a set of pitches based on an l-system, with recursive depth 4. # 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)
#!/usr/bin/env python3 #------------------------------------------------------------------------ # isobar: ex-lsystem-grapher # # Generates an L-system and its ASCII representation. #------------------------------------------------------------------------ import isobar as iso import logging logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(message)s") seq = iso.PLSystem("N[+N+N]?N[-N]+N", depth=3) notes = seq.all() note_min = min(notes) note_max = max(notes) for note in seq: note = note - note_min print("#" * note)