fromProto static method

MidiMessage fromProto(
  1. MidiMessage proto
)

Implementation

static MidiMessage fromProto(midi_mapping_pb.MidiMessage proto) {
  return switch (proto.whichParameters()) {
    midi_mapping_pb.MidiMessage_Parameters.noteOn => MidiMessage.noteOn(
        channel: proto.channel,
        note: proto.noteOn.note,
        velocity: proto.noteOn.velocity,
      ),
    midi_mapping_pb.MidiMessage_Parameters.noteOff => MidiMessage.noteOff(
        channel: proto.channel,
        note: proto.noteOff.note,
        velocity: proto.noteOff.velocity,
      ),
    midi_mapping_pb.MidiMessage_Parameters.controlChange =>
      MidiMessage.controlChange(
        channel: proto.channel,
        control: proto.controlChange.control,
        value: proto.controlChange.value,
      ),
    midi_mapping_pb.MidiMessage_Parameters.programChange =>
      MidiMessage.programChange(
        channel: proto.channel,
        number: proto.programChange.number,
      ),
    midi_mapping_pb.MidiMessage_Parameters.notSet => throw ProtoException(),
  };
}