pitchBend static method

MidiEvent pitchBend({
  1. required double beat,
  2. required double value,
})

Implementation

static MidiEvent pitchBend({
  required double beat,
  required double value,
}) {
  if (value > 1 || value < -1) throw 'value must be in range -1 to 1';

  final intValue = (((value + 1) / 2) * 16383).round();
  final midiData1 = intValue >> 7;
  final midiData2 = intValue & 0x7F;

  return MidiEvent(
    beat: beat,
    midiStatus: 0xE0,
    midiData1: midiData1,
    midiData2: midiData2,
  );
}