/*********** * Methods * ***********/ #region Private Methods #region Event Handlers private void DataHexTextBox_TextChanged(object sender, TextChangedEventArgs e) { byte[] bytes = Midi.ParseHex(this.DataHexTextBox.Text); if (bytes == null) { this.DataHexTextBox.Text = this.Hex; return; } this.Hex = this.DataHexTextBox.Text; this._Data = bytes; this.DataCommentTextBox.Text = Midi.ReadText(this.Data, 0, this.Data.Length); }
/// <summary>Reads text as a string of ASCII characters from this file's byte array.</summary> /// <param name="offset">Offset into the byte array at which the text is stored.</param> /// <param name="length">The number of bytes (ASCII characters) to read.</param> /// <returns>The text that is read.</returns> public string ReadText(int offset, int length) { return(Midi.ReadText(this.Bytes, offset, length)); }
/// <summary>Returns a comment for the data bytes of a meta-event.</summary> /// <param name="type">Meta-event type (always less than 128).</param> /// <param name="bytes">The data bytes of the event.</param> /// <returns>A comment for the data bytes.</returns> public static string GetDataComment(int type, byte[] bytes) { return((MidiMetaEvent.TypeMap.ContainsKey(type) && MidiMetaEvent.TypeMap[type].DescribeData != null) ? MidiMetaEvent.TypeMap[type].DescribeData(bytes) : Midi.ReadText(bytes, 0, bytes.Length)); }