# Stereo audio in PortAudio.jl

**URL:** https://discourse.julialang.org/t/stereo-audio-in-portaudio-jl/98455
**Category:** New to Julia
**Created:** [May 8, 2023, 2:27am UTC](https://discourse.julialang.org/t/stereo-audio-in-portaudio-jl/98455 "2023-05-08T02:27:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sadish-d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sadish-d/32/48058_2.png) [@sadish-d](https://discourse.julialang.org/u/sadish-d)
#### Post date: [May 8, 2023, 2:27am UTC](https://discourse.julialang.org/t/stereo-audio-in-portaudio-jl/98455/1 "2023-05-08T02:27:47Z")

</div>

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.

```julia
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

```

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [May 8, 2023, 3:42am UTC](https://discourse.julialang.org/t/stereo-audio-in-portaudio-jl/98455/2 "2023-05-08T03:42:51Z")

</div>

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)`.

---

<div class="post-metadata">

### Author: ![sadish-d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sadish-d/32/48058_2.png) [@sadish-d](https://discourse.julialang.org/u/sadish-d)
#### Post date: [May 8, 2023, 3:52am UTC](https://discourse.julialang.org/t/stereo-audio-in-portaudio-jl/98455/3 "2023-05-08T03:52:46Z")

</div>

That seems to work. Thanks.
