Beispiel #1
0
 internal PaStream(
     IntPtr stream, StreamCallbackContainer streamCallbackContainer,
     PaSampleFormat inputSampleFormat, PaSampleFormat outputSampleFormat,
     int numInputChannels, int numOutputChannels)
 {
     this.stream = stream;
     this.streamCallbackContainer = streamCallbackContainer;
 }
        public PaStream OpenStream(
            PaStreamParameters?inputParameters, PaStreamParameters?outputParameters,
            double sampleRate, int framesPerBuffer, PaStreamFlags streamFlags,
            PaStreamCallback streamCallback, object userData)
        {
            var streamCallbackContainer = new StreamCallbackContainer(
                streamCallback,
                inputParameters.HasValue ? inputParameters.Value.sampleFormat : 0,
                outputParameters.HasValue ? outputParameters.Value.sampleFormat : 0,
                inputParameters.HasValue ? inputParameters.Value.channelCount : 0,
                outputParameters.HasValue ? outputParameters.Value.channelCount : 0,
                userData);
            IntPtr stream;

            unsafe
            {
                PaStreamParameters inputParametersTemp, outputParametersTemp;
                IntPtr             inputParametersPtr = IntPtr.Zero;
                if (inputParameters.HasValue)
                {
                    inputParametersPtr = new IntPtr(&inputParametersTemp);
                    Marshal.StructureToPtr <PaStreamParameters>(inputParameters.Value, inputParametersPtr, false);
                }
                IntPtr outputParametersPtr = IntPtr.Zero;
                if (outputParameters.HasValue)
                {
                    outputParametersPtr = new IntPtr(&outputParametersTemp);
                    Marshal.StructureToPtr <PaStreamParameters>(outputParameters.Value, outputParametersPtr, false);
                }
                PaErrorException.ThrowIfError(Pa_OpenStream(
                                                  new IntPtr(&stream),
                                                  inputParametersPtr, outputParametersPtr,
                                                  sampleRate, (unsigned_long_t)framesPerBuffer, streamFlags,
                                                  streamCallbackContainer.Callback, IntPtr.Zero));
            }
            return(new PaStream(
                       stream, streamCallbackContainer,
                       inputParameters.HasValue ? inputParameters.Value.sampleFormat : 0,
                       outputParameters.HasValue ? outputParameters.Value.sampleFormat : 0,
                       inputParameters.HasValue ? inputParameters.Value.channelCount : 0,
                       outputParameters.HasValue ? outputParameters.Value.channelCount : 0));
        }
Beispiel #3
0
        public PaStream OpenDefaultStream(
            int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat,
            double sampleRate, int framesPerBuffer, PaStreamFlags streamFlags,
            PaStreamCallback streamCallback, object userData)
        {
            var streamCallbackContainer = new StreamCallbackContainer(
                streamCallback,
                sampleFormat, sampleFormat,
                numInputChannels, numOutputChannels, userData);
            IntPtr stream;

            unsafe
            {
                PaErrorException.ThrowIfError(Pa_OpenDefaultStream(
                                                  new IntPtr(&stream),
                                                  numInputChannels, numOutputChannels, sampleFormat,
                                                  sampleRate, (unsigned_long_t)framesPerBuffer, streamFlags,
                                                  streamCallbackContainer.Callback, IntPtr.Zero));
            }
            return(new PaStream(stream, streamCallbackContainer));
        }
Beispiel #4
0
 internal PaStream(IntPtr stream, StreamCallbackContainer streamCallbackContainer)
 {
     this.stream = stream;
     this.streamCallbackContainer = streamCallbackContainer;
 }