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
nameNoteNameoctaveint
Exceptions
- ArgumentException
Thrown when
nameis 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
valuebyte
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
CleanModule
Stops the module, clears its internal buffers and puts it into standby mode.
public static Note CleanModule { get; }
Property Value
CleanSynths
Stops all modules, clears their internal buffers and puts them into standby mode.
public static Note CleanSynths { get; }
Property Value
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
Nothing
Does nothing.
public static Note Nothing { get; }
Property Value
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
Play
Starts playing the project.
public static Note Play { get; }
Property Value
PreviousTrack
Used to apply effects to the previous track.
public static Note PreviousTrack { get; }
Property Value
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
Remarks
Consider using the Microtones helper class for pitch conversions.
Stop
Stops playing the project.
public static Note Stop { get; }
Property Value
Methods
A(int)
Creates an A note at the specified octave.
public static Note A(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
Ab(int)
Creates an A♭ note at the specified octave. Enharmonic equivalent of G#.
public static Note Ab(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
As(int)
Creates an A# note at the specified octave.
public static Note As(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
B(int)
Creates a B note at the specified octave.
public static Note B(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
Bb(int)
Creates a B♭ note at the specified octave. Enharmonic equivalent of A#.
public static Note Bb(int octave)
Parameters
octaveint
Returns
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
octaveint
Returns
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
octaveint
Returns
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
octaveint
Returns
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
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
D(int)
Creates a D note at the specified octave.
public static Note D(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
Db(int)
Creates a D♭ note at the specified octave. Enharmonic equivalent of C#.
public static Note Db(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
Ds(int)
Creates a D# note at the specified octave.
public static Note Ds(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
E(int)
Creates an E note at the specified octave.
public static Note E(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
Eb(int)
Creates an E♭ note at the specified octave. Enharmonic equivalent of D#.
public static Note Eb(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
Equals(Note)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Note other)
Parameters
otherNoteAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
F(int)
Creates an F note at the specified octave.
public static Note F(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
Fb(int)
Creates an F♭ note at the specified octave. Enharmonic equivalent of E.
public static Note Fb(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
Fs(int)
Creates an F# note at the specified octave.
public static Note Fs(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
G(int)
Creates a G note at the specified octave.
public static Note G(int octave)
Parameters
octaveint
Returns
Exceptions
- ArgumentOutOfRangeException
Gb(int)
Creates a G♭ note at the specified octave. Enharmonic equivalent of F#.
public static Note Gb(int octave)
Parameters
octaveint
Returns
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
octaveint
Returns
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:
- two empty spaces for nothing/silence
- "--" for Off
- "-!" for AllNotesOff
- "CS" for CleanSynths
- "CM" for CleanModule
- "S!" for Stop
- "P!" for Play
- "SP" for SetPitch
- Note name and octave (e.g., "C4", "d5") for musical notes
- "??" for unknown/invalid values
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
Returns
- bool
implicit operator byte(Note)
public static implicit operator byte(Note note)
Parameters
noteNote
Returns
- byte
implicit operator Note(byte)
public static implicit operator Note(byte value)
Parameters
valuebyte
Returns
operator !=(Note, Note)
public static bool operator !=(Note left, Note right)
Parameters
Returns
- bool