Table of Contents

Struct Note

Namespace
SunSharp
Assembly
SunSharp.dll

Represents a musical note or command in the SunVox pattern format. This structure encapsulates both standard musical notes (C0-F#10) and special commands like note off, stop, play, etc.

public readonly struct Note

Remarks

The note value is stored as a single byte where:

  • 0 = Nothing/Silence
  • 1-127 = Musical notes (C0 = 1, C#0 = 2, ..., F#10 = 127)
  • 128+ = Special commands (note off, stop, play, etc.)

Constructors

Note(NoteName, int)

Initializes a new instance of the Note struct with the specified note name and octave. Valid range is C0 to F#10 inclusive.

public Note(NoteName name, int octave)

Parameters

name NoteName
octave int

Exceptions

ArgumentException

Thrown when name is not a valid note name.

ArgumentOutOfRangeException

Thrown when the note and octave combination is out of the supported range (C0 to F#10).

Note(byte)

Initializes a new instance of the Note struct with the specified raw byte value.

public Note(byte value)

Parameters

value byte

Fields

Value

The raw byte value of the note.

public readonly byte Value

Field Value

byte

Properties

AllNotesOff

Sends "note off" to all modules.

public static Note AllNotesOff { get; }

Property Value

Note

CleanModule

Stops the module, clears its internal buffers and puts it into standby mode.

public static Note CleanModule { get; }

Property Value

Note

CleanSynths

Stops all modules, clears their internal buffers and puts them into standby mode.

public static Note CleanSynths { get; }

Property Value

Note

IsAllNotesOff

public bool IsAllNotesOff { get; }

Property Value

bool

IsCleanModule

public bool IsCleanModule { get; }

Property Value

bool

IsCleanSynths

public bool IsCleanSynths { get; }

Property Value

bool

IsDisplayable

Whether the note value can be displayed in SunVox's pattern editor. Does not include commands that don't have a visual representation.

public bool IsDisplayable { get; }

Property Value

bool

IsMusicalNote

Gets a value indicating whether this is a normal musical note (C0-F#10).

public bool IsMusicalNote { get; }

Property Value

bool

IsNoteOff

public bool IsNoteOff { get; }

Property Value

bool

IsNothing

public bool IsNothing { get; }

Property Value

bool

IsPlay

public bool IsPlay { get; }

Property Value

bool

IsSetPitch

public bool IsSetPitch { get; }

Property Value

bool

IsStop

public bool IsStop { get; }

Property Value

bool

IsValid

Gets a value indicating whether the value is considered a valid note or command in SunVox.

public bool IsValid { get; }

Property Value

bool

Name

Get the name of the note. Returns valid values for notes in range C0 to F#10 inclusive. Returns Other otherwise.

public NoteName Name { get; }

Property Value

NoteName

Nothing

Does nothing.

public static Note Nothing { get; }

Property Value

Note

Octave

Gets the octave number of the musical note, if applicable.

public int Octave { get; }

Property Value

int

Remarks

Returns -1 if the value does not represent a musical note.

Off

Stops the note playing on its track.

public static Note Off { get; }

Property Value

Note

Play

Starts playing the project.

public static Note Play { get; }

Property Value

Note

PreviousTrack

Used to apply effects to the previous track.

public static Note PreviousTrack { get; }

Property Value

Note

SetPitch

Sets the pitch specified in column XXYY, where 0x0000 - highest possible pitch, 0x7800 -lowest pitch (note C0); one semitone = 0x100.

public static Note SetPitch { get; }

Property Value

Note

Remarks

Consider using the Microtones helper class for pitch conversions.

Stop

Stops playing the project.

public static Note Stop { get; }

Property Value

Note

Methods

A(int)

Creates an A note at the specified octave.

public static Note A(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Ab(int)

Creates an A♭ note at the specified octave. Enharmonic equivalent of G#.

public static Note Ab(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

As(int)

Creates an A# note at the specified octave.

public static Note As(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

B(int)

Creates a B note at the specified octave.

public static Note B(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Bb(int)

Creates a B♭ note at the specified octave. Enharmonic equivalent of A#.

public static Note Bb(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Bs(int)

Creates a B# note at the specified octave. Enharmonic equivalent of C in the next octave.

public static Note Bs(int octave)

Parameters

octave int

Returns

Note

Remarks

Since B♯ is a semitone above B, it actually belongs to the next octave. For example, B♯3 = C4, B♯4 = C5, etc.

Exceptions

ArgumentOutOfRangeException

C(int)

Creates a C note at the specified octave.

public static Note C(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Cb(int)

Creates a C♭ note at the specified octave. Enharmonic equivalent of B in the previous octave.

public static Note Cb(int octave)

Parameters

octave int

Returns

Note

Remarks

Since C♭ is a semitone below C, it actually belongs to the previous octave. For example, C♭4 = B3, C♭5 = B4, etc.

Exceptions

ArgumentOutOfRangeException

Cs(int)

Creates a C# note at the specified octave.

public static Note Cs(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

D(int)

Creates a D note at the specified octave.

public static Note D(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Db(int)

Creates a D♭ note at the specified octave. Enharmonic equivalent of C#.

public static Note Db(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Ds(int)

Creates a D# note at the specified octave.

public static Note Ds(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

E(int)

Creates an E note at the specified octave.

public static Note E(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Eb(int)

Creates an E♭ note at the specified octave. Enharmonic equivalent of D#.

public static Note Eb(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Equals(Note)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Note other)

Parameters

other Note

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Es(int)

Creates an E# note at the specified octave. Enharmonic equivalent of F.

public static Note Es(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

F(int)

Creates an F note at the specified octave.

public static Note F(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Fb(int)

Creates an F♭ note at the specified octave. Enharmonic equivalent of E.

public static Note Fb(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Fs(int)

Creates an F# note at the specified octave.

public static Note Fs(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

G(int)

Creates a G note at the specified octave.

public static Note G(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

Gb(int)

Creates a G♭ note at the specified octave. Enharmonic equivalent of F#.

public static Note Gb(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Gs(int)

Creates a G# note at the specified octave.

public static Note Gs(int octave)

Parameters

octave int

Returns

Note

Exceptions

ArgumentOutOfRangeException

ToString()

Returns a two-character string representation of the note.

public override string ToString()

Returns

string

A two-character string representing the note:

Remarks

The ToString() returns a two-character string representing the note or command, even if SunVox does not display it in the pattern editor.

Operators

operator ==(Note, Note)

public static bool operator ==(Note left, Note right)

Parameters

left Note
right Note

Returns

bool

implicit operator byte(Note)

public static implicit operator byte(Note note)

Parameters

note Note

Returns

byte

implicit operator Note(byte)

public static implicit operator Note(byte value)

Parameters

value byte

Returns

Note

operator !=(Note, Note)

public static bool operator !=(Note left, Note right)

Parameters

left Note
right Note

Returns

bool

See Also