Beispiel #1
0
        public WaveInBuffer(IntPtr waveInHandle, int size)
        {
            m_WaveIn = waveInHandle;

            m_HeaderHandle          = GCHandle.Alloc(m_Header, GCHandleType.Pinned);
            m_Header.dwUser         = (IntPtr)GCHandle.Alloc(this);
            m_HeaderData            = new byte[size];
            m_HeaderDataHandle      = GCHandle.Alloc(m_HeaderData, GCHandleType.Pinned);
            m_Header.lpData         = m_HeaderDataHandle.AddrOfPinnedObject();
            m_Header.dwBufferLength = size;
            WaveInHelper.Try(WaveNative.waveInPrepareHeader(m_WaveIn, ref m_Header, Marshal.SizeOf(m_Header)));
        }
Beispiel #2
0
 public WaveInRecorder(int device, WaveFormat format, int bufferSize, int bufferCount, BufferDoneEventHandler doneProc)
 {
     m_DoneProc = doneProc;
     WaveInHelper.Try(WaveNative.waveInOpen(out m_WaveIn, device, format, m_BufferProc, IntPtr.Zero, WaveNative.CALLBACK_FUNCTION));
     AllocateBuffers(bufferSize, bufferCount);
     for (int i = 0; i < bufferCount; i++)
     {
         SelectNextBuffer();
         m_CurrentBuffer.Record();
     }
     WaveInHelper.Try(WaveNative.waveInStart(m_WaveIn));
     m_Thread = new Thread(ThreadProc);
     m_Thread.Start();
 }