adds ability to open device by name

This commit is contained in:
Spencer Russell 2016-03-20 02:12:21 -04:00
parent 738c4cff4b
commit e51c980f24

View file

@ -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