Skip to content

Commit

Permalink
Tweaks to autodocs
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Jul 1, 2024
1 parent e0763dc commit 5fe5ed0
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 106 deletions.
10 changes: 8 additions & 2 deletions auxiliary/scripts/generate-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,19 @@ class dictionaries with their names, descriptions, and arguments and code exampl
# Format the file text into a list per line
class_content = []
class_content.append("# Pattern: %s" % class_dict['classname'])
class_content.append(class_dict['short_description'])
class_content.append("%s" % class_dict['short_description'])

if (class_dict['long_description']):
class_content.append(class_dict['long_description'])

if (class_dict['arguments']):
class_content.append("## Arguments")
class_content.append(class_dict['arguments'])

if (class_dict['example_output']):
class_content.append("## Example Output")
class_content.append("## Example output")
class_content.append("```py\n%s```" % class_dict['example_output'])

# Output to the proper file (adding .md to the actual file name)
fname = (os.path.join(root_dir, file_dict['name'].lower(), class_dict['classname'].lower() + ".md"))
with open(fname, "w") as f:
Expand Down Expand Up @@ -225,6 +229,8 @@ def parse_class_data():
# Get first line for short description
desc = desc.split("\n", 1)
short_desc = desc[0]
if ':' in short_desc:
short_desc = short_desc[short_desc.index(':') + 2:]
# Get the rest before code for a long description (if available)
long_desc = None
output = None
Expand Down
243 changes: 139 additions & 104 deletions docs/patterns/library.md
Original file line number Diff line number Diff line change
@@ -1,142 +1,177 @@
## Core
## [Chance](chance/index.md)
View source: [chance.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/chance.py)

| Class | Function |
|-|-|
| [PStochasticPattern](chance/pstochasticpattern.md) | PStochasticPattern is the superclass of all chance-based patterns. |
| [PWhite](chance/pwhite.md) | White noise between `min` and `max`. |
| [PBrown](chance/pbrown.md) | Brownian noise. |
| [PCoin](chance/pcoin.md) | Coin toss, returning either 0 or 1 given some `probability`. |
| [PRandomWalk](chance/prandomwalk.md) | Random walk around list. |
| [PChoice](chance/pchoice.md) | Pick a random element from `values`, weighted by optional `weights`. |
| [PSample](chance/psample.md) | Pick multiple random elements from `values`, weighted by optional `weights`, |
| [PShuffle](chance/pshuffle.md) | Shuffled list. |
| [PShuffleInput](chance/pshuffleinput.md) | Every `n` steps, take `n` values from `pattern` and reorder. |
| [PSkip](chance/pskip.md) | Skip events with some probability, 1 - `play`. |
| [PFlipFlop](chance/pflipflop.md) | flip a binary bit with some probability. |
| [PSwitchOne](chance/pswitchone.md) | Capture `length` input values; loop, repeatedly switching two adjacent values. |
| [PRandomExponential](chance/prandomexponential.md) | Random uniform on exponential curve between `min` and `max`, |
| [PRandomImpulseSequence](chance/prandomimpulsesequence.md) | Random sequence of impulses with probability `probability`. |


## [Core](core/index.md)
View source: [core.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/core.py)

