PortAudioStream(input_device, output_device, input_channels = 2, output_channels = 2; options...)</code></pre><p>Audio devices can either be <code>PortAudioDevice</code> instances as returned by <ahref="#PortAudio.devices-Tuple{}"><code>devices</code></a>, or strings with the device name as reported by the operating system. Set <code>input_channels</code> to <code>0</code> for an output only stream; set <code>output_channels</code> to <code>0</code> for an input only steam. If you pass the function <code>maximum</code> instead of a number of channels, use the maximum channels allowed by the corresponding device. If a single <code>duplex_device</code> is given, it will be used for both input and output. If no devices are given, the system default devices will be used.</p><p>The <code>PortAudioStream</code> type supports all the stream and buffer features defined <ahref="https://github.com/JuliaAudio/SampledSignals.jl">SampledSignals.jl</a> by default. For example, if you load SampledSignals with <code>using SampledSignals</code> you can read 5 seconds to a buffer with <code>buf = read(stream, 5s)</code>, regardless of the sample rate of the device. <code>write(stream, stream)</code> will set up a loopback that will read from the input and play it back on the output.</p><p>Options:</p><ul><li><code>adjust_channels = false</code>: If set to <code>true</code>, if either <code>input_channels</code> or <code>output_channels</code> exceeds the corresponding device maximum, adjust down to the maximum.</li><li><code>call_back = C_NULL</code>: The PortAudio call-back function. Currently, passing anything except <code>C_NULL</code> is unsupported.</li><li><code>eltype = Float32</code>: Sample type of the audio stream</li><li><code>flags = PortAudio.paNoFlag</code>: PortAudio flags</li><li><code>frames_per_buffer = 128</code>: the number of frames per buffer</li><li><code>input_info = C_NULL</code>: host API specific stream info for the input device. Currently, passing anything except <code>C_NULL</code> is unsupported.</li><li><code>latency = nothing</code>: Requested latency. Stream could underrun when too low, consider using the defaults. If left as <code>nothing</code>, use the defaults below:<ul><li>For input/output only streams, use the corresponding device's default high latency.</li><li>For duplex streams, use the max of the default high latency of the input and output devices.</li></ul></li><li><code>output_info = C_NULL</code>: host API specific stream info for the output device. Currently, passing anything except <code>C_NULL</code> is unsupported.</li><li><code>reader = PortAudio.SampledSignalsReader()</code>: the scribe that will read input. Defaults to a <ahref="internals/#PortAudio.SampledSignalsReader"><code>PortAudio.SampledSignalsReader</code></a>. Users can pass custom scribes; see <ahref="internals/#PortAudio.Scribe"><code>PortAudio.Scribe</code></a>.</li><li><code>samplerate = nothing</code>: Sample rate. If left as <code>nothing</code>, use the defaults below:<ul><li>For input/output only streams, use the corresponding device's default sample rate.</li><li>For duplex streams, use the default sample rate if the default sample rates for the input and output devices match, otherwise throw an error.</li></ul></li><li><code>warn_xruns = true</code>: Display a warning if there is a stream overrun or underrun, which often happens when Julia is compiling, or with a particularly large GC run. Only affects duplex streams.</li><li><code>writer = PortAudio.SampledSignalsWriter()</code>: the scribe that will write output. Defaults to a <ahref="internals/#PortAudio.SampledSignalsReader"><code>PortAudio.SampledSignalsReader</code></a>. Users can pass custom scribes; see <ahref="internals/#PortAudio.Scribe"><code>PortAudio.Scribe</code></a>.</li></ul><p><strong>Examples:</strong></p><p>Set up an audio pass-through from microphone to speaker</p><pre><codeclass="language-julia hljs">julia> using PortAudio, SampledSignals
end</code></pre><p>Use <code>do</code> syntax to auto-close the stream</p><pre><codeclass="language-julia hljs">julia> using PortAudio, SampledSignals
julia> PortAudioStream(2, 2; warn_xruns = false) do stream
write(stream, stream, 2s)
end</code></pre><p>Open devices by name</p><pre><codeclass="language-julia hljs">using PortAudio, SampledSignals
PortAudioStream("Built-in Microph", "Built-in Output"; warn_xruns = false) do stream
write(stream, stream, 2s)
end
2 s</code></pre><p>Record 10 seconds of audio and save to an ogg file</p><pre><codeclass="language-julia hljs">julia> using PortAudio, SampledSignals, LibSndFile
julia> PortAudioStream(2, 0; warn_xruns = false) do stream
2 s</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/JuliaAudio/PortAudio.jl/blob/06c6fd04959975644e308b23138313bfcfde4765/src/PortAudio.jl#L630-L720">source</a></section></article><articleclass="docstring"><header><aclass="docstring-binding"id="PortAudio.devices-Tuple{}"href="#PortAudio.devices-Tuple{}"><code>PortAudio.devices</code></a> — <spanclass="docstring-category">Method</span></header><section><div><pre><codeclass="language-julia hljs">devices()</code></pre><p>List the devices available on your system. Devices will be shown with their internal name, and maximum input and output channels.</p></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/JuliaAudio/PortAudio.jl/blob/06c6fd04959975644e308b23138313bfcfde4765/src/PortAudio.jl#L232-L237">source</a></section></article></article><navclass="docs-footer"><aclass="docs-footer-nextpage"href="internals/">Internals »</a><divclass="flexbox-break"></div><pclass="footer-message">Powered by <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <ahref="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><divclass="modal"id="documenter-settings"><divclass="modal-background"></div><divclass="modal-card"><headerclass="modal-card-head"><pclass="modal-card-title">Settings</p><buttonclass="delete"></button></header><sectionclass="modal-card-body"><p><labelclass="label">Theme</label><divclass="select"><selectid="documenter-themepicker"><optionvalue="documenter-light">documenter-light</option><optionvalue="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.22 on <spanclass="colophon-date"title="Sunday 24 July 2022 15:58">Sunday 24 July 2022</span>. Using Julia version 1.6.7.</p></section><footerclass="modal-card-foot"></footer></div></div></div></body></html>