Pattern Modules

Pattern modules are generative; they generate patterns or values according to their control inputs.


Random RandPlus RandInt RandWalk Shuffle

Probability Corruption Feedback SampRpt

Evolve

FuncGen Lissajous Spiro


Random

Produces a non repeating random floating point number from 0 to 1. Random number patterns, while non repeating by default, can be set to repeat their pattern by selecting "Random Numbers repeat after Reset" in the System module properties or from Patch Options, in the Main Menu. For a highly controlled repeating random number sequence, use a Sequencer module initialized with a random pattern.

This module has a user settable number of outputs, with a separate RNG for each output. To change the number of outputs, click on the blue-label property button on the upper right of the module, and click on the "More" or "Fewer" button on the Outputs tab. You have the option to set custom input labels and tool tips if you like.

You also have the option, by checking the box at the bottom of the property dialog, of setting the module to produce a new value on Change instead of Strobe.

Output:

Out N: Random decimal fraction between 0 and 1.

Input:

Strb (Chng): Strobe (change) produces new random values.


RandPlus

Produces a non repeating random floating point number with range multiplier and offset. Random number patterns, while non repeating by default, can be set to repeat their pattern by selecting "Random Numbers repeat after Reset" in the System module properties or from Patch Options, in the Main Menu. For a highly controlled repeating random number sequence, use a Sequencer module initialized with a random pattern.

This module has a user settable number of outputs, with a separate RNG for each output. To change the number of outputs, click on the blue-label property button on the upper right of the module, and click on the "More" or "Fewer" button on the Outputs tab. You have the option to set custom input labels and tool tips if you like.

You also have the option, by checking the box at the bottom of the property dialog, of setting the module to produce a new value on Change instead of Strobe.

This module is especially useful when you need several random numbers set to the same range. Each random value produced is multiplied by the Mul input, then the Ofst input is added, finally it is multiplied by -1 if the Neg input is non zero.

Output:

Out N: Random value multiplied by Mul, with Ofst added, and negated if Neg is NZ.

Input:

Strb (Chng): Strobe (change) produces new random values.

Mul: Multiply output(s) by the value in this input.

Ofst: Offset added to output(s) after Multiply.

Neg: Negate output(s) if non zero, effectivly multiplying each by -1.


RandInt

Produces a non repeating random integer from 0 to Range (+ offset). Random number patterns, while non repeating by default, can be set to repeat their pattern by selecting "Random Numbers repeat after Reset" in the System module properties or from Patch Options, in the Main Menu. For a highly controlled repeating random number sequence, use a Sequencer module initialized with a random pattern.

This module has a user settable number of outputs, with a separate RNG for each output. To change the number of outputs, click on the blue-label property button on the upper right of the module, and click on the "More" or "Fewer" button on the Outputs tab. You have the option to set custom input labels and tool tips if you like.

You also have the option, by checking the box at the bottom of the property dialog, of setting the module to produce a new value on Change instead of Strobe.

Output:

Out N: Random integer from 0 to Range (+ offset).

Input:

Strb (Chng): Strobe (change) produces new random values.

Range: Upper limit of random integer.

Ofst: Offset added to random integer.


RandWalk

Produces a random walk ("1/f") pattern, with each step, while random, determined by the preceding steps. The delta, or step range, can be adjusted, as well as the low frequency, "wander" component, along with the propensity to wander up or down.

This module has a user settable number of outputs, with a separate RNG for each output. To change the number of outputs, click on the blue-label property button on the upper right of the module, and click on the "More" or "Fewer" button on the Outputs tab. You have the option to set custom input labels and tool tips if you like.

You also have the option, by checking the box at the bottom of the property dialog, of setting the module to produce a new value on Change instead of Strobe.

Output:

Out N: Random integer from 0 to Range (+ offset), and within +/- Delta of previous value, with probability that it will continue in the same direction set by the relative Up & Down inputs.

Input:

Strb (Chng): Strobe (change) produces new values.

Delta: Maximum change per step.

Range: Upper limit of generated value.

Ofst: Offset added to generated value.

Up: Bias to favor upward motion (0.0 to 1.0).

Down: Bias to favor downward motion (0.0 to 1.0).


Shuffle

Produces a repeating random integer from 0 to Range. This is like shuffling a deck of cards, where there is a random arrangement of the cards, but no card repeats until all are used. Can be set to repeat the same pattern, to repeat the pattern backwards, or to reshuffle at the end of each pattern. When set to reshuffle (Patrn input = 2), it tests to disallow the last integer in the previous sequence to be the same as the first in the new sequence, so individual integers never repeat, even on a new shuffle.