| Class | Function |
|-|-|
| Pattern | Abstract superclass of all pattern generators. |
| PConstant | Returns a fixed value. |
| PRef | Contains a reference to another pattern, which can be replaced dynamically. |
| PFunc | Returns the value generated by a function. |
| PArrayIndex | Request a specified index from an array. |
| PDict | Construct a pattern from a dict of arrays, or an array of dicts. |
| PDictKey | Request a specified key from a dictionary. |
| PConcatenate | Concatenate the output of multiple sequences. |
| PAbs | Absolute value of `input` |
| PInt | Integer value of `input` |
| PAdd | Add elements of two patterns (shorthand: patternA + patternB) |
| PSub | Subtract elements of two patterns (shorthand: patternA - patternB) |
| PMul | Multiply elements of two patterns (shorthand: patternA * patternB) |
| PDiv | Divide elements of two patterns (shorthand: patternA / patternB) |
| PFloorDiv | Integer division (shorthand: patternA // patternB) |
| PMod | Modulo elements of two patterns (shorthand: patternA % patternB) |
| PPow | One pattern to the power of another (shorthand: patternA ** patternB) |
| PLShift | Binary left-shift (shorthand: patternA << patternB) |
| PRShift | Binary right-shift (shorthand: patternA << patternB) |
| PEqual | Return 1 if a == b, 0 otherwise (shorthand: patternA == patternB) |
| PGreaterThanOrEqual | Return 1 if a != b, 0 otherwise (shorthand: patternA != patternB) |
| PGreaterThan | Return 1 if a > b, 0 otherwise (shorthand: patternA > patternB) |
| PGreaterThanOrEqual | Return 1 if a >= b, 0 otherwise (shorthand: patternA >= patternB) |
| PLessThan | Return 1 if a < b, 0 otherwise (shorthand: patternA < patternB) |
| PLessThanOrEqual | Return 1 if a <= b, 0 otherwise (shorthand: patternA <= patternB) |

## Scalar
View source: [scalar.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/scalar.py)
| [Pattern](core/pattern.md) | Abstract superclass of all pattern generators. |
| [PConstant](core/pconstant.md) | Returns a fixed value. |
| [PRef](core/pref.md) | Contains a reference to another pattern, which can be replaced dynamically. |
| [PFunc](core/pfunc.md) | Returns the value generated by a function. |
| [PArrayIndex](core/parrayindex.md) | Request a specified index from an array. |
| [PDict](core/pdict.md) | Construct a pattern from a dict of arrays, or an array of dicts. |
| [PDictKey](core/pdictkey.md) | Request a specified key from a dictionary. |
| [PConcatenate](core/pconcatenate.md) | Concatenate the output of multiple sequences. |
| [PAbs](core/pabs.md) | Absolute value of `input` |
| [PInt](core/pint.md) | Integer value of `input` |
| [PAdd](core/padd.md) | Add elements of two patterns (shorthand: patternA + patternB) |
| [PSub](core/psub.md) | Subtract elements of two patterns (shorthand: patternA - patternB) |
| [PMul](core/pmul.md) | Multiply elements of two patterns (shorthand: patternA * patternB) |
| [PDiv](core/pdiv.md) | Divide elements of two patterns (shorthand: patternA / patternB) |
| [PFloorDiv](core/pfloordiv.md) | Integer division (shorthand: patternA // patternB) |
| [PMod](core/pmod.md) | Modulo elements of two patterns (shorthand: patternA % patternB) |
| [PPow](core/ppow.md) | One pattern to the power of another (shorthand: patternA ** patternB) |
| [PLShift](core/plshift.md) | Binary left-shift (shorthand: patternA << patternB) |
| [PRShift](core/prshift.md) | Binary right-shift (shorthand: patternA << patternB) |
| [PEqual](core/pequal.md) | Return 1 if a == b, 0 otherwise (shorthand: patternA == patternB) |
| [PNotEqual](core/pnotequal.md) | Return 1 if a != b, 0 otherwise (shorthand: patternA != patternB) |
| [PGreaterThan](core/pgreaterthan.md) | Return 1 if a > b, 0 otherwise (shorthand: patternA > patternB) |
| [PGreaterThanOrEqual](core/pgreaterthanorequal.md) | Return 1 if a >= b, 0 otherwise (shorthand: patternA >= patternB) |
| [PLessThan](core/plessthan.md) | Return 1 if a < b, 0 otherwise (shorthand: patternA < patternB) |
| [PLessThanOrEqual](core/plessthanorequal.md) | Return 1 if a <= b, 0 otherwise (shorthand: patternA <= patternB) |
| [PAnd](core/pand.md) | Return True if a and b, False otherwise (shorthand: patternA & patternB) |


## [Fade](fade/index.md)
View source: [fade.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/fade.py)

| Class | Function |
|-|-|
| PChanged | Outputs a 1 if the value of a pattern has changed. |
| PDiff | Outputs the difference between the current and previous values of an input pattern |
| PSkipIf | If `skip` is false, returns `input`; otherwise, returns None. |
| PNormalise | Adaptively normalise `input` to [0..1] over a linear scale. |
| PMap | Apply an arbitrary function to an input pattern. |
| PMapEnumerated | Apply arbitrary function to input, passing a counter. |
| PLinLin | Map `input` from linear range [a,b] to linear range [c,d]. |
| PLinExp | Map `input` from linear range [a,b] to exponential range [c,d]. |
| PRound | Round `input` to N decimal places. |
| PScalar | Reduce tuples and lists into single scalar values, |
| PWrap | Wrap input note values within <min>, <max>. |
| PIndexOf | Find index of items from `pattern` in <list> |

## Sequence
View source: [sequence.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/sequence.py)
| [PFadeNotewise](fade/pfadenotewise.md) | Fade a pattern in/out by introducing notes at a gradual rate. |
| [PFadeNotewiseRandom](fade/pfadenotewiserandom.md) | Fade a pattern in/out by gradually introducing random notes. |


## [Lsystem](lsystem/index.md)
View source: [lsystem.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/lsystem.py)

| Class | Function |
|-|-|
| PSeries | Arithmetic series, beginning at `start`, increment by `step` |
| PRange | Similar to PSeries, but specify a max/step value. |
| PGeom | Geometric series, beginning at `start`, multiplied by `step` |
| PImpulse | Outputs a 1 every <period> events, otherwise 0. |
| PLoop | Repeats a finite `pattern` for `n` repeats. |
| PPingPong | Ping-pong input pattern back and forth N times. |
| PCreep | Loop `length`-note segment, progressing `creep` notes after `repeats` repeats. |
| PStutter | Play each note of `pattern` `count` times. |
| PSubsequence | Returns a finite subsequence of an input pattern. |
| PReverse | Reverses a finite sequence. |
| PReset | Resets `pattern` whenever `trigger` is true |
| PCounter | Increments a counter by 1 for each zero-crossing in `trigger`. |
| PCollapse | Skip over any rests in `input` |
| PNoRepeats | Skip over repeated values in `input` |
| PPad | Pad `pattern` with rests until it reaches length `length`. |
| PPadToMultiple | Pad `pattern` with rests until its length is divisible by `multiple`. |
| PArpeggiator | Arpeggiator. |
| PEuclidean | Generate Euclidean rhythms. |
| PPermut | Generate every permutation of `count` input items. |
| PPatternGeneratorAction | Each time its pattern is exhausted, request a new pattern by calling <fn>. |
| PSequenceAction | Iterate over an array, perform a function, and repeat. |

## Chance
View source: [chance.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/chance.py)
| [PLSystem](lsystem/plsystem.md) | integer sequence derived from Lindenmayer systems |


## [Markov](markov/index.md)
View source: [markov.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/markov.py)

| Class | Function |
|-|-|
| PWhite | White noise between `min` and `max`. |
| PBrown | Brownian noise. |
| PCoin | Coin toss, returning either 0 or 1 given some `probability`. |
| PWalk | Random walk around list. |
| PChoice | Pick a random element from `values`, weighted by optional `weights`. |
| PSample | Pick multiple random elements from `values`, weighted by optional `weights`, |
| PShuffle | Shuffled list. |
| PShuffleInput | Every `n` steps, take `n` values from `pattern` and reorder. |
| PSkip | Skip events with some probability, 1 - <play>. |
| PFlipFlop | flip a binary bit with some probability. |
| PSwitchOne | Capture `length` input values; loop, repeatedly switching two adjacent values. |

## Tonal
View source: [tonal.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/tonal.py)
| [PMarkov](markov/pmarkov.md) | First-order Markov chain generator. |
| [MarkovLearner](markov/markovlearner.md) | Learn a Markovian sequence by sequentially registering new values |
| [MarkovGrapher](markov/markovgrapher.md) | Helper class to graph the structure of a Markov object. |


## [Midi](midi/index.md)
View source: [midi.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/midi.py)

| Class | Function |
|-|-|
| PDegree | Map scale index <degree> to MIDI notes in <scale>. |
| PFilterByKey | Filter notes based on their presence in <key>. |
| PNearestNoteInKey | Return the nearest note in <key>. |
| PMidiNoteToFrequency | Map MIDI note to frequency value. |

## Static
View source: [static.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/static.py)

## [Oscillator](oscillator/index.md)
View source: [oscillator.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/oscillator.py)

| Class | Function |
|-|-|
| PGlobals | Static global value identified by a string. |
| PCurrentTime | Returns the position (in beats) of the current timeline. |
| [PTri](oscillator/ptri.md) | Generates a triangle waveform of period `length`. |
| [PSaw](oscillator/psaw.md) | Generates a sawtooth waveform. |

## Fade
View source: [fade.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/fade.py)

## [Scalar](scalar/index.md)
View source: [scalar.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/scalar.py)

| Class | Function |
|-|-|
| PFadeNotewise | Fade a pattern in/out by introducing notes at a gradual rate. |
| PFadeNotewiseRandom | Fade a pattern in/out by gradually introducing random notes. |
| [PChanged](scalar/pchanged.md) | Outputs a 1 if the value of the input pattern has changed, |
| [PDiff](scalar/pdiff.md) | Outputs the difference between the current and previous values of an input pattern |
| [PSkipIf](scalar/pskipif.md) | If `skip` is false, returns `input`; otherwise, returns None. |
| [PNormalise](scalar/pnormalise.md) | Adaptively normalise `input` to [0..1] over a linear scale. |
| [PMap](scalar/pmap.md) | Apply an arbitrary function to an input pattern. |
| [PMapEnumerated](scalar/pmapenumerated.md) | Apply arbitrary function to input, passing a counter. |
| [PScaleLinLin](scalar/pscalelinlin.md) | Map `input` from linear range [a,b] to linear range [c,d]. |
| [PScaleLinExp](scalar/pscalelinexp.md) | Map `input` from linear range [a,b] to exponential range [c,d]. |
| [PRound](scalar/pround.md) | Round `input` to N decimal places. |
| [PScalar](scalar/pscalar.md) | Reduce tuples and lists into single scalar values, |
| [PWrap](scalar/pwrap.md) | Wrap input note values within <min>, <max>. |
| [PIndexOf](scalar/pindexof.md) | Find index of items from `pattern` in <list> |


## [Sequence](sequence/index.md)
View source: [sequence.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/sequence.py)

## Markov
View source: [markov.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/markov.py)
| Class | Function |
|-|-|
| [PSequence](sequence/psequence.md) | Sequence of values based on an array |
| [PSeries](sequence/pseries.md) | Arithmetic series, beginning at `start`, increment by `step` |
| [PRange](sequence/prange.md) | Similar to PSeries, but specify a max/step value. |
| [PGeom](sequence/pgeom.md) | Geometric series, beginning at `start`, multiplied by `step` |
| [PImpulse](sequence/pimpulse.md) | Outputs a 1 every <period> events, otherwise 0. |
| [PLoop](sequence/ploop.md) | Repeats a finite `pattern` for `n` repeats. |
| [PPingPong](sequence/ppingpong.md) | Ping-pong input pattern back and forth N times. |
| [PCreep](sequence/pcreep.md) | Loop `length`-note segment, progressing `creep` notes after `repeats` repeats. |
| [PStutter](sequence/pstutter.md) | Play each note of `pattern` `count` times. |
| [PSubsequence](sequence/psubsequence.md) | Returns a finite subsequence of an input pattern. |
| [PReverse](sequence/preverse.md) | Reverses a finite sequence. |
| [PReset](sequence/preset.md) | Resets `pattern` whenever `trigger` is true |
| [PCounter](sequence/pcounter.md) | Increments a counter by 1 for each zero-crossing in `trigger`. |
| [PCollapse](sequence/pcollapse.md) | Skip over any rests in `input` |
| [PNoRepeats](sequence/pnorepeats.md) | Skip over repeated values in `input` |
| [PPad](sequence/ppad.md) | Pad `pattern` with rests until it reaches length `length`. |
| [PPadToMultiple](sequence/ppadtomultiple.md) | Pad `pattern` with rests until its length is divisible by `multiple`. |
| [PArpeggiator](sequence/parpeggiator.md) | Arpeggiator. |
| [PEuclidean](sequence/peuclidean.md) | Generate Euclidean rhythms. |
| [PPermut](sequence/ppermut.md) | Generate every permutation of `count` input items. |
| [PPatternGeneratorAction](sequence/ppatterngeneratoraction.md) | Each time its pattern is exhausted, request a new pattern by calling <fn>. |
| [PSequenceAction](sequence/psequenceaction.md) | Iterate over an array, perform a function, and repeat. |


## [Static](static/index.md)
View source: [static.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/static.py)

| Class | Function |
|-|-|
| PMarkov | First-order Markov chain generator. |
| [Globals](static/globals.md) | The Globals class encapsulates a namespace of global variables that can be accessed |
| [PGlobals ](static/pglobals .md) | Static global value identified by a string. |
| [PCurrentTime](static/pcurrenttime.md) | Returns the position (in beats) of the current timeline. |

## Lsystem
View source: [lsystem.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/lsystem.py)

## [Tonal](tonal/index.md)
View source: [tonal.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/tonal.py)

| Class | Function |
|-|-|
| PLSystem | integer sequence derived from Lindenmayer systems |
| [PDegree](tonal/pdegree.md) | Map scale index <degree> to MIDI notes in <scale>. |
| [PFilterByKey](tonal/pfilterbykey.md) | Filter notes based on their presence in <key>. |
| [PNearestNoteInKey](tonal/pnearestnoteinkey.md) | Return the nearest note in <key>. |
| [PMidiNoteToFrequency](tonal/pmidinotetofrequency.md) | Map MIDI note to frequency value. |
| [PMidiSemitonesToFrequencyRatio](tonal/pmidisemitonestofrequencyratio.md) | Map a MIDI offet in semitones to a frequency ratio. |

## Warp

## [Warp](warp/index.md)
View source: [warp.py](https://github.com/ideoforms/isobar/tree/master/isobar/pattern/warp.py)

| Class | Function |
|-|-|
| PWInterpolate | Requests a new target warp value from `pattern` every `length` beats |
| PWSine | Sinosoidal warp, period `length` beats, amplitude +/-<amp>. |
| PWRallantando | Exponential deceleration to <amp> times the current tempo over `length` beats. |
| [PWarp](warp/pwarp.md) | Requests a new target warp value from `pattern` every `length` beats |
| [PWSine](warp/pwsine.md) | Sinosoidal warp, period `length` beats, amplitude +/-<amp>. |
| [PWRallantando](warp/pwrallantando.md) | Exponential deceleration to <amp> times the current tempo over `length` beats. |


0 comments on commit 5fe5ed0

Please sign in to comment.