Пример #1
0
 public PortAudioInputStream(PaStreamParameters inputParameters, double sampleRate, uint framesPerBuffer, PaStreamFlags streamFlags, StreamCallback streamCallback, IntPtr userData)
     : base(inputParameters.sampleFormat, inputParameters.channelCount)
 {
     using (var input = Factory.ToNative <PaStreamParameters> (inputParameters))
         HandleError(PortAudioInterop.Pa_OpenStream(
                         out handle,
                         input.Native,
                         IntPtr.Zero,
                         sampleRate,
                         framesPerBuffer,
                         streamFlags,
                         ToPaStreamCallback(streamCallback, false),
                         userData
                         ));
 }
Пример #2
0
        public PortAudioOutputStream(PaStreamParameters outputParameters, double sampleRate, uint framesPerBuffer, PaStreamFlags streamFlags, StreamCallback streamCallback, object userData)
            : base(outputParameters.sampleFormat, outputParameters.channelCount)
        {
            var gch = userData == null ? default(GCHandle) : GCHandle.Alloc(userData, GCHandleType.Pinned);

            try {
                using (var output = Factory.ToNative <PaStreamParameters> (outputParameters))
                    HandleError(PortAudioInterop.Pa_OpenStream(
                                    out handle,
                                    IntPtr.Zero,
                                    output.Native,
                                    sampleRate,
                                    framesPerBuffer,
                                    streamFlags,
                                    ToPaStreamCallback(streamCallback, true),
                                    userData != null ? gch.AddrOfPinnedObject() : IntPtr.Zero));
            } finally {
                if (userData != null)
                {
                    gch.Free();
                }
            }
        }
Пример #3
0
 public static PaErrorCode CheckIfFormatSupported(PaStreamParameters inputParameters, PaStreamParameters outputParameters, double sampleRate)
 {
     using (var input = Factory.ToNative <PaStreamParameters> (inputParameters))
         using (var output = Factory.ToNative <PaStreamParameters> (outputParameters))
             return(PortAudioInterop.Pa_IsFormatSupported(input.Native, output.Native, sampleRate));
 }