コード例 #1
0
        protected override void WndProc(ref Message m)
        {
            WaveInterop.WaveMessage message = (WaveInterop.WaveMessage)m.Msg;

            switch (message)
            {
            case WaveInterop.WaveMessage.WaveOutDone:
            case WaveInterop.WaveMessage.WaveInData:
                IntPtr     hOutputDevice = m.WParam;
                WaveHeader waveHeader    = new WaveHeader();
                Marshal.PtrToStructure(m.LParam, waveHeader);
                waveCallback(hOutputDevice, message, IntPtr.Zero, waveHeader, IntPtr.Zero);
                break;

            case WaveInterop.WaveMessage.WaveOutOpen:
            case WaveInterop.WaveMessage.WaveOutClose:
            case WaveInterop.WaveMessage.WaveInClose:
            case WaveInterop.WaveMessage.WaveInOpen:
                waveCallback(m.WParam, message, IntPtr.Zero, null, IntPtr.Zero);
                break;

            default:
                base.WndProc(ref m);
                break;
            }
        }
コード例 #2
0
        private GCHandle hThis;   // for the user callback

        /// <summary>
        /// creates a new wavebuffer
        /// </summary>
        /// <param name="waveInHandle">WaveIn device to write to</param>
        /// <param name="bufferSize">Buffer size in bytes</param>
        public WaveInBuffer(IntPtr waveInHandle, Int32 bufferSize)
        {
            this.bufferSize   = bufferSize;
            this.buffer       = new byte[bufferSize];
            this.hBuffer      = GCHandle.Alloc(buffer, GCHandleType.Pinned);
            this.waveInHandle = waveInHandle;

            header              = new WaveHeader();
            hHeader             = GCHandle.Alloc(header, GCHandleType.Pinned);
            header.dataBuffer   = hBuffer.AddrOfPinnedObject();
            header.bufferLength = bufferSize;
            header.loops        = 1;
            hThis           = GCHandle.Alloc(this);
            header.userData = (IntPtr)hThis;

            MmException.Try(WaveInterop.waveInPrepareHeader(waveInHandle, header, Marshal.SizeOf(header)), "waveInPrepareHeader");
            //MmException.Try(WaveInterop.waveInAddBuffer(waveInHandle, header, Marshal.SizeOf(header)), "waveInAddBuffer");
        }
コード例 #3
0
 public static extern MmResult waveOutWrite(IntPtr hWaveOut, WaveHeader lpWaveOutHdr, int uSize);
コード例 #4
0
 public static extern MmResult waveOutUnprepareHeader(IntPtr hWaveOut, WaveHeader lpWaveOutHdr, int uSize);
コード例 #5
0
 public static extern MmResult waveInPrepareHeader(IntPtr hWaveIn, WaveHeader lpWaveInHdr, int uSize);
コード例 #6
0
 public static extern MmResult waveInAddBuffer(IntPtr hWaveIn, WaveHeader pwh, int cbwh);