void HandleMessageReceived(MidiDataReceivedEventHandler eventHandler, MidiPacketsEventArgs e) { foreach (MidiPacket mPacket in e.Packets) { var midiData = new byte[mPacket.Length]; Marshal.Copy (mPacket.Bytes, midiData, 0, mPacket.Length); MidiMessage message = new MidiMessage (); message.ParseRawData (midiData); message.TimeStamp = mPacket.TimeStamp; //rais event if (eventHandler != null) { eventHandler (this, new MidiDataReceivedEventArgs (message)); } } }
void HandleMessageReceived(object sender, MidiPacketsEventArgs e) { foreach (MidiPacket mPacket in e.Packets) { var midiData = new byte[mPacket.Length]; Marshal.Copy (mPacket.Bytes, midiData, 0, mPacket.Length); MidiMessage message = new MidiMessage (); message.ParseRawData (midiData); message.TimeStamp = mPacket.TimeStamp; //Console.WriteLine("type: {0} channel: {1} note: {2} velocity: {3}", message.MessageType.ToString(), message.MidiChannel, message.NoteNumber, message.NoteVelocity); //rais event if (MidiDataReceived != null) { MidiDataReceived (this, new MidiDataReceivedEventArgs (message)); } } }