Plush

Note#

PlushEngine · Type index

Namespace: PlushEngine

A note to play, in the tracker notation code, the Inspector and sequences share: NOTE MOD OCTAVE [VOLUME] [FINETUNE], for example "C-4", "F#2", or "F#2U0C-D05" (six dB louder, five cents flat). NOTE is A to G, MOD is # (sharp) or - (natural), OCTAVE is 0 to 9. VOLUME is U (up) or D (down) and two hex digits in 0.5 dB steps, so U0C is +6 dB; the result is at most +24 dB. FINETUNE is -U or -D and two hex digits in cents. "OFF" releases a held note. Input is case-insensitive; ToString writes upper case. Build notes from values with From(string, int) or the named builders (Note.FSharp(2).Louder(6).Down(5)) instead of concatenating strings. Parse a fixed string once (in OnAttach) to report a mistake early.

public readonly struct Note : IEquatable<Note>

Members: A · ASharp · B · C · CSharp · Cents · Conversions · D · DSharp · Down · E · Equals · F · FSharp · From · FromKey · G · GSharp · Gain · GetHashCode · IsOff · Key · Louder · MaxKey · MaxVolumeDb · Off · Parse · PitchRatio · Quieter · Root · ToString · TryParse · Up · VolumeDb · WithCents · operator != · operator ==

A#

public static Note A(int octave);

A in an octave 0 to 9 (Note.A(4) is A-4).

ASharp#

public static Note ASharp(int octave);

A# in an octave 0 to 9 (Note.ASharp(4) is A#4).

B#

public static Note B(int octave);

B in an octave 0 to 9 (Note.B(4) is B-4).

C#

public static Note C(int octave);

C in an octave 0 to 9 (Note.C(4) is C-4).

CSharp#

public static Note CSharp(int octave);

C# in an octave 0 to 9 (Note.CSharp(4) is C#4).

Cents#

public int Cents { get; }

Fine tuning in cents (100 cents is a semitone).

Conversions#

public static implicit operator Note(string text);

Lets a note string be passed where a Note is expected (parsed, throws when malformed).

D#

public static Note D(int octave);

D in an octave 0 to 9 (Note.D(4) is D-4).

DSharp#

public static Note DSharp(int octave);

D# in an octave 0 to 9 (Note.DSharp(4) is D#4).

Down#

public Note Down(int cents);

This note tuned down by cents.

E#

public static Note E(int octave);

E in an octave 0 to 9 (Note.E(4) is E-4).

Equals#

public bool Equals(Note other);
public override bool Equals(object? obj);

F#

public static Note F(int octave);

F in an octave 0 to 9 (Note.F(4) is F-4).

FSharp#

public static Note FSharp(int octave);

F# in an octave 0 to 9 (Note.FSharp(4) is F#4).

From#

public static Note From(string name, int octave);

A note from a name ("C" to "B", optionally with #) and an octave 0 to 9.

FromKey#

public static Note FromKey(int key);

A note from its semitone count above C-0 (0 to 119).

G#

public static Note G(int octave);

G in an octave 0 to 9 (Note.G(4) is G-4).

GSharp#

public static Note GSharp(int octave);

G# in an octave 0 to 9 (Note.GSharp(4) is G#4).

Gain#

public float Gain { get; }

The note's volume change as a linear gain.

GetHashCode#

public override int GetHashCode();

IsOff#

public bool IsOff { get; }

True for OFF: release the note that is playing.

Key#

public int Key { get; }

Semitones above C-0 (C-4 is 48, B-9 is 119); -1 for Off. default(Note) is C-4.

Louder#

public Note Louder(float db);

This note, db louder (negative is quieter); the total is at most +24 dB.

MaxKey#

public const int MaxKey = 119;

The highest key, B-9 (MIDI 119).

MaxVolumeDb#

public const float MaxVolumeDb = 24;

Loudest change a note can ask for, in dB.

Off#

public static Note Off { get; }

Note-off.

Parse#

public static Note Parse(string text);

Parse a note string; throws ArgumentException naming what is wrong.

PitchRatio#

public double PitchRatio(int rootKey = 48);

Playback-rate ratio relative to a root key (default C-4): 2 an octave up, 0.5 an octave down.

Quieter#

public Note Quieter(float db);

This note, db quieter.

Root#

public static Note Root { get; }

C-4, the root note a Sound plays at its original pitch.

ToString#

public override string ToString();

The canonical string: upper case, volume in 0.5 dB steps and cents when not zero (clamped to two hex digits).

TryParse#

public static bool TryParse(ReadOnlySpan<char> text, out Note note);

Parse without throwing or allocating.

Up#

public Note Up(int cents);

This note tuned up by cents.

VolumeDb#

public float VolumeDb { get; }

Change from the sound's own level, in dB (0 when the note has no volume part).

WithCents#

public Note WithCents(int cents);

This note with its fine tuning set to cents (positive is sharper).

operator !=#

public static bool operator !=(Note a, Note b);

operator ==#

public static bool operator ==(Note a, Note b);

Source#