Exemple #1
0
        public static void ThrowExceptionForReasonCode(int reasonCode)
        {
            var exception = new TeVirtualMIDIException(reasonCodeToString(reasonCode))
            {
                reasonCode = reasonCode
            };

            throw exception;
        }
Exemple #2
0
        public void shutdown()
        {
            if (!virtualMIDIShutdown(fInstance))
            {
                var lastError = Marshal.GetLastWin32Error();

                TeVirtualMIDIException.ThrowExceptionForReasonCode(lastError);
            }
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
        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;
        }
Exemple #5
0
        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;
        }