Stereo audio in PortAudio.jl

How do I play stereo audio using PortAudio?

Here, I have two tones s1 and s2. I want to play one on the right speaker, on on the left. This plays only s1 in both speakers.

using PortAudio

s1 = 2 * pi * (1 : 2 * 12_000) / 12_000 |> o-> cos.(o * 440)
s2 = 2 * pi * (1 : 2 * 12_000) / 12_000 |> o-> cos.(o * 660)

PortAudioStream(0, 2; samplerate=12_000) do stream
    write(stream, s1)
end

Yeah the docs aren’t very fleshed out. I looked through some of their examples and tests, maybe it’s possible with a Nx2 Matrix? As in each column has each channel, like hcat(s1, s2).

That seems to work. Thanks.

1 Like