From e51c980f2491db574a38af750479adf339fa7a7f Mon Sep 17 00:00:00 2001 From: Spencer Russell Date: Sun, 20 Mar 2016 02:12:21 -0400 Subject: [PATCH] adds ability to open device by name --- src/PortAudio.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/PortAudio.jl b/src/PortAudio.jl index e08e798..db91f6a 100644 --- a/src/PortAudio.jl +++ b/src/PortAudio.jl @@ -75,6 +75,14 @@ function PortAudioSink(device::PortAudioDevice, eltype=Float32, sr=48000Hz, chan PortAudioSink(eltype, stream, sr, channels, bufsize) end +function PortAudioSink(devname::AbstractString, args...) + for d in devices() + if d.name == devname + return PortAudioSink(d, args...) + end + end +end + function PortAudioSource(eltype=Float32, sr=48000Hz, channels=2, bufsize=DEFAULT_BUFSIZE) stream = Pa_OpenDefaultStream(channels, 0, type_to_fmt[eltype], float(sr), bufsize) PortAudioSource(eltype, stream, sr, channels, bufsize) @@ -86,6 +94,14 @@ function PortAudioSource(device::PortAudioDevice, eltype=Float32, sr=48000Hz, ch PortAudioSource(eltype, stream, sr, channels, bufsize) end +function PortAudioSource(devname::AbstractString, args...) + for d in devices() + if d.name == devname + return PortAudioSource(d, args...) + end + end +end + # most of these methods are the same for Sources and Sinks, so define them on # the union