Skip to main content

Topic: Multichannel Programming (Read 2805 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • dlembed83
  • [*]
Multichannel Programming
In my application, I want four buffers representing the four speakers individually.I will fill up each channel(buffer) with different data (dynamically at run time,not statically), then send them to a four-channel soundcard.How can I do?
I find DirectSound only surport playing multichannel media file .Is KS ok?If so ,could you please suggest me some references?

Many thanks.

Multichannel Programming
Reply #1
Something to try may be to just open the device 4 times. Use a single-channel format for each device, assigning the correct speaker to each "device" you opened.

The windows 'mixer' will take care of interleaving the data then.

  • Jasper
  • [*][*][*]
Multichannel Programming
Reply #2
Practically all soundcard API's I know of use interleaved buffers, so I don't think you have any other option than to interleave the audio data before you send it to the soundcard (and as that isn't very hard or slow it probably won't give a lot of problems).
Opening the device four times does not sound like a good idea to me, it sounds like a lot of hassle and you'll have to interleave the signal anyhow (only now you need to do it four times and with zeroes in between).
Of course it is an entirely different matter if your soundcard allows you to open all four channels separately (it might through ASIO, not sure). But even then I would still recommend simply interleaving the sound yourself, unless you'd have some special reason not to (what that would be though?).

  • dlembed83
  • [*]
Multichannel Programming
Reply #3
How can I use soundcard API, surpassing the DirectSound and the like?I'm thinking about writing a four-channel wave file, with DS playing back the wave synchronously.Could you please suggest me some soundcard with the very feature you mentioned?

  • Jasper
  • [*][*][*]
Multichannel Programming
Reply #4
With soundcard API I meant API's like DirectSound, Windows MME (waveIn/waveOut), ASIO, etc. To play a four channel wave file you just have to open a device which supports four channels (a lot of modern soundcards support this) or two stereo devices. The sound data in a wave file is also interleaved, so you will only have to do something with it if you can't open a single device with four channels, if that's the case you'll have to send two channels to one device and the other two to another device.
If you are unfamiliar with how to do this kind of thing I would suggest looking at some of the examples in the MSDN Library (http://msdn.microsoft.com/library/).
You might also want to consider looking at PortAudio (http://www.portaudio.com/), its MME implementation has support for opening more than one device simultaniously (in such a way that you will can pretend it's a single device).

Also, if you are only interested in playing a wave file you might get by with using PlaySound (look for it in the MSDN Library). I believe this function will send the sound to the Windows default output device.

  • dlembed83
  • [*]
Multichannel Programming
Reply #5
Thanks , Jasper. I'm trying that.

  • dlembed83
  • [*]
Multichannel Programming
Reply #6
Yes , it works ,with a buffer created with WAVEFORMATENTENSIBLE.
Thanks a lot.