1

I have a 5.1 surround system that I am using to output some WAV files. I am coding in c++ a way to output the sound on one of the speakers.

basically is there any way I can say, x.wav file output sound only on the corner left speaker? like has a speaker generate an address?

drescherjm
  • 10,365
  • 5
  • 44
  • 64
  • 1
    dsound probably isn't the right tool for this but [XAudio2](https://learn.microsoft.com/en-us/windows/win32/xaudio2/xaudio2-introduction) probably is. – Mgetz Dec 13 '21 at 15:45

1 Answers1

0

Your best bet is probably to output a full 5.1 stream, but output zero samples for the channels you don't want to play. That's easy enough to do and will control which speaker is actually 'active'. A bit of experimentation should tell which which channel that corresponds to.

The output stream has the channels interleaved, BTW, so take that into account when writing your code.

Paul Sanders
  • 24,133
  • 4
  • 26
  • 48
  • 1
    While this would work, it's probably better to use the APIs for spatial audio. E.g. XAudio2 – Mgetz Dec 13 '21 at 15:46
  • @Mgetz Oh right, not familiar with that, thank you. – Paul Sanders Dec 13 '21 at 15:52
  • I am making a few assumptions in that recommendation: The OP is making a game or something where synthesizing 5.1/7.1 audio doesn't make sense (if they are just doing a speaker test it's better to synthesize). And they need precise control over which speaker at runtime. – Mgetz Dec 13 '21 at 15:55
  • @PaulSanders thank you very much. I will try to take that into account. But my problem is that I don't really know how to address a specific audio file to a specific speaker. like m_Buffer->PlaySound() where if we call the function PlaySound(), it already knows that setSpeakerconfig(xxxxx address) which represents one of the 5 speakers? – VINBEN zerozerosept Dec 13 '21 at 16:00
  • @VINBENzerozerosept you might be able to use [`IDirectSound3DBuffer`](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ee417960(v=vs.85)) but this is really a better job for XAudio2 and [X3DAudio](https://learn.microsoft.com/en-us/windows/win32/xaudio2/x3daudio) which are actively supported. DirectSound is considered very legacy and may not work as expected. – Mgetz Dec 13 '21 at 16:17
  • @VINBENzerozerosept Does [this](https://en.wikipedia.org/wiki/5.1_surround_sound#Channel_order) help? – Paul Sanders Dec 13 '21 at 16:36
  • @PaulSanders, thank you for your answer. i have tried IDirectSound3Dbuffer but it is not great, i will try to get familiar with xaudio2 and 3. thank you very much! – VINBEN zerozerosept Dec 14 '21 at 16:01