Example #1
0
        private int AddSysexBuffer()
        {
            int    result = -1;
            int    shdr   = Marshal.SizeOf(typeof(MidiHeader));
            IntPtr nhdr   = Marshal.AllocHGlobal(shdr);

            header = new MidiHeader();
            header.bufferLength  = header.bytesRecorded = 128;
            header.bytesRecorded = 0;
            header.data          = Marshal.AllocHGlobal(128);
            header.flags         = 0;
            Marshal.StructureToPtr(header, nhdr, false);
            result = WinMM.midiInPrepareHeader(inHandle, nhdr, shdr);
            if (result != 0)
            {
                throw new Exception("Cannot prepare IN header");
            }
            result = WinMM.midiInAddBuffer(inHandle, nhdr, shdr);
            if (result != 0)
            {
                throw new Exception("Cannot add IN buffer");
            }
            return(result);
        }