Struct Voicing
- Namespace
- Celeritas.Core.VoiceLeading
- Assembly
- Celeritas.dll
A specific voicing of a chord (4 pitches, one per voice). Stored as a packed 32-bit integer for efficient comparison.
public readonly struct Voicing : IEquatable<Voicing>
- Implements
- Inherited Members
Constructors
Voicing(int, int, int, int)
A specific voicing of a chord (4 pitches, one per voice). Stored as a packed 32-bit integer for efficient comparison.
public Voicing(int bass, int tenor, int alto, int soprano)
Parameters
bassintBass voice MIDI pitch, in [0, 127].
tenorintTenor voice MIDI pitch, in [0, 127].
altointAlto voice MIDI pitch, in [0, 127].
sopranointSoprano voice MIDI pitch, in [0, 127].
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
Properties
Alto
Alto voice MIDI pitch.
public int Alto { get; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
Bass
Bass voice MIDI pitch.
public int Bass { get; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
this[VoicePart]
Gets the MIDI pitch of the given voice part.
public int this[VoicePart voice] { get; }
Parameters
voiceVoicePartThe voice part to read.
Property Value
- int
The MIDI pitch for
voice, or 0 for an undefined value.
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
Soprano
Soprano voice MIDI pitch.
public int Soprano { get; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
Tenor
Tenor voice MIDI pitch.
public int Tenor { get; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
Methods
Equals(Voicing)
Determines whether this voicing has the same four pitches as other.
public bool Equals(Voicing other)
Parameters
otherVoicing
Returns
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
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.
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
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.
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
ToPitches()
Returns the four voice pitches in bass-to-soprano order.
public int[] ToPitches()
Returns
- int[]
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
ToString()
Returns the voicing as bracketed note names, bass to soprano.
public override string ToString()
Returns
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
Operators
operator ==(Voicing, Voicing)
Determines whether two voicings have identical pitches.
public static bool operator ==(Voicing a, Voicing b)
Parameters
Returns
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].
operator !=(Voicing, Voicing)
Determines whether two voicings differ in any pitch.
public static bool operator !=(Voicing a, Voicing b)
Parameters
Returns
Exceptions
- ArgumentOutOfRangeException
Any voice is outside the MIDI range [0, 127].