/// <summary> /// Reads the message from a MIDI stream. /// </summary> /// <param name="data">The MIDI stream containing the message data.</param> public override void ReadData(IO.MidiBinaryReader data) { base.ReadData(data); CommandFormat = (MscFormat)data.ReadByte(); ShowControlCommand = (MscCommand)data.ReadByte(); if (ShowControlCommand.HasCueParameter()) { if (!data.EndOfMessage) { CueNumber = data.ReadMidiString(); } if (!data.EndOfMessage) { CueList = data.ReadMidiString(); } if (!data.EndOfMessage) { CuePath = data.ReadMidiString(); } } if (ShowControlCommand.HasNumberParameter()) { Number = data.ReadByte(); } }
/// <summary> /// Writes this message to the MIDI stream. /// </summary> /// <param name="data">The MIDI stream to write the messafe to.</param> public override void WriteData(IO.MidiBinaryWriter data) { base.WriteData(data); data.Write((byte)CommandFormat); data.Write((byte)ShowControlCommand); if (ShowControlCommand.HasCueParameter()) { if (!string.IsNullOrEmpty(CueNumber)) { data.WriteMidiString(CueNumber, !string.IsNullOrEmpty(CueList)); if (!string.IsNullOrEmpty(CueList)) { data.WriteMidiString(CueList, !string.IsNullOrEmpty(CuePath)); if (!string.IsNullOrEmpty(CuePath)) { data.WriteMidiString(CuePath, false); } } else { if (!string.IsNullOrEmpty(CuePath)) { throw new FormatException("The Cue List parameter has not been set the MIDI Show Control message. This will result in an invalid MIDI message."); } } } else { if (!string.IsNullOrEmpty(CueList) || !string.IsNullOrEmpty(CuePath)) { throw new FormatException("The Cue Number parameter has not been set the MIDI Show Control message. This will result in an invalid MIDI message."); } } } if (ShowControlCommand.HasNumberParameter()) { data.Write((byte)Number); } data.Write((byte)MidiCommand.SystemExclusiveEnd); }