This module provides a quick and simple shuffle function. For more advanced shuffle functions, and for sharing the sequence among other modules, you can set up a sequence or array module to read a shuffled count. To do this, use the array or sequencer module Properties pop up to create a a count, the click on the Scatter button to randomize the values.

Output:

Out: Random integer from 0 to Range.

Input:

Strb: Strobe (NZ after 0) produces new random value.

Chng: Any change produces new random value.

Range: Upper limit of random integer range 0-n.

Patrn: 0 = repeat pattern, 1=reverse repeat, 2=shuffle at end of pattern.


Probability

Produces a probability distribution, according to the slider settings in the Property dialog, available by clicking on the blue-label property button on the upper right of the module.

For each step the module will output an index value according to the probability table set by the sliders in the Property dialog. Slider values set to 0 have zero probability and are ignored, all other values have a probability that is the normalized ratio of all non zero values. As you change the slider positions the probability in percent is displayed on the labels just under the sliders.

An important concept in using the Probability module, is that the values it returns are indexes of the sliders number, not the slider values you set. This means, for example, if the table is set to all zeros except for index 7 which is set to 3, the output will always be 7, which is the index of the only value in the table that is not zero. If you also set index 20 to 6, then 33% (1/3) of the time the output will be 7 (the index set to 3) and 67% (2/3) of the time the output will be 20 (the index set to 6). The math: 6+3=9; 3/9 is 1/3; 6/9 is 2/3.

You can use this module in many different ways. For example, you can make it produce specific pitch (or whatever) values in probability ratios you specify by setting the indexes to the relative probability you want, and then using the output directly. For example, produce a root, 3rd, 5th, and octave by setting index 0 (root), 4 (3rd), 7 (5th), and 12 (octave) to whatever values you like. All other values in the table should be 0. The module will produce the index values of 0, 4, 7, and 12 according to the relative "weights" of these indexes in the table.

You can also map, or translate, the indexes produced by the Probability module to more meaningful values by connecting the output of the Probability module to the input of a PitchMap module and adjusting the corresponding PitchMap values to whatever you want as the "real" output. This works equally well with Sequencer or Array modules for non pitch values.

The Probability module uses an internal table of 128 elements (sliders), with a range of 0-100.  You can dynamically update that table by copying an ArtWonk array to the module.  To do this, give the Ary# input the array handle, and send a strobe to the aStrb input.  Your array values should be in the 0-100 range used by the Probability module.  Array values lower than 0 will be set to 0, higher than 100 set to 100.  Arrays can be any length.  If importing it will use as many elements as available up to 128.  If exporting it will resize the array to 128 elements.

This module has a user settable number of outputs, with a separate probability run for each output. To change the number of outputs, use the Up/Down control labeled #Outs.

You also have the option, by checking the box at the bottom of the property dialog, of setting the module to produce a new value on Change instead of Strobe.

Output:

Out N: Index (slider number) of probability hit.

Input:

Strb (Chng): Strobe (change) produces new probability output.

aStrb: Strobe to copy Ary# to internal array, -1 to copy internal to Ary#

Ary#: Optional Ary# (128-element, values of 0-100) to replace internal array


Corruption

Produces a controlled degradation of the original Value parameter input stream calculated by adding to, or substituting with, an offset (Ofst) according to the (Prob) probability input.

The idea for the module comes from an article on using information theory in algorithmic music originally published in the Leonardo Music Journal by algorithmic composer Laurie Spiegel, titled: An Information Theory Based Compositional Model.

This module has a user settable number of outputs. To change the number of outputs, click on the blue-label property button on the upper right of the module, and click on the "More" or "Fewer" button on the Outputs tab. You have the option to set custom input labels and tool tips if you like.

You also have the option, by checking the box at the bottom of the property dialog, of setting the module to produce a new value on Change instead of Strobe.

Output:

Out N: Corrupted version of Value input.

Input:

Strb (Chng): Strobe (change) produces new corruption output.

Value: Input stream to be corrupted.

Prob: Probability (0 - 100) that input will be corrupted. Use a probability value of 0 (never) to 100 (always), to select the likelihood that the original input will be changed. The source for this value might be a simple sequence parallel to the input sequence, or perhaps some calculation based on the input such as inverse MIDI Velocity to degrade the quieter values more than the louder ones.

Ofst: Value added or substituted on corruption hit. Offset values would be chosen according to the intended use of the output. For example, if the output was to be used for pitch, the values might be set up as intervals going from harmonic to dissonant; if the output was program change, the values could be moving increasingly away from the original instrument's tonal color.

Subst: NZ to substitute Ofst for Value, 0 to add to Value.


Feedback

