public static void ThrowExceptionForReasonCode(int reasonCode) { var exception = new TeVirtualMIDIException(reasonCodeToString(reasonCode)) { reasonCode = reasonCode }; throw exception; }
public void shutdown() { if (!virtualMIDIShutdown(fInstance)) { var lastError = Marshal.GetLastWin32Error(); TeVirtualMIDIException.ThrowExceptionForReasonCode(lastError); } }
public void sendCommand(byte[] command) { if ((command == null) || (command.Length == 0)) { return; } if (!virtualMIDISendData(fInstance, command, (UInt32)command.Length)) { var lastError = Marshal.GetLastWin32Error(); TeVirtualMIDIException.ThrowExceptionForReasonCode(lastError); } }
public VirtualMIDI(string portName, UInt32 maxSysexLength = TE_VM_DEFAULT_SYSEX_SIZE, UInt32 flags = TE_VM_FLAGS_PARSE_RX) { fInstance = virtualMIDICreatePortEx2(portName, IntPtr.Zero, IntPtr.Zero, maxSysexLength, flags); if (fInstance == IntPtr.Zero) { var lastError = Marshal.GetLastWin32Error(); TeVirtualMIDIException.ThrowExceptionForReasonCode(lastError); } fReadBuffer = new byte[maxSysexLength]; fMaxSysexLength = maxSysexLength; }
public byte[] getCommand() { var length = fMaxSysexLength; if (!virtualMIDIGetData(fInstance, fReadBuffer, ref length)) { var lastError = Marshal.GetLastWin32Error(); TeVirtualMIDIException.ThrowExceptionForReasonCode(lastError); } var outBytes = new byte[length]; Array.Copy(fReadBuffer, outBytes, length); return(outBytes); }
public static void ThrowExceptionForReasonCode(int reasonCode) { var exception = new TeVirtualMIDIException(reasonCodeToString(reasonCode)) { reasonCode = reasonCode }; throw exception; }