diff --git a/dev/assets/documenter.js b/dev/assets/documenter.js index 6d0b785..a1ada46 100644 --- a/dev/assets/documenter.js +++ b/dev/assets/documenter.js @@ -70,6 +70,67 @@ $(document).ready(function() { hljs.highlightAll(); }) +}) +//////////////////////////////////////////////////////////////////////////////// +require([], function() { +function addCopyButtonCallbacks() { + for (const el of document.getElementsByTagName("pre")) { + const button = document.createElement("button"); + button.classList.add("copy-button", "fas", "fa-copy"); + el.appendChild(button); + + const success = function () { + button.classList.add("success", "fa-check"); + button.classList.remove("fa-copy"); + }; + + const failure = function () { + button.classList.add("error", "fa-times"); + button.classList.remove("fa-copy"); + }; + + button.addEventListener("click", function () { + copyToClipboard(el.innerText).then(success, failure); + + setTimeout(function () { + button.classList.add("fa-copy"); + button.classList.remove("success", "fa-check", "fa-times"); + }, 5000); + }); + } +} + +function copyToClipboard(text) { + // clipboard API is only available in secure contexts + if (window.navigator && window.navigator.clipboard) { + return window.navigator.clipboard.writeText(text); + } else { + return new Promise(function (resolve, reject) { + try { + const el = document.createElement("textarea"); + el.textContent = text; + el.style.position = "fixed"; + el.style.opacity = 0; + document.body.appendChild(el); + el.select(); + document.execCommand("copy"); + + resolve(); + } catch (err) { + reject(err); + } finally { + document.body.removeChild(el); + } + }); + } +} + +if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", addCopyButtonCallbacks); +} else { + addCopyButtonCallbacks(); +} + }) //////////////////////////////////////////////////////////////////////////////// require(['jquery', 'headroom', 'headroom-jquery'], function($, Headroom) { diff --git a/dev/assets/themes/documenter-dark.css b/dev/assets/themes/documenter-dark.css index 65e34e4..d6555f9 100644 --- a/dev/assets/themes/documenter-dark.css +++ b/dev/assets/themes/documenter-dark.css @@ -7179,6 +7179,35 @@ html.theme--documenter-dark { visibility: visible; } html.theme--documenter-dark .docs-light-only { display: none !important; } + html.theme--documenter-dark pre { + position: relative; } + html.theme--documenter-dark pre .copy-button { + opacity: 0.2; + transition: opacity 0.2s; + position: absolute; + right: 0em; + top: 0em; + padding: 0.5em; + width: 2.5em; + height: 2.5em; + background: transparent; + border: none; + font-family: "Font Awesome 5 Free"; + color: #fff; + cursor: pointer; + text-align: center; } + html.theme--documenter-dark pre .copy-button:focus, html.theme--documenter-dark pre .copy-button:hover { + opacity: 1; + background: rgba(255, 255, 255, 0.1); + color: #1abc9c; } + html.theme--documenter-dark pre .copy-button.success { + color: #259a12; + opacity: 1; } + html.theme--documenter-dark pre .copy-button.error { + color: #cb3c33; + opacity: 1; } + html.theme--documenter-dark pre:hover .copy-button { + opacity: 1; } html.theme--documenter-dark .admonition { background-color: #282f2f; border-style: solid; diff --git a/dev/assets/themes/documenter-light.css b/dev/assets/themes/documenter-light.css index 14f6a0e..aec0ad2 100644 --- a/dev/assets/themes/documenter-light.css +++ b/dev/assets/themes/documenter-light.css @@ -7114,6 +7114,36 @@ h1:hover .docs-heading-anchor-permalink, h2:hover .docs-heading-anchor-permalink .docs-dark-only { display: none !important; } +pre { + position: relative; } + pre .copy-button { + opacity: 0.2; + transition: opacity 0.2s; + position: absolute; + right: 0em; + top: 0em; + padding: 0.5em; + width: 2.5em; + height: 2.5em; + background: transparent; + border: none; + font-family: "Font Awesome 5 Free"; + color: #222222; + cursor: pointer; + text-align: center; } + pre .copy-button:focus, pre .copy-button:hover { + opacity: 1; + background: rgba(34, 34, 34, 0.1); + color: #2e63b8; } + pre .copy-button.success { + color: #259a12; + opacity: 1; } + pre .copy-button.error { + color: #cb3c33; + opacity: 1; } + pre:hover .copy-button { + opacity: 1; } + .admonition { background-color: #b5b5b5; border-style: solid; diff --git a/dev/index.html b/dev/index.html index bb6c106..eb2b108 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,5 +1,5 @@ -Public interface · PortAudio.jl

