Public interface
PortAudio.PortAudioStream
— TypePortAudioStream(input_channels = 2, output_channels = 2; options...)
+Public interface · PortAudio.jl Public interface
PortAudio.PortAudioStream
— TypePortAudioStream(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 streamflags = PortAudio.paNoFlag
: PortAudio flagsframes_per_buffer = 128
: the number of frames per bufferinput_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
sourcePortAudio.devices
— Methoddevices()
List the devices available on your system. Devices will be shown with their internal name, and maximum input and output channels.
sourceSettings
This document was generated with Documenter.jl version 0.27.10 on Monday 10 January 2022. Using Julia version 1.6.5.
+2 s
PortAudio.devices
— Methoddevices()
List the devices available on your system. Devices will be shown with their internal name, and maximum input and output channels.