public void Shutdown() { if (!VirtualMIDIShutdown(instance)) { int lastError = Marshal.GetLastWin32Error(); throw TeVirtualMidiException.NewExceptionForReasonCode(lastError); } }
public TeVirtualMidi(string portName, uint maxSysexLength, CreationOptions options, ref Guid manufacturer, ref Guid product) { instance = VirtualMIDICreatePortEx3(portName, IntPtr.Zero, IntPtr.Zero, maxSysexLength, (uint)options, ref manufacturer, ref product); if (instance == IntPtr.Zero) { int lastError = Marshal.GetLastWin32Error(); throw TeVirtualMidiException.NewExceptionForReasonCode(lastError); } readBuffer = new byte[maxSysexLength]; readProcessIds = new ulong[17]; this.maxSysexLength = maxSysexLength; }
public TeVirtualMidi(string portName, uint maxSysexLength = DefaultSysExSize, CreationOptions options = CreationOptions.ParseIncomingDataIntoValidMidi) { instance = VirtualMIDICreatePortEx2(portName, IntPtr.Zero, IntPtr.Zero, maxSysexLength, (uint)options); if (instance == IntPtr.Zero) { int lastError = Marshal.GetLastWin32Error(); throw TeVirtualMidiException.NewExceptionForReasonCode(lastError); } readBuffer = new byte[maxSysexLength]; readProcessIds = new ulong[17]; this.maxSysexLength = maxSysexLength; }
public void SendCommand(byte[] command) { if ((command == null) || (command.Length == 0)) { return; } if (!VirtualMIDISendData(instance, command, (uint)command.Length)) { int lastError = Marshal.GetLastWin32Error(); throw TeVirtualMidiException.NewExceptionForReasonCode(lastError); } }
public byte[] GetCommand() { uint length = maxSysexLength; if (!VirtualMIDIGetData(instance, readBuffer, ref length)) { int lastError = Marshal.GetLastWin32Error(); throw TeVirtualMidiException.NewExceptionForReasonCode(lastError); } byte[] outBytes = new byte[length]; Array.Copy(readBuffer, outBytes, length); return(outBytes); }
public ulong[] GetProcessIds() { uint length = 17 * sizeof(ulong); uint count; if (!VirtualMIDIGetProcesses(instance, readProcessIds, ref length)) { int lastError = Marshal.GetLastWin32Error(); throw TeVirtualMidiException.NewExceptionForReasonCode(lastError); } count = length / sizeof(ulong); ulong[] outIds = new ulong[count]; Array.Copy(readProcessIds, outIds, count); return(outIds); }