PwarpDur:
Filter:
Classes (extension) | Streams-Patterns-Events > Patterns > Time

PwarpDur
ExtensionExtension

Warps a series of durations, preserving the total expected duration
Location: NOT INSTALLED!

Description

"It's just a jump to the left..."

PwarpDur takes a stream of linear durations as input, and warps the timeline so that constant input durations accelerate or decelerate at the output.

Input durations are given as the pattern. cycleDur is the total duration of the time period to be warped. Within that duration, a midpoint is specified as a normalized 0.0 to 1.0 value (where 0.5 is the middle of the cycle duration).

Then a piecewise function is applied to the running sum of the durations (t is the discrete integral of the incoming durations):

0 <= t < midpoint
t.lincurve(0, midpoint, 0, midpoint, curve.neg)
midpoint <= t <= 1
t.lincurve(midpoint, 1, midpoint, 1, curve)

A positive curve will produce first acceleration, followed by deceleration past the midpoint. A negative curve produces the opposite. Midpoint == 0 or 1 suppresses one or the other branch and produces only acceleration or deceleration (as in Bucephalus bouncing ball).

See Visualizing the time warp for a more intuitive visual understanding of the interaction between the curve and midpoint parameters.

Class Methods

.new

Create a new PwarpDur instance.

Arguments:

pattern

A pattern returning single numbers. These are the incoming, unwarped time durations.

cycleDur

A number, function or stream, giving the total cycle length (in beats) for this repeat. (This is polled once per repeat.)

curve

A number, function or stream, giving the curve value for this repeat. (This is polled once per repeat.)

midpoint

A number, function or stream, giving the curve value for this repeat. (This is polled once per repeat.)

repeats

A number, function or stream, specifying how many cycles to perform. (This is polled once, when PwarpDur takes control.)

clip

A boolean, function or stream. (This is polled once per repeat.) If true on this repeat, the final duration will be clipped so that the total input and output durations == cycleDur. If false, the input and output durations may exceed cycleDur. (Note: Because of the exponential nature of the mapping function, if the final part of the cycle decelerates, an unclipped final duration might map onto a much longer duration than you expect. Be careful.)

tolerance

A number, function or stream, for "fuzzy equals" at the end of the cycle. (This is polled once per repeat.) That is, if an output value would put the next time point within tolerance of cycleDur, then it will round up to cycleDur and end this cycle.

Returns:

A PwarpDur instance.

Inherited class methods

Instance Methods

Inherited instance methods

Examples

Curve

Try different curve values. If curve is closer to 0, the warp is very mild. 1.5 to 2.0 is probably as high as you want to go most of the time. Empirically, 3.0 usually sounds too extreme to my ear.

Midpoint

Flowing arpeggiators

Note that, in this example and the next, PwarpDur works within a normalized 0.0-1.0 cycle, which is then scaled up according to 'dur' (expressing directly the idea of "18 to 30 notes within the specified duration").

Bucephalus bouncing ball

An obligatory attempt, whenever acceleration is involved.

Visualizing the time warp

This code block lets you see the effect of the curve and midpoint parameters. Equally spaced sixteenth notes are shown on the Y axis, and mapped via a sigmoid transfer function onto the warped durations. Read the resulting rhythm on the X axis (left to right).

The "Play" button will repeat a C major scale using the warped timing. Note that, to prevent negative durations, the playback warp will update only once per bar; changes to the sliders during playback will not be audible until the next bar.