Exemplo n.º 1
0
        public WaveInBuffer(IntPtr waveInHandle, int size)
        {
            m_WaveIn = waveInHandle;

            _mHeaderHandle          = GCHandle.Alloc(_mHeader, GCHandleType.Pinned);
            _mHeader.dwUser         = (IntPtr)GCHandle.Alloc(this);
            _mHeaderData            = new byte[size];
            _mHeaderDataHandle      = GCHandle.Alloc(_mHeaderData, GCHandleType.Pinned);
            _mHeader.lpData         = _mHeaderDataHandle.AddrOfPinnedObject();
            _mHeader.dwBufferLength = size;
            WaveInHelper.Try(WaveNative.waveInPrepareHeader(m_WaveIn, ref _mHeader, Marshal.SizeOf(_mHeader)));
        }
Exemplo n.º 2
0
 public WaveInRecorder(int device, WaveFormat format, int bufferSize, int bufferCount,
                       BufferDoneEventHandler doneProc)
 {
     _mDoneProc = doneProc;
     WaveInHelper.Try(WaveNative.waveInOpen(out _mWaveIn, device, format, _mBufferProc, 0,
                                            WaveNative.CallbackFunction));
     AllocateBuffers(bufferSize, bufferCount);
     for (var i = 0; i < bufferCount; i++)
     {
         SelectNextBuffer();
         _mCurrentBuffer.Record();
     }
     WaveInHelper.Try(WaveNative.waveInStart(_mWaveIn));
     _mThread = new Thread(ThreadProc)
     {
         IsBackground = true
     };
     _mThread.Start();
 }