Additive feedback from input+output to output.

Output:

Out: Feedback count.

Inputs:

Incr: Amount to add to output.

Wrap: 0 = stop when limits reached; >0 = wrap around; <0 = oscillate.

High: High Limit.

Low: Low Limit.

Start: Start value, sent to output on Reset.

Reset: NZ = reset to Start value.

Chng: A changing positive value or static negative value to process next step. If a negative value is given, processing occurs at maximum loop speed.


SampRpt

Sample and repeat; values from input stream are repeated with offset(s).  Passes input directly to output except on Strb input, where the previous input is repeated for the number of times set by the Rpt input. The Ofst input is added to the original value; if an Ary# is given in Ofst the array sequence is added to the original value.

Output:

Out: Sampled/repeated value.

Inputs:

Strb: Strobe to repeat sample. If Ofst is set to an Ary#, the sequence is reset to 0 on each new Strb input

Rpts: Number of repeats.

InVal: Value to sample.

Ofst: Offset added to repeated sample value; if => 100 uses Ary# for multiple offsets. Arrays from widget modules NumGrid and ASliders work well here.


Evolve

Genetic Algorithm with dynamic goal setting. Uses sequences in standard ArtWonk arrays. as the "chromosomes." Since ArtWonk itself is cyclical, this GA implementation uses a floating Goal value that can be from 0 (reverse goal) to the array max value (full goal). By setting the goal somewhere between these two extremes, Evolve can be made to balance and produce evolving variations on a theme rather than just max out and go static, as GA is inclined to do.

Evolve uses 4 arrays, which will be set to the same size if they are not already. These arrays are given in the inputs Pg1# to Pg4# (Progeny 1-4), and after the generation is processed the same array numbers are sent to the outputs PgA# to PgD# in grade order according to the Rule that was selected to run on them. The top two, PgA# and PgB# become the parents for the next generation, the other two simply die out.

For each of the 4 arrays, the algorithm proceeds down the two parent arrays in chunk sizes given by the Chunk input, one at a time if Chunk is 1; 4 at a time if Chunk is set to 4; and so on. For each chunk, a random number is thrown, and there is a 50:50 chance that the progeny array will inherit from either parent. This is done on each chunk up to the last chunk that fits in the array. If any elements are in the last partial chunk overflow, they are left.

After the new progeny chromosome (array) is created, it is treated on an element by element basis for mutations. For each element in each array, a random number is thrown and if the number is within the range given at the mFreq (mutation frequency) input the element is either replaced by or offset by a random number between 0 and the value given mValue input. Whether this replaces the original element value or is added or subtracted from it, is set by the mSub (substitute) input. Whether the value is added or subtracted is randomly (50:50) selected.

After the 4 arrays are processed, one of the 15 rules is selected to "grade" each of the progeny. They (their array number) is then posted in the output in grade order, A-D. The A and B students go on to become parents to the next generation.

There are also options to quantize according to harmonic table, or note values, or an arbitrary table of values. You can quantize just the mutations, or the whole array after processing.

To pick the sorting Rule, the post process quantizing, initial settings and much more, use the properties pop up, accessible from the upper right of the module.

Although pitch is an obvious subject for GA treatment, the Evolve module has been designed to work with arbitrary values. Color, brightness, note values, program change and other MIDI control values, you name it. In particular, the Test Values and the rules that use them, in the properties pop up, are for non specific, generalized use.

Note that ArtWonk array operations always check the Ary#, so using the shifting array number outputs of the Evolve module works. Also, while each of the 4 arrays would normally be used for one specific thing, not packed as most GA algorithms do, you can and should use multiple Evolve modules, one for each characteristic you are interested in. For example, one for pitch, another for note values, a third for volume, etc. While the 4 arrays within an Evolve module will always be set to the same size (given by the Size input), when using multiple Evolve modules you need not set them all to the same size.

Dr. Warren Burt, Dr. Igor Karaca, and Prof. Jamy Sheridan assisted in the design of this module.

