Pitch constructor

const Pitch({
  1. required String step,
  2. required int octave,
  3. double alter = 0.0,
  4. AccidentalType? accidentalType,
  5. String? customAccidentalGlyph,
})

Creates a pitch from a diatonic step, an octave and an optional chromatic alter.

In debug builds the step must be one of validSteps (uppercase) and the octave must be in the MIDI-representable range [-1, 10].

Implementation

const Pitch({
  required this.step,
  required this.octave,
  this.alter = 0.0,
  this.accidentalType,
  this.customAccidentalGlyph,
})  : assert(
        step == 'C' ||
            step == 'D' ||
            step == 'E' ||
            step == 'F' ||
            step == 'G' ||
            step == 'A' ||
            step == 'B',
        'Invalid pitch step (expected one of C D E F G A B)',
      ),
      assert(
        octave >= -1 && octave <= 10,
        'Octave out of range (expected -1..10)',
      );