Beispiel #1
0
        private void OnWimData()
        {
            WaveHdr header;

            byte[] samples;
            if (lastHeader == 1)
            {
                header  = waveHdr1;
                samples = pBuffer1;
            }
            else if (lastHeader == 2)
            {
                header  = waveHdr2;
                samples = pBuffer2;
            }
            else
            {
                if (bEnding)
                {
                    WinmmHook.waveInClose(hWaveIn);
                }
                return;
            }

            byte[] result;
            int    copyPos;

            if (pSaveBuffer == null)
            {
                result  = new byte[header.dwBytesRecorded];
                copyPos = 0;
            }
            else
            {
                result = new byte[pSaveBuffer.Length + header.dwBytesRecorded];
                pSaveBuffer.CopyTo(result, 0);
                copyPos = pSaveBuffer.Length;
            }
            Array.Copy(samples, 0, result, copyPos, header.dwBytesRecorded);
            pSaveBuffer = result;

            if (bEnding)
            {
                WinmmHook.waveInReset(hWaveIn);
                WinmmHook.waveInClose(hWaveIn);
                return;
            }


            if (lastHeader == 1)
            {
                WinmmHook.waveInAddBuffer(hWaveIn, ref waveHdr1, Marshal.SizeOf(waveHdr1));
            }
            else if (lastHeader == 2)
            {
                WinmmHook.waveInAddBuffer(hWaveIn, ref waveHdr2, Marshal.SizeOf(waveHdr2));
            }
        }
Beispiel #2
0
        /*
         * ===============  Actions ===============
         */

        private void OnWimOpen()
        {
            WinmmHook.waveInAddBuffer(hWaveIn, ref waveHdr1, Marshal.SizeOf(waveHdr1));
            WinmmHook.waveInAddBuffer(hWaveIn, ref waveHdr2, Marshal.SizeOf(waveHdr2));

            bRecording = true;
            bEnding    = false;
            WinmmHook.PostMessage(parentHandle, WinmmHook.WM_USER + 1, (int)PlaybackStatus.Recording, 0);
            WinmmHook.waveInStart(hWaveIn);
        }