Struct InstrumentRange
- Namespace
- Celeritas.Core.Orchestration
- Assembly
- Celeritas.dll
MIDI pitch range for an instrument/part.
public readonly record struct InstrumentRange : IEquatable<InstrumentRange>
- Implements
- Inherited Members
Remarks
Both bounds must be MIDI pitches, and the range must not be inverted. Unvalidated, this type
could describe a range no instrument has: (int.MaxValue, int.MaxValue) was perfectly
constructible, and wedged OrchestrationMapper in an infinite loop.
This covers construction only. default(InstrumentRange) is (0, 0) and with { }
assigns without re-checking — as they do for every C# record struct — so consumers have to stay
correct for any bounds regardless of this. OrchestrationMapper.ClampToRange does.
Constructors
InstrumentRange(int, int)
MIDI pitch range for an instrument/part.
public InstrumentRange(int MinPitch, int MaxPitch)
Parameters
MinPitchintLowest playable MIDI pitch, 0..127.
MaxPitchintHighest playable MIDI pitch, 0..127, not below
MinPitch.
Remarks
Both bounds must be MIDI pitches, and the range must not be inverted. Unvalidated, this type
could describe a range no instrument has: (int.MaxValue, int.MaxValue) was perfectly
constructible, and wedged OrchestrationMapper in an infinite loop.
This covers construction only. default(InstrumentRange) is (0, 0) and with { }
assigns without re-checking — as they do for every C# record struct — so consumers have to stay
correct for any bounds regardless of this. OrchestrationMapper.ClampToRange does.
Exceptions
- ArgumentOutOfRangeException
A bound is outside [0, 127], or
MaxPitchis belowMinPitch.
Properties
MaxPitch
Highest playable MIDI pitch.
public int MaxPitch { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
A bound is outside [0, 127], or
MaxPitchis belowMinPitch.
MinPitch
Lowest playable MIDI pitch.
public int MinPitch { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
A bound is outside [0, 127], or
MaxPitchis belowMinPitch.
Methods
Contains(int)
Returns whether pitch lies within the inclusive range.
public bool Contains(int pitch)
Parameters
pitchint
Returns
Exceptions
- ArgumentOutOfRangeException
A bound is outside [0, 127], or
MaxPitchis belowMinPitch.