27 lines
11 KiB
HTML
27 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Public interface · PortAudio.jl</title><script data-outdated-warner src="assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.039/juliamono-regular.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.11/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href>PortAudio.jl</a></span></div><form class="docs-search" action="search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li class="is-active"><a class="tocitem" href>Public interface</a></li><li><a class="tocitem" href="internals/">Internals</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Public interface</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Public interface</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/JuliaAudio/PortAudio.jl/blob/master/docs/src/index.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Public-interface"><a class="docs-heading-anchor" href="#Public-interface">Public interface</a><a id="Public-interface-1"></a><a class="docs-heading-anchor-permalink" href="#Public-interface" title="Permalink"></a></h1><ul><li><a href="#PortAudio.PortAudioStream"><code>PortAudio.PortAudioStream</code></a></li><li><a href="#PortAudio.devices-Tuple{}"><code>PortAudio.devices</code></a></li></ul><article class="docstring"><header><a class="docstring-binding" id="PortAudio.PortAudioStream" href="#PortAudio.PortAudioStream"><code>PortAudio.PortAudioStream</code></a> — <span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia hljs">PortAudioStream(input_channels = 2, output_channels = 2; options...)
|
|
PortAudioStream(duplex_device, input_channels = 2, output_channels = 2; options...)
|
|
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 <a href="#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 <a href="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 <a href="internals/#PortAudio.SampledSignalsReader"><code>PortAudio.SampledSignalsReader</code></a>. Users can pass custom scribes; see <a href="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 <a href="internals/#PortAudio.SampledSignalsReader"><code>PortAudio.SampledSignalsReader</code></a>. Users can pass custom scribes; see <a href="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><code class="language-julia hljs">julia> using PortAudio, SampledSignals
|
|
|
|
julia> stream = PortAudioStream(2, 2; warn_xruns = false);
|
|
|
|
julia> try
|
|
# cancel with Ctrl-C
|
|
write(stream, stream, 2s)
|
|
finally
|
|
close(stream)
|
|
end</code></pre><p>Use <code>do</code> syntax to auto-close the stream</p><pre><code class="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><code class="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><code class="language-julia hljs">julia> using PortAudio, SampledSignals, LibSndFile
|
|
|
|
julia> PortAudioStream(2, 0; warn_xruns = false) do stream
|
|
buf = read(stream, 10s)
|
|
save(joinpath(tempname(), ".ogg"), buf)
|
|
end
|
|
2 s</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaAudio/PortAudio.jl/blob/497567e329412a59cc501df4963280ee90fa2503/src/PortAudio.jl#L600-L690">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="PortAudio.devices-Tuple{}" href="#PortAudio.devices-Tuple{}"><code>PortAudio.devices</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="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><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaAudio/PortAudio.jl/blob/497567e329412a59cc501df4963280ee90fa2503/src/PortAudio.jl#L221-L226">source</a></section></article></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="internals/">Internals »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.15 on <span class="colophon-date" title="Wednesday 23 March 2022 15:38">Wednesday 23 March 2022</span>. Using Julia version 1.6.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
|