예제 #1
0
        private void PrepareSysExBuffer()
        {
            var buffer = new byte[SysExBufferLength];

            _sysExBufferPointer = Marshal.AllocHGlobal(buffer.Length);
            Marshal.Copy(buffer, 0, _sysExBufferPointer, buffer.Length);

            _sysExHeader                = new MidiWinApi.MIDIHDR();
            _sysExHeader.lpData         = _sysExBufferPointer;
            _sysExHeader.dwBufferLength = _sysExHeader.dwBytesRecorded = (uint)buffer.Length;

            ProcessMmResult(() => MidiInWinApi.midiInPrepareHeader(_handle, ref _sysExHeader, Marshal.SizeOf(_sysExHeader)));
            ProcessMmResult(() => MidiInWinApi.midiInAddBuffer(_handle, ref _sysExHeader, Marshal.SizeOf(_sysExHeader)));
        }
예제 #2
0
        private void PrepareSysExBuffer()
        {
            var header = new MidiWinApi.MIDIHDR
            {
                lpData          = Marshal.AllocHGlobal(SysExBufferLength),
                dwBufferLength  = SysExBufferLength,
                dwBytesRecorded = SysExBufferLength
            };

            _sysExHeaderPointer = Marshal.AllocHGlobal(MidiWinApi.MidiHeaderSize);
            Marshal.StructureToPtr(header, _sysExHeaderPointer, false);

            ProcessMmResult(MidiInWinApi.midiInPrepareHeader(_handle, _sysExHeaderPointer, MidiWinApi.MidiHeaderSize));
            ProcessMmResult(MidiInWinApi.midiInAddBuffer(_handle, _sysExHeaderPointer, MidiWinApi.MidiHeaderSize));
        }
        private IntPtr PrepareSysExBuffer(byte[] data)
        {
            var bufferLength = data.Length + 1;
            var dataPointer  = Marshal.AllocHGlobal(bufferLength);

            Marshal.WriteByte(dataPointer, EventStatusBytes.Global.NormalSysEx);
            Marshal.Copy(data, 0, IntPtr.Add(dataPointer, 1), data.Length);

            var header = new MidiWinApi.MIDIHDR
            {
                lpData          = dataPointer,
                dwBufferLength  = bufferLength,
                dwBytesRecorded = bufferLength
            };

            var headerPointer = Marshal.AllocHGlobal(MidiWinApi.MidiHeaderSize);

            Marshal.StructureToPtr(header, headerPointer, false);

            ProcessMmResult(MidiOutWinApi.midiOutPrepareHeader(_handle, headerPointer, MidiWinApi.MidiHeaderSize));

            return(headerPointer);
        }
예제 #4
0
 public static extern MMRESULT midiInAddBuffer(IntPtr hMidiIn, ref MidiWinApi.MIDIHDR lpMidiInHdr, int cbMidiInHdr);
예제 #5
0
 public static extern MMRESULT midiInUnprepareHeader(IntPtr hMidiIn, ref MidiWinApi.MIDIHDR lpMidiInHdr, int cbMidiInHdr);