Public interface

PortAudio.PortAudioStreamType
PortAudioStream(input_channels = 2, output_channels = 2; options...)
+Public interface · PortAudio.jl

Public interface

PortAudio.PortAudioStreamType
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...)

Audio devices can either be PortAudioDevice instances as returned by devices, or strings with the device name as reported by the operating system. Set input_channels to 0 for an output only stream; set output_channels to 0 for an input only steam. If you pass the function maximum instead of a number of channels, use the maximum channels allowed by the corresponding device. If a single duplex_device is given, it will be used for both input and output. If no devices are given, the system default devices will be used.

The PortAudioStream type supports all the stream and buffer features defined SampledSignals.jl by default. For example, if you load SampledSignals with using SampledSignals you can read 5 seconds to a buffer with buf = read(stream, 5s), regardless of the sample rate of the device. write(stream, stream) will set up a loopback that will read from the input and play it back on the output.

Options:

  • adjust_channels = false: If set to true, if either input_channels or output_channels exceeds the corresponding device maximum, adjust down to the maximum.
  • call_back = C_NULL: The PortAudio call-back function. Currently, passing anything except C_NULL is unsupported.
  • eltype = Float32: Sample type of the audio stream
  • flags = PortAudio.paNoFlag: PortAudio flags
  • frames_per_buffer = 128: the number of frames per buffer
  • input_info = C_NULL: host API specific stream info for the input device. Currently, passing anything except C_NULL is unsupported.
  • latency = nothing: Requested latency. Stream could underrun when too low, consider using the defaults. If left as nothing, use the defaults below:
    • For input/output only streams, use the corresponding device's default high latency.
    • For duplex streams, use the max of the default high latency of the input and output devices.
  • output_info = C_NULL: host API specific stream info for the output device. Currently, passing anything except C_NULL is unsupported.
  • reader = PortAudio.SampledSignalsReader(): the scribe that will read input. Defaults to a PortAudio.SampledSignalsReader. Users can pass custom scribes; see PortAudio.Scribe.
  • samplerate = nothing: Sample rate. If left as nothing, use the defaults below:
    • For input/output only streams, use the corresponding device's default sample rate.
    • For duplex streams, use the default sample rate if the default sample rates for the input and output devices match, otherwise throw an error.
  • warn_xruns = true: 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.
  • writer = PortAudio.SampledSignalsWriter(): the scribe that will write output. Defaults to a PortAudio.SampledSignalsReader. Users can pass custom scribes; see PortAudio.Scribe.

Examples:

Set up an audio pass-through from microphone to speaker

julia> using PortAudio, SampledSignals
 
@@ -24,4 +24,4 @@ julia> PortAudioStream(2, 0; warn_xruns = false) do stream
             buf = read(stream, 10s)
             save(joinpath(tempname(), ".ogg"), buf)
         end
-2 s
source
PortAudio.devicesMethod
devices()

List the devices available on your system. Devices will be shown with their internal name, and maximum input and output channels.

source
+2 s
source
PortAudio.devicesMethod
devices()

List the devices available on your system. Devices will be shown with their internal name, and maximum input and output channels.

source
diff --git a/dev/internals/index.html b/dev/internals/index.html index 2850a34..4516299 100644 --- a/dev/internals/index.html +++ b/dev/internals/index.html @@ -1,2 +1,2 @@ -Internals · PortAudio.jl

Internals

+Internals · PortAudio.jl

Internals

diff --git a/dev/search/index.html b/dev/search/index.html index e7aabe1..bf9f63e 100644 --- a/dev/search/index.html +++ b/dev/search/index.html @@ -1,2 +1,2 @@ -Search · PortAudio.jl

Loading search...

    +Search · PortAudio.jl

    Loading search...