Re: multi-channel buffers
Chris Robinson <[email protected]>
| Newsgroups | gmane.comp.lib.openal |
|---|---|
| Message-ID | <[email protected]> |
On Monday, May 10, 2010 6:37:45 am fxj_0330 wrote:
> hello,I want to use multi-channel buffers to output 5.1 audio.But,when I
> want to play on back- left sound is heard from front-left and vice-versa
> for the back-right.I have two questions about it:
> 1、From 《OpenAL Programming Guide》we know that "playing a buffer using the
> AL_FORMAT_51CHN16 format will require 6 free hardware voices".I really
> want to know what does"hardware voices"mean?
A hardware voice is, in a sense, a single source channel in hardware (1 is
needed for a mono sound, 2 for stereo, etc). Software implementations don't
tend to have an issue like this since mixing is done in software, and there's
virtually no limit to the number of channels it can mix (1 source is 1 source,
regardless of how many channels it plays).
> 2、I have implemented code as below,does it has something wrong?
>
>
> template<typename T>
> T *load_data(const T *data, int size)
> {
> size /= sizeof(T);
>
>
> T *data71 = new T[size*6];
> for(int i = 0;i < size;i++) {
>
>
> data71[i*6 + 0] = 0; // front-left
> data71[i*6 + 1] =0 ; // front-right
> data71[i*6 + 2] = 0; // front-center
> data71[i*6 + 3] = 0; // lfe (sub-woofer)
> data71[i*6 + 4] = data[i]; // back-left
> data71[i*6 + 5] = 0; // back-right
> }
>
>
> return data71;
> }
It looks okay to me, but be aware of a couple things:
1) 8-bit data uses 0x80 for "silence". If a char/byte array gets passed in,
the extra channels won't be cleared properly. For 16-bit, or 32-bit float,
however, 0 is fine.
2) You need to output using quad, 5.1, or 7.1 mode for a 5.1 source to play as
you're expecting. If you're outputting to stereo, then the rear speakers will
be remixed into the front speakers to be heard. How to change the output mode
depends on your OS and the implementation you're using.
_______________________________________________
Openal mailing list
[email protected]
http://opensource.creative.com/mailman/listinfo/openal