Class PatternExtensions
- Namespace
- Sigil.Sound
- Assembly
- Sigil.Sound.Notes.dll
Reshaping patterns. Every method returns a new pattern and leaves the original alone.
public static class PatternExtensionsInheritance
Inherited Members
Methods
Degrade<T>(Pattern<T>, double, int)
Drops events at random, the same ones every time you ask (the choice comes from where the event sits in time and
seed, not from a clock), so a loop is stable and a hot swap or offline render matches live playback.
public static Pattern<T> Degrade<T>(this Pattern<T> pattern, double amount = 0.5, int seed = 0)Parameters
patternPattern<T>-
The pattern to thin out.
amountdouble-
The share to drop, from 0 (none) to 1 (all). Defaults to half.
seedint-
Different seeds drop different events.
Returns
- Pattern<T>
Type Parameters
T
Euclid<T>(Pattern<T>, int, int, int)
Spreads pulses hits as evenly as possible over steps steps (a Euclidean rhythm): (3,8) is x..x..x.
The rhythm decides when things happen and each hit takes whatever the pattern is playing at that moment, so
"[a b]" with (3,8) gives a, a, b, as in Strudel.
public static Pattern<T> Euclid<T>(this Pattern<T> pattern, int pulses, int steps, int rotation = 0)Parameters
patternPattern<T>-
Where the values come from; sampled at the start of each hit.
pulsesint-
How many steps sound, from 0 to
steps. stepsint-
How many steps the cycle is divided into.
rotationint-
Steps to rotate the rhythm left.
Returns
- Pattern<T>
Type Parameters
T
Every<T>(Pattern<T>, int, Func<Pattern<T>, Pattern<T>>)
Applies transform to the pattern on every cyclesth cycle (0, n, 2n, ...) and leaves the rest alone.
public static Pattern<T> Every<T>(this Pattern<T> pattern, int cycles, Func<Pattern<T>, Pattern<T>> transform)Parameters
Returns
- Pattern<T>
Type Parameters
T
Examples
// Every fourth cycle the pattern runs twice as fast and backwards.
Mini.Notes("c3 e3 g3 b3").Every(4, p => p.Fast(2).Rev())
.Play(v => Saw(v.Frequency).LowPass(2000).Adsr(0.005, 0.1, 0.4, 0.2), bpm: 120) * 0.3
Fast<T>(Pattern<T>, Fraction)
Plays the pattern factor times as fast: Fast(2) fits two of its cycles into one.
public static Pattern<T> Fast<T>(this Pattern<T> pattern, Fraction factor)Parameters
Returns
- Pattern<T>
Type Parameters
T
Exceptions
- ArgumentOutOfRangeException
-
The factor is not positive.
Fast<T>(Pattern<T>, int)
Plays the pattern factor times as fast: Fast(2) fits two of its cycles into one.
public static Pattern<T> Fast<T>(this Pattern<T> pattern, int factor)Parameters
Returns
- Pattern<T>
Type Parameters
T
Exceptions
- ArgumentOutOfRangeException
-
The factor is not positive.
Fast<T>(Pattern<T>, double)
Plays the pattern factor times as fast: Fast(2) fits two of its cycles into one.
public static Pattern<T> Fast<T>(this Pattern<T> pattern, double factor)Parameters
Returns
- Pattern<T>
Type Parameters
T
Exceptions
- ArgumentOutOfRangeException
-
The factor is not positive.
Rev<T>(Pattern<T>)
Plays each cycle backwards.
public static Pattern<T> Rev<T>(this Pattern<T> pattern)Parameters
patternPattern<T>
Returns
- Pattern<T>
Type Parameters
T
Select<T, TResult>(Pattern<T>, Func<T, TResult>)
Changes every value.
public static Pattern<TResult> Select<T, TResult>(this Pattern<T> pattern, Func<T, TResult> map)Parameters
Returns
- Pattern<TResult>
Type Parameters
TTResult
SelectMany<T, TResult>(Pattern<T>, Func<T, IReadOnlyList<TResult>>)
Turns each event into several at the same time, one per item the function returns (a chord into its notes).
public static Pattern<TResult> SelectMany<T, TResult>(this Pattern<T> pattern, Func<T, IReadOnlyList<TResult>> expand)Parameters
patternPattern<T>expandFunc<T, IReadOnlyList<TResult>>
Returns
- Pattern<TResult>
Type Parameters
TTResult
Shift<T>(Pattern<T>, Fraction)
Moves the whole pattern later by cycles (earlier if negative).
public static Pattern<T> Shift<T>(this Pattern<T> pattern, Fraction cycles)Parameters
Returns
- Pattern<T>
Type Parameters
T
Shift<T>(Pattern<T>, double)
Moves the whole pattern later by cycles (earlier if negative).
public static Pattern<T> Shift<T>(this Pattern<T> pattern, double cycles)Parameters
Returns
- Pattern<T>
Type Parameters
T
Slow<T>(Pattern<T>, Fraction)
Plays the pattern factor times as slow: Slow(2) stretches one cycle over two.
public static Pattern<T> Slow<T>(this Pattern<T> pattern, Fraction factor)Parameters
Returns
- Pattern<T>
Type Parameters
T
Slow<T>(Pattern<T>, int)
Plays the pattern factor times as slow: Slow(2) stretches one cycle over two.
public static Pattern<T> Slow<T>(this Pattern<T> pattern, int factor)Parameters
Returns
- Pattern<T>
Type Parameters
T
Slow<T>(Pattern<T>, double)
Plays the pattern factor times as slow: Slow(2) stretches one cycle over two.
public static Pattern<T> Slow<T>(this Pattern<T> pattern, double factor)Parameters
Returns
- Pattern<T>
Type Parameters
T
Sometimes<T>(Pattern<T>, double, Func<Pattern<T>, Pattern<T>>, int)
Applies transform to a random amount of the events and leaves the others as they are.
public static Pattern<T> Sometimes<T>(this Pattern<T> pattern, double amount, Func<Pattern<T>, Pattern<T>> transform, int seed = 0)Parameters
Returns
- Pattern<T>
Type Parameters
T
Where<T>(Pattern<T>, Func<T, bool>)
Keeps only the events whose value passes keep.
public static Pattern<T> Where<T>(this Pattern<T> pattern, Func<T, bool> keep)Parameters
Returns
- Pattern<T>
Type Parameters
T