Exemplo n.º 1
0
        public void Record()
        {
            IntPtr userdata = IntPtr.Zero; //intptr.zero is essentially just a null pointer

            callbackDelegate = new PortAudio.PaStreamCallbackDelegate(myPaStreamCallback);
            PortAudio.Pa_Initialize();

            PortAudio.PaStreamParameters outputparams = new PortAudio.PaStreamParameters();

            outputparams.channelCount              = 1;
            outputparams.sampleFormat              = PortAudio.PaSampleFormat.paInt16;
            outputparams.device                    = PortAudio.Pa_GetDefaultInputDevice();
            outputparams.suggestedLatency          = PortAudio.Pa_GetDeviceInfo(outputparams.device).defaultLowInputLatency;
            outputparams.hostApiSpecificStreamInfo = IntPtr.Zero;


            PortAudio.PaStreamParameters a = new PortAudio.PaStreamParameters(); //uninteresting output params cause i cant give it null

            a.channelCount              = 1;
            a.sampleFormat              = PortAudio.PaSampleFormat.paInt16;
            a.device                    = PortAudio.Pa_GetDefaultOutputDevice();
            a.suggestedLatency          = PortAudio.Pa_GetDeviceInfo(a.device).defaultLowOutputLatency;
            a.hostApiSpecificStreamInfo = IntPtr.Zero;


            PortAudio.PaError error = PortAudio.Pa_OpenStream(out stream, ref outputparams, ref a, this.sampleRate,
                                                              (uint)NUM_SAMPLES, PortAudio.PaStreamFlags.paClipOff, callbackDelegate, IntPtr.Zero);

            this.isRecording = true;
            PortAudio.Pa_StartStream(stream);

            Thread myThread = new Thread(new ThreadStart(record_loop));

            myThread.Start();
        }