Table of Contents

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

MinPitch int

Lowest playable MIDI pitch, 0..127.

MaxPitch int

Highest 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 MaxPitch is below MinPitch.

Properties

MaxPitch

Highest playable MIDI pitch.

public int MaxPitch { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

A bound is outside [0, 127], or MaxPitch is below MinPitch.

MinPitch

Lowest playable MIDI pitch.

public int MinPitch { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

A bound is outside [0, 127], or MaxPitch is below MinPitch.

Methods

Contains(int)

Returns whether pitch lies within the inclusive range.

public bool Contains(int pitch)

Parameters

pitch int

Returns

bool

Exceptions

ArgumentOutOfRangeException

A bound is outside [0, 127], or MaxPitch is below MinPitch.