Class Patterns
- Namespace
- Sigil.Sound
- Assembly
- Sigil.Sound.Notes.dll
Placing notes in time and playing them: notes.Every(Beats.Eighth).Loop().Play(v => ...).
public static class PatternsInheritance
Inherited Members
Methods
Every(IEnumerable<Note>, double, double)
Places the notes one after another, step beats apart.
public static Pattern Every(this IEnumerable<Note> notes, double step = 1, double gate = 1)Parameters
notesIEnumerable<Note>-
The notes, in order; any LINQ filtering or transposing you did on them carries over.
stepdouble-
Beats from the start of one note to the start of the next; see Sigil.Sound.Beats. Defaults to Sigil.Sound.Beats.Quarter, one beat.
gatedouble-
How long each note is held, as a multiple of
step. 1 (the default) ends it as the next begins; above 1 the notes overlap, which is what makes an arpeggio polyphonic.
Returns
Examples
// Every places the notes in time: one per eighth, each held for 2 steps. Loop repeats them.
Notes.Parse("C4 E4 G4").Every(Beats.Eighth, gate: 2).Loop()
.Play(v => Saw(v.Frequency).LowPass(2400).Adsr(0.005, 0.1, 0.4, 0.2), bpm: 120) * 0.3
Play(Pattern, Func<Voice, Sound>, double?, int)
Turns a pattern into sound: at each note's start, a voice built from voice plays it,
and the voices are mixed. Notes that overlap play together, up to polyphony at once; past that, the oldest is cut.
public static Sound Play(this Pattern pattern, Func<Voice, Sound> voice, double? bpm = null, int polyphony = 8)Parameters
patternPattern-
The notes to play.
voiceFunc<Voice, Sound>-
Describes the sound of one note from its Sigil.Sound.Voice signals. Called while the sound is built, not per note.
bpmdouble?-
Beats (quarter notes) per minute; the pattern then keeps its own time, starting when the sound does. Leave it out to follow the host: with a Sigil.Sound.HostClock on the render context, a looping pattern stays on the host's beat grid at the host's tempo (so replacing the sound keeps the notes in time), and without one the tempo is 120.
polyphonyint-
The most notes sounding at once, from 1 to 64. Defaults to 8.
Returns
Examples
Notes.Parse("C3 E3 G3 B3").Every(Beats.Sixteenth, gate: 3).Loop()
.Play(v => Saw(v.Frequency).Adsr(0.003, 0.15, 0.4, 0.3), bpm: 110)
Remarks
Each voice is scaled by the note's velocity, and an Adsr inside it releases when the note ends.
The voices are built up front and reused for every note, so playing allocates nothing.