/// <summary> /// Determine if the device will support a given PCM format /// </summary> /// <param name="sampleFormat">The data format for PCM samples</param> /// <param name="channels">The number of channels</param> /// <param name="sampleRate">The number of frames/second the device will render/capture</param> /// <param name="suggestedLatency">The latency the device will attempt to match</param> /// <param name="asOutput">Marks if the device should be opened as an input or an output</param> /// <returns>True if the device supports this format, false otherwise</returns> public unsafe bool SupportsFormat(PortAudioSampleFormat sampleFormat, int channels, double sampleRate, TimeSpan suggestedLatency, bool asOutput) { PaStreamParameters *inputParams = default; PaStreamParameters *outputParams = default; var param = new PaStreamParameters { DeviceIndex = DeviceIndex, ChannelCount = channels, HostApiSpecificStreamInfo = IntPtr.Zero, SampleFormats = sampleFormat.SampleFormat, SuggestedLatency = new PaTime(suggestedLatency) }; if (asOutput) { outputParams = ¶m; } else { inputParams = ¶m; } return(Native.PortAudio.Pa_IsFormatSupported(inputParams, outputParams, sampleRate) >= PaErrorCode.NoError); }
unsafe public static extern PaError PA_OpenStream( out void *stream, PaStreamParameters *inputParameters, PaStreamParameters *outputParameters, double sampleRate, uint framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback streamCallback, int callback_id); // 0 for callback1, else callback2
unsafe public static extern PaError PA_IsFormatSupported( PaStreamParameters *inputParameters, PaStreamParameters *outputParameters, double sampleRate);