@@ -13,53 +13,56 @@ Most of the major parts of isobar are subclasses of `Pattern`, which implement's
1313# Usage
1414
1515``` python
16- from isobar import *
17-
18- # create a repeating sequence with scalar transposition:
19- # [ 36, 38, 43, 39, ... ]
20- a = PSeq([ 0 , 2 , 7 , 3 ]) + 36
21-
22- # apply pattern-wise transposition
23- # [ 36, 50, 43, 51, ... ]
24- a = a + PSeq([ 0 , 12 ])
25-
26- # create a geometric chromatic series, repeated back and forth
27- b = PSeries(0 , 1 , 12 ) + 72
28- b = PPingPong(b)
29- b = PLoop(b)
30-
31- # create an velocity series, with emphasis every 4th note,
32- # plus a random walk to create gradual dynamic changes
33- amp = PSeq([ 50 , 35 , 25 , 35 ]) + PBrown(0 , 1 , - 20 , 20 )
34-
35- # a Timeline schedules events at a given BPM.
36- # by default, send these over the first MIDI output.
37- timeline = Timeline(120 )
38-
39- # assign each of our Patterns to particular properties
40- timeline.sched({ ' note' : a, ' dur' : 1 , ' gate' : 2 })
41- timeline.sched({ ' note' : b, ' dur' : 0.25 , ' amp' : amp })
42-
43- timeline.run()
44-
16+ import isobar as iso
17+
18+ # ------------------------------------------------------------------------
19+ # Create a geometric series on a minor scale.
20+ # PingPong plays the series forward then backward. PLoop loops forever.
21+ # ------------------------------------------------------------------------
22+ arpeggio = iso.PSeries(0 , 2 , 6 )
23+ arpeggio = iso.PDegree(arpeggio, iso.Scale.minor) + 72
24+ arpeggio = iso.PPingPong(arpeggio)
25+ arpeggio = iso.PLoop(arpeggio)
26+
27+ # ------------------------------------------------------------------------
28+ # Create a velocity sequence, with emphasis every 4th note,
29+ # plus a random walk to create gradual dynamic changes.
30+ # Amplitudes are in the MIDI velocity range (0..127).
31+ # ------------------------------------------------------------------------
32+ amplitude = iso.PSequence([50 , 35 , 25 , 35 ]) + iso.PBrown(0 , 1 , - 20 , 20 )
33+
34+ # ------------------------------------------------------------------------
35+ # A Timeline schedules events at a given BPM.
36+ # ------------------------------------------------------------------------
37+ timeline = iso.Timeline(120 )
38+
39+ # ------------------------------------------------------------------------
40+ # Schedule events, with properties mapped to the Pattern objects.
41+ # ------------------------------------------------------------------------
42+ timeline.schedule({
43+ iso.EVENT_NOTE : arpeggio,
44+ iso.EVENT_DURATION : 0.25 ,
45+ iso.EVENT_AMPLITUDE : amplitude
46+ })
4547```
4648
4749## Examples
4850
49- More examples are available in the ' examples' directory with this
51+ More examples are available in the [ examples] ( examples ) directory with this
5052distribution:
5153
52- * [ ex-basics.py] ( examples/ex-basics.py )
53- * [ ex-lsystem-grapher.py] ( examples/ex-lsystem-grapher.py )
54- * [ ex-lsystem-rhythm.py] ( examples/ex-lsystem-rhythm.py )
55- * [ ex-lsystem-stochastic.py] ( examples/ex-lsystem-stochastic.py )
56- * [ ex-markov-learner.py] ( examples/ex-markov-learner.py )
57- * [ ex-permut-degree.py] ( examples/ex-permut-degree.py )
58- * [ ex-piano-phase.py] ( examples/ex-piano-phase.py )
59- * [ ex-prime-composition.py] ( examples/ex-prime-composition.py )
60- * [ ex-subsequence.py] ( examples/ex-subsequence.py )
61- * [ ex-walk.py] ( examples/ex-walk.py )
62-
54+ * [ 00.ex-hello-world.py] ( examples/00.ex-hello-world.py )
55+ * [ 01.ex-basics.py] ( examples/01.ex-basics.py )
56+ * [ 02.ex-subsequence.py] ( examples/02.ex-subsequence.py )
57+ * [ 03.ex-euclidean.py] ( examples/03.ex-euclidean.py )
58+ * [ 04.ex-permutations.py] ( examples/04.ex-permutations.py )
59+ * [ 05.ex-piano-phase.py] ( examples/05.ex-piano-phase.py )
60+ * [ 06.ex-walk.py] ( examples/06.ex-walk.py )
61+ * [ 10.ex-lsystem-stochastic.py] ( examples/10.ex-lsystem-stochastic.py )
62+ * [ 11.ex-lsystem-rhythm.py] ( examples/11.ex-lsystem-rhythm.py )
63+ * [ 12.ex-lsystem-grapher.py] ( examples/12.ex-lsystem-grapher.py )
64+ * [ 20.ex-markov-learner.py] ( examples/20.ex-markov-learner.py )
65+ * [ 30.ex-midifile-write.py] ( examples/30.ex-midifile-write.py )
6366
6467## Classes
6568
@@ -82,11 +85,11 @@ Pattern classes:
8285
8386 CORE (core.py)
8487 Pattern - Abstract superclass of all pattern generators.
85- PConst - Pattern returning a fixed value
88+ PConstant - Pattern returning a fixed value
8689 PRef - Pattern containing a reference to another pattern
8790 PDict - Dict of patterns
91+ PDictKey - Request a specified key from a dictionary.
8892 PIndex - Request a specified index from an array.
89- PKey - Request a specified key from a dictionary.
9093 PConcat - Concatenate the output of multiple sequences.
9194 PAdd - Add elements of two patterns (shorthand: patternA + patternB)
9295 PSub - Subtract elements of two patterns (shorthand: patternA - patternB)
@@ -99,12 +102,12 @@ Pattern classes:
99102 PRShift - Binary right-shift (shorthand: patternA << patternB)
100103
101104 SEQUENCE (sequence.py)
102- PSeq - Sequence of values based on an array
105+ PSequence - Sequence of values based on an array
103106 PSeries - Arithmetic series, beginning at <start>, increment by <step>
104107 PRange - Similar to PSeries, but specify a max/step value.
105108 PGeom - Geometric series, beginning at <start>, multiplied by <step>
106109 PLoop - Repeats a finite <pattern> for <n> repeats.
107- PConcat - Concatenate the output of multiple finite sequences
110+ PConcatenate - Concatenate the output of multiple finite sequences
108111 PPingPong - Ping-pong input pattern back and forth N times.
109112 PCreep - Loop <length>-note segment, progressing <creep> notes after <count> repeats.
110113 PStutter - Play each note of <pattern> <count> times.
@@ -159,7 +162,7 @@ Pattern classes:
159162 PMarkov - First-order Markov chain.
160163
161164 LSYSTEM (lsystem.py)
162- PLSys - integer sequence derived from Lindenmayer systems
165+ PLSystem - integer sequence derived from Lindenmayer systems
163166
164167 WARP (warp.py)
165168 PWInterpolate - Requests a new target warp value from <pattern> every <length> beats
0 commit comments