private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { C_MidControl.res = M_MidModel.midiOutGetDevCaps(0, ref formCap, (UInt32)Marshal.SizeOf(formCap)); C_MidControl.res = M_MidModel.midiOutOpen(ref C_MidControl.ohandle, 0, null, 0, 0); var prevTimestamp = -250; for (int i = 0; i < noteDict.Count; i++) { if (!noteDict[i].IsDisposed) { byte[] data = new byte[4]; data[0] = 0x90; data[1] = noteDict[i].noteLevel; data[2] = 127; uint msg = BitConverter.ToUInt32(data, 0); C_MidControl.res = M_MidModel.midiOutShortMsg(C_MidControl.ohandle, (int)msg); var sleepTimestamp = noteDict[i].noteTimeStamp - prevTimestamp; Thread.Sleep(sleepTimestamp); prevTimestamp = noteDict[i].noteTimeStamp; } } C_MidControl.res = M_MidModel.midiOutClose(C_MidControl.ohandle); }
private void toolStripButton7_Click(object sender, EventArgs e) { C_MidControl.res = M_MidModel.midiOutGetDevCaps(0, ref formCap, (UInt32)Marshal.SizeOf(formCap)); M_MidModel.midiInGetDevCaps(UIntPtr.Zero, out formDevices[0], (UInt32)Marshal.SizeOf(typeof(MIDIINCAPS))); device_ID = UIntPtr.Zero; M_MidModel.midiInOpen(out handle, device_ID, C_MidControl.callback, (UIntPtr)0); M_MidModel.midiInStart(handle); C_MidControl.res = M_MidModel.midiOutOpen(ref C_MidControl.ohandle, 0, null, 0, 0); }