Class Pattern<T>
- Namespace
- Sigil.Sound
- Assembly
- Sigil.Sound.Notes.dll
Values arranged in cycle time, as a question you can ask of any stretch of time: "what happens between 3 and 4.5?".
Because it is a function and not a stored list, Fast, Rev, Every and friends compose freely and a
pattern can run forever or change from cycle to cycle. Build one with Sigil.Sound.Pat or Sigil.Sound.Mini
(Mini.Notes("c3 [e3 g3]*2 ~ <b3 d4>")), reshape it with the methods on Sigil.Sound.PatternExtensions.
public sealed class Pattern<T>Type Parameters
T-
What happens at each event: a Sigil.Sound.Note, a number to drive a parameter, anything.
Inheritance
Inherited Members
Extension Methods
Remarks
Time is in cycles, not beats or seconds: cycle 0 is [0, 1), cycle 1 is [1, 2). How long a cycle lasts is up to whatever plays
the pattern (Sigil.Sound.Pat.BeatsPerCycle beats when converted with ToPattern).
Queries fill a list you own, so asking again with the same list allocates nothing once it has grown.
Methods
Cycle(long)
The events of one cycle, in a new list. Convenient for tests and tools; real-time code should call Sigil.Sound.Pattern`1.Query(Sigil.Sound.Arc,System.Collections.Generic.List{Sigil.Sound.PatternEvent{`0}}).
public List<PatternEvent<T>> Cycle(long cycle)Parameters
cyclelong
Returns
- List<PatternEvent<T>>
Query(Arc, List<PatternEvent<T>>)
Adds the events that touch arc to output, ordered by when they start.
The list is not cleared first. An event that straddles the end of the arc comes back cut to the arc (see
Sigil.Sound.PatternEvent`1.Part); check Sigil.Sound.PatternEvent`1.HasOnset to play only those that start in it.
public void Query(Arc arc, List<PatternEvent<T>> output)Parameters
arcArcoutputList<PatternEvent<T>>
Validate(int)
Asks the pattern for its first cycles cycles and throws if that fails, so a pattern that cannot be played
(too many events a cycle, or nested too deeply) is refused when it is built and not found out while audio is running.
Sigil.Sound.Pat.MaxEvents is the limit. Playing a pattern checks it for you; this is for code that consumes one itself.
public void Validate(int cycles = 64)Parameters
cyclesint-
How many cycles to check, counting from cycle 0.
Exceptions
- InvalidOperationException
-
The pattern is too dense or too deeply nested.