Rules (0-9 seek selected Goal value, 10-15 ignore it:

0 Harmonic Table Values
1 Harmonic Table Intervals
2 Element >= Value input
3 Within selected test values
4 Matching selected test values
5 Matching Value input Ary# values
6 Most similar to parent 1
7 Most similar to parent 2
8 Most value changes
9 Least value changes
10 Highest single interval
11 Lowest single interval
12 Higest average interval
13 Lowest average interval
14 Greatest upward motion
15 Greatest downward motion

Outputs:

Max: Max address for chromosomes (size -1).

PgA# - PgD# : Array# of progeny for current gen, highest score first; first two become parents for the next generation. These are the same Ary#s given in the Pg1# - Pg4# inputs below, but sorted according to the selected Rule.

Inputs:

Strb: Strobe to create next generation.

Chunk: Chunk size to inherit (1 = single elements, 2=double elements, etc.).

mValu: Mutation value range (0=no mutations)

mFreq: Mutation frequency in percent (<1% OK, 0=no mutations)

mSub: NZ to substitute mutation for element, 0 to add to element.

MaxV: Maximum value allowed (minimum value is always 0).

Rule: Evolution rule to apply (see properties pop up).

Goal: Floating Goal value for some rules. 0 for minimum, or anti-goal; array max (Max output) for maximum goal seaking. The idea is that a rule is run on each element of the array, so you get a score of hits that can be from 0 to the max elements in the array. The score is then subtracted from the goal to give a value that indicates how close to the Goal value it is, with 0 being exactly on. This (the absolute of the difference) is then reversed so that more is better. This makes it go toward the middle instead of maxing (or bottoming) out, and for best results this value should be changed dynamically, like waving a saussage before a dog.

Valu: Harmonic Table for rule #0 & #1; match value for rule #3; Ary# for rule #5.

Harm: Harmonic table to apply to progeny after processing.

Init: Initialize to 1st generation; sets arrays to given size, populates according to Init Rules in property pop up.

Ini#: Array number for initialization values. This array does not need to be the same size as the progeny arrays. It will cycle if smaller; if larger it will continue through each array, cycling if and when it reaches its end.

Size: Size of progny chromosome arrays. This may be changed without initialization. If changed the existing arrays will be resized, preserving their contents.

Pg1# - Pg4# : Array numbers for progeny chromosomes. These will all be set to the same size (Size input), and after processing will appear at the 4 PgA-D outputs sorted according to how well they met the selected Rule and Goal.


FuncGen

Generate points for Sine, 2x Cosine, Triangle, Sawtooth waveforms. Emulates a LFO (Low Frequency Oscillator).

Outputs:

Out X: Step Output.

Out Y: Value Output.

Inputs:

Chng: Any change to process next step.

Func: 0=Sine, 1=2Cos, 2=Tri, 3=Ramp, 4=Saw.

MaxX: Maximum X for full cycle.

MaxY: Maximum Y for full range.

Invrt: NZ=Invert Y Output.

Rot90: NZ=Rotate 90 degrees (swaps X and Y outputs).

Int: NZ = Force outputs to integers.

Reset: NZ = Reset to start of cycle & hold.


Lissajous

Generate Lissajous X,Y oscilloscope patterns.

Output:

Out X: Lissajous X Output.

Out Y: Lissajous Y Output.

Step: Value Output.

Input:

Chng: Any change to process next step.

MaxX: Maximum X range.

MaxY: Maximum Y range.

LisX: Lissajous fold value X.

LisY: Lissajous fold value Y.

AScl: Angle Scale.

RScl: Radius Scale.

Steps: Steps for a complete Lissajous cycle.

Int: NZ = Force outputs to integers.

Reset: NZ = Reset to start of cycle & hold.


Spiro

Generate Spirograph points. Use with Line or LineTo modules to create Spirograph imags; outputs can be used for interesting and largely unexplored sound patterns.

This greatly expanded set of Spirograph algorithms goes far beyond the typical 2-circle Spirograph plot. It was contributed by William Flis, who wrote the original "Spiro" program in Fortran over 25 years ago as a test for flat bed plotters.

Outputs:

X1: Spiro X1 plot value.

Y1: Spiro Y1 plot value.

X2: Spiro X2 plot value. Note that for most plots X2, Y2 is simply the previous step X1, Y1. Thus, you have the option of using LineTo graphics to create the plots, ignoring X2, Y2. Only Shape #9 and #30 use different values, and will not draw properly with LineTo.

Y2: SpiroY2 plot value.

Step: Current Spiro step address.

Steps: Number of steps for a complete Spiro cycle.

End: NZ (1) at end of cycle (connect to Reset for continuous run).

Inputs:

Chng: Any change to process next step.

Width: Image width, X range.

Height: Image height, Y range.

Shape: Spiro shape type algorithm (0-33).

Sym: Spiro symmetry type (0-7). Selects number of loops, lobes, etc. in the generating curve.

Pass: Passes per set type (0-7). Selects number of lines to be drawn in one circuit of the generating curve.

Dens: Density Scale (0-3). Selects the number of passes or circuits to complete the figure.

Int: NZ = Force outputs to integers.

Reset: NZ = Reset to start of cycle & hold.

ArtWonk is Copyright 2003-2014 by John Dunn and Algorithmic Arts. All Rights Reserved