private void OnMetaMessagePlayed(object sender, MetaMessageEventArgs e) { if (e.Message.MetaType == MetaType.Tempo) { TempoChangeBuilder builder = new TempoChangeBuilder(e.Message); midiTempo = (60000000 / builder.Tempo); OnTempoChange?.Invoke(this, midiTempo); } if (e.Message.MetaType == MetaType.Lyric) { MetaTextBuilder builder = new MetaTextBuilder(e.Message); if (e.MidiTrack == LoadedTrack) { OnLyric?.Invoke(this, builder.Text); } } if (e.Message.MetaType == MetaType.TrackName) { MetaTextBuilder builder = new MetaTextBuilder(e.Message); ParseTrackName(e.MidiTrack, builder.Text); if (e.MidiTrack == LoadedTrack) { OnTrackNameChange?.Invoke(this, builder.Text); } } if (e.Message.MetaType == MetaType.InstrumentName) { MetaTextBuilder builder = new MetaTextBuilder(e.Message); OnTrackNameChange?.Invoke(this, builder.Text); Console.WriteLine("Instrument name: " + builder.Text); } }
static void MIDIMetaMessagePlayed(object sender, MetaMessageEventArgs e) { var m = e.Message; foreach (var b in m.GetBytes()) { Console.Write("{0:X} ", b); } }
protected virtual void OnMetaMessageDispatched(MetaMessageEventArgs e) { EventHandler <MetaMessageEventArgs> handler = MetaMessageDispatched; if (handler != null) { handler(this, e); } }
void m_Sequencer_MetaMessagePlayed(object sender, MetaMessageEventArgs e) { if (e.Message.MetaType == MetaType.Text) { if (prevPos == m_Sequencer.Position) { return; } string tmpFilled; int filledIdx; if ((filledIdx = karTextByPiece.IndexOfKey(m_Sequencer.Position - 1)) != -1) { string tmpNextFilled = String.Empty; if (karTextByPiece.Count >= (filledIdx + 1 + 1)) { tmpNextFilled = karTextByPiece.Values[filledIdx + 1]; } if (karTextByPiece.TryGetValue(m_Sequencer.Position - 1, out tmpFilled)) { bFlag = !bFlag; if (bFlag) { filled = tmpFilled; filling = String.Empty; filled1 = tmpNextFilled; filling1 = String.Empty; } else { filled1 = tmpFilled; filling1 = String.Empty; filled = tmpNextFilled; filling = String.Empty; } } } string tmpFilling; if (karTextBit.TryGetValue(m_Sequencer.Position - 1, out tmpFilling)) { if (!tmpFilling.StartsWith("@")) { if (tmpFilling.StartsWith("/") || tmpFilling.StartsWith("\\")) { tmpFilling = tmpFilling.Remove(0, 1); } if (bFlag) { filling += tmpFilling; } else { filling1 += tmpFilling; } } } m_Owner.Invalidate(); prevPos = m_Sequencer.Position; } }