Table of Contents

Class Scale

Namespace
Sigil.Sound
Assembly
Sigil.Sound.Notes.dll

A scale: a root note and the steps above it. Degrees count up the scale from 0 and run past the octave, so degree 7 of a seven-note scale is the root again an octave up, and negative degrees go below the root.

public sealed class Scale

Inheritance

Inherited Members

Examples

// A melody by scale degree. 48 is C3; degree 0 is 48, degree 2 is 51 and degree 7 is the octave, 60.
var scale = Scale.Minor(48);
scale.Notes(Mini.Integers("0 2 <4 7> ~"))
    .Play(v => Saw(v.Frequency).LowPass(2000).Adsr(0.005, 0.1, 0.5, 0.2), bpm: 110) * 0.3

Constructors

Scale(int, IEnumerable<int>, string)

A scale from a root pitch and the semitone steps above it, which must rise from 0 and stay within one octave.

public Scale(int root, IEnumerable<int> steps, string name = "custom")

Parameters

root int

The MIDI pitch of degree 0.

steps IEnumerable<int>

Semitones above the root for each degree: 0 first, strictly rising, all below 12.

name string

A label.

Properties

Count

How many degrees one octave holds.

public int Count { get; }

Property Value

int

Name

The scale's name, such as "minor".

public string Name { get; }

Property Value

string

Root

The MIDI pitch of degree 0.

public int Root { get; }

Property Value

int

this[int]

The MIDI pitch of a degree. Degrees past the end climb an octave per Sigil.Sound.Scale.Count; negative ones go down.

public int this[int degree] { get; }

Property Value

int

Methods

Blues(int)

The blues scale: minor pentatonic with a flat fifth.

public static Scale Blues(int root)

Parameters

root int

Returns

Scale

Chromatic(int)

Every semitone.

public static Scale Chromatic(int root)

Parameters

root int

Returns

Scale

Contains(int)

True when pitch is a tone of the scale in some octave. It reads a precomputed set and allocates nothing, so it is fit to ask of every note as it plays.

public bool Contains(int pitch)

Parameters

pitch int

A MIDI pitch.

Returns

bool

Examples

// Only the notes of C major: C# and D# are not tones of it and are left out.
Mini.Notes("c3 c#3 d3 d#3 e3 f3 g3 a3")
    .Where(n => Scale.Major(48).Contains(n.Pitch))
    .Play(v => Triangle(v.Frequency).Adsr(0.005, 0.1, 0.4, 0.15), bpm: 140) * 0.3

Degrees(params int[])

The notes on the given degrees, in order: Scale.Minor(C3).Degrees(0, 2, 4, 7).

public IReadOnlyList<Note> Degrees(params int[] degrees)

Parameters

degrees int[]

Returns

IReadOnlyList<Note>

Degrees(string)

The notes on the degrees written as whole numbers in Sigil.Sound.Mini notation: Scale.Parse("c3 minor").Degrees("0 2 4 7").

public IReadOnlyList<Note> Degrees(string degrees)

Parameters

degrees string

Returns

IReadOnlyList<Note>

Exceptions

MiniNotationException

The text is not valid.

Dorian(int)

Dorian: minor with a raised sixth.

public static Scale Dorian(int root)

Parameters

root int

Returns

Scale

HarmonicMinor(int)

Harmonic minor: natural minor with a raised seventh.

public static Scale HarmonicMinor(int root)

Parameters

root int

Returns

Scale

Locrian(int)

Locrian: minor with lowered second and fifth.

public static Scale Locrian(int root)

Parameters

root int

Returns

Scale

Lydian(int)

Lydian: major with a raised fourth.

public static Scale Lydian(int root)

Parameters

root int

Returns

Scale

Major(int)

Major (Ionian): 0 2 4 5 7 9 11.

public static Scale Major(int root)

Parameters

root int

Returns

Scale

MajorPentatonic(int)

Major pentatonic: 0 2 4 7 9.

public static Scale MajorPentatonic(int root)

Parameters

root int

Returns

Scale

MelodicMinor(int)

Melodic minor (ascending): minor with raised sixth and seventh.

public static Scale MelodicMinor(int root)

Parameters

root int

Returns

Scale

Minor(int)

Natural minor (Aeolian): 0 2 3 5 7 8 10.

public static Scale Minor(int root)

Parameters

root int

Returns

Scale

MinorPentatonic(int)

Minor pentatonic: 0 3 5 7 10.

public static Scale MinorPentatonic(int root)

Parameters

root int

Returns

Scale

Mixolydian(int)

Mixolydian: major with a lowered seventh.

public static Scale Mixolydian(int root)

Parameters

root int

Returns

Scale

Note(int, float)

The note on a degree.

public Note Note(int degree, float velocity = 0.8)

Parameters

degree int
velocity float

Returns

Note

Notes(string)

Turns degrees written in Sigil.Sound.Mini notation into a pattern of notes, so the scale and the melody are both text: Scale.Parse("c3 minor").Notes("0 2 <4 7> ~").

public Pattern<Note> Notes(string degrees)

Parameters

degrees string

Returns

Pattern<Note>

Exceptions

MiniNotationException

The text is not valid.

Notes(Pattern<int>)

Turns a pattern of degrees into a pattern of notes.

public Pattern<Note> Notes(Pattern<int> degrees)

Parameters

degrees Pattern<int>

Returns

Pattern<Note>

Parse(string)

A scale by name: "c3 minor", "F#2 dorian" or "c3:minor". A root without an octave is in octave 3. Names are case-insensitive; spaces, dashes and underscores inside a name are ignored ("minor pentatonic" works).

public static Scale Parse(string text)

Parameters

text string

Returns

Scale

Exceptions

FormatException

The text is not a root and a known scale.

Phrygian(int)

Phrygian: minor with a lowered second.

public static Scale Phrygian(int root)

Parameters

root int

Returns

Scale

ToString()

The scale as text, such as C major.

public override string ToString()

Returns

string

WholeTone(int)

Whole tone: six notes a whole step apart.

public static Scale WholeTone(int root)

Parameters

root int

Returns

Scale

WithRoot(int)

This scale started on another root.

public Scale WithRoot(int root)

Parameters

root int

Returns

Scale