Exemple #1
0
        /// <summary>
        /// Dispatch a MIDI System Exclusive message
        /// </summary>
        /// <param name="header"></param>
        /// <param name="timeStamp"></param>
        private void DispatchSysExMessage(MidiLibWrap.MidiHeader header, uint timeStamp)
		{
			// Create array for holding system exclusive data.
			byte[] data = new byte[header.bytesRecorded - 1];

			// Get status byte.
			byte status = Marshal.ReadByte(header.data);
                
			// Copy system exclusive data into array (status byte is excluded).
			for(int i = 1; i < header.bytesRecorded; i++)
			{
				data[i - 1] = Marshal.ReadByte(header.data, i);
			}

			// Create message.
			SysExMessage msg = new SysExMessage((SysExType)status, data);

			// Raise event.
			//SysExReceived(this, new SysExEventArgs(msg, timeStamp));

			// Fire our specific Input Data Event
			if(OnMidiInputPortData!=null)
			{
				ObjectEventArgs e = new ObjectEventArgs( msg );
				OnMidiInputPortData( this, e );
			}

			// Fire the All Midi Input Data event
            //ProjectMidi.ProjectMidiParent.FireAllSysExInputData(msg as ISysExMessage, timeStamp);
		}
Exemple #2
0
        /// <summary>
        /// Instance MIDI callback. Called from the static MIDI callback.
        /// </summary>
        /// <param name="hMidiIn"></param>
        /// <param name="msg"></param>
        /// <param name="dwInstance"></param>
        /// <param name="dwParam1"></param>
        /// <param name="dwParam2"></param>
		void InstanceMidiCallback(int hMidiIn, uint msg, uint dwInstance, uint dwParam1, uint dwParam2)
		{
			try
			{
				NumMidiCallbacksReceived++;
				if(msg == MidiLibWrap.MIM_DATA)
				{
					// Handle input data
					m_PreviousMidiData = m_LastMidiData;
					m_LastMidiData = new MidiData( dwParam1, dwParam2 );
					if(m_LastMidiData.IsActiveSense==false && m_LastMidiData.IsTimingClock==false)
					{
						RC.WriteLine(string.Format("InstanceMidiCallback: {0:A}", m_LastMidiData));
					}

					// Fire our specific Input Data Event
					if(OnMidiInputPortData!=null)
					{
						ObjectEventArgs e = new ObjectEventArgs( m_LastMidiData );
						OnMidiInputPortData( this, e );
					}

					// Fire the All Midi Input Data event
                    //ProjectMidi.ProjectMidiParent.FireAllMidiInputData(lastMidiData as IMidiData, dwParam1);

				}
				//else if(msg == MIM_ERROR)
				//{
				//	DispatchInvalidShortMsg(param1, param2);
				//}
				else if(msg == MidiLibWrap.MIM_LONGDATA)
				{
					ManageSysExMessage(dwParam1, dwParam2);
				}
			}
			catch(Exception e)
			{
				RC.WriteLine(string.Format("Error in InstanceMidiCallback: {0}", e.Message));
			}
		}