private void TypeTextBox_TextChanged(object sender, TextChangedEventArgs e) { this.ValidateNumericInput(this.TypeLabel, ref this._Type, 0, sbyte.MaxValue); this.TypeTextBlock.Text = (this.Type < 0) ? null : MidiMetaEvent.GetTypeComment(this.Type); this.DataLength = MidiMetaEvent.GetDataLength(this.Type); this.DataCommentTextBox.IsReadOnly = (this.DataLength >= 0); this.UpdateDataComment(); }
private static string DescribeNumber(int type, byte[] bytes) { int n = MidiMetaEvent.GetDataLength(type); if (bytes.Length < n) { return(null); } return(Midi.ReadNumber(bytes, 0, n).ToString()); }
private static string DescribeTimeSignature(byte[] bytes) { int n = MidiMetaEvent.GetDataLength(MidiMetaEvent.TimeSignatureType); if (bytes.Length < n) { return(null); } return(string.Format("{0}/{1} {2}, {3} {4}, {5} {6}", bytes[0], Math.Pow(2, bytes[1]), Properties.Resources.Time, bytes[2], Properties.Resources.ClocksPerClick, bytes[3], Properties.Resources.NotesPerQuarterNote)); }
private static string DescribeTempo(byte[] bytes) { int n = MidiMetaEvent.GetDataLength(MidiMetaEvent.SetTempoType); if (bytes.Length < n) { return(null); } n = Midi.ReadNumber(bytes, 0, n); return(string.Format("{0} {1} ({2} {3})", n, Properties.Resources.MicrosecondsPerQuarterNote, (n == 0) ? double.PositiveInfinity : (60000000 / n), Properties.Resources.BeatsPerMinute)); }
private static string DescribeKeySignature(byte[] bytes) { int n = MidiMetaEvent.GetDataLength(MidiMetaEvent.KeySignatureType); if (bytes.Length < n) { return(null); } MidiKeySignature k = MidiMetaEvent.DataToKeySignature(bytes); return((k == MidiKeySignature.NA) ? null : k.ToString().Replace("Flat", "b").Replace("Sharp", "#").Replace("Major", " major").Replace("Minor", " minor")); }
private static string DescribeSmpteOffset(byte[] bytes) { int n = MidiMetaEvent.GetDataLength(MidiMetaEvent.SmpteOffsetType); if (bytes.Length < n) { return(null); } string s = string.Empty; foreach (byte b in bytes) { if (s.Length > 0) { s += (s.Length > 9) ? "." : ":"; } s += b.ToString("00"); } return(s); }