multichannel output working now
This commit is contained in:
parent
4cb94e168d
commit
6830452b9c
2 changed files with 6 additions and 26 deletions
|
@ -92,8 +92,10 @@ end
|
|||
# end
|
||||
|
||||
function sinktask(sink::PortAudioSink)
|
||||
println("starting sink task")
|
||||
buffer = Array(eltype(sink), sink.bufsize, nchannels(sink))
|
||||
# as of portaudio 19.20140130 (which is the HomeBrew version as of 20160319)
|
||||
# noninterleaved data is not supported for the read/write interface on OSX
|
||||
transbuf = Array(eltype(sink), nchannels(sink), sink.bufsize)
|
||||
try
|
||||
while sink.open
|
||||
total = Pa_GetStreamWriteAvailable(sink.stream)
|
||||
|
@ -101,8 +103,8 @@ function sinktask(sink::PortAudioSink)
|
|||
while(written < total)
|
||||
tocopy = min(size(buffer, 1), total - written)
|
||||
read!(sink.ringbuf, sub(buffer, 1:tocopy, :))
|
||||
# TODO: this will only work for mono streams
|
||||
Pa_WriteStream(sink.stream, buffer, tocopy, true)
|
||||
transpose!(transbuf, buffer)
|
||||
Pa_WriteStream(sink.stream, transbuf, tocopy, true)
|
||||
written += tocopy
|
||||
end
|
||||
sleep(0.005)
|
||||
|
@ -111,7 +113,6 @@ function sinktask(sink::PortAudioSink)
|
|||
warn("PortAudio Sink Task died with exception: $ex")
|
||||
Base.show_backtrace(STDOUT, catch_backtrace())
|
||||
end
|
||||
println("sink task finished")
|
||||
end
|
||||
|
||||
# function sourcetask(sink::PortAudioSource)
|
||||
|
|
|
@ -27,36 +27,15 @@ const paInt8 = PaSampleFormat(0x10)
|
|||
const paUInt8 = PaSampleFormat(0x20)
|
||||
const paNonInterleaved = PaSampleFormat(0x80000000)
|
||||
|
||||
const fmt_to_type = Dict{PaSampleFormat, Type}(
|
||||
1 => Float32,
|
||||
2 => Int32,
|
||||
# 4 => Int24,
|
||||
8 => Int16,
|
||||
16 => Int8,
|
||||
32 => UInt8
|
||||
)
|
||||
|
||||
# const type_to_fmt = Dict{Type, PaSampleFormat}(
|
||||
# Float32 => 1 | paNonInterleaved,
|
||||
# Int32 => 2 | paNonInterleaved,
|
||||
# # Int24 => 4 | paNonInterleaved,
|
||||
# Int16 => 8 | paNonInterleaved,
|
||||
# Int8 => 16 | paNonInterleaved,
|
||||
# UInt8 => 3 | paNonInterleaved
|
||||
# )
|
||||
#
|
||||
|
||||
# TODO: temporary for testing mono
|
||||
const type_to_fmt = Dict{Type, PaSampleFormat}(
|
||||
Float32 => 1,
|
||||
Int32 => 2,
|
||||
# Int24 =>,
|
||||
# Int24 => 4,
|
||||
Int16 => 8,
|
||||
Int8 => 16,
|
||||
UInt8 => 3
|
||||
)
|
||||
|
||||
|
||||
function Pa_Initialize()
|
||||
err = ccall((:Pa_Initialize, libportaudio), PaError, ())
|
||||
handle_status(err)
|
||||
|
|
Loading…
Reference in a new issue