[Openal] AL_FORMAT Types and Meanings

Daniel PEACOCK dpeacock at creativelabs.com
Fri Oct 2 02:02:51 PDT 2009





Hi Ümit,

What is your goal with this algorithm?   Are you trying to extract
particular channels from a wavefile, or are you attempting to mix several
channels into one or more channels (downmixing)?

>> I mean for example we have 16 bit sampled 5.1 sound which will be played
only front left

e..g. Does this mean you want to hear the front-left channel only (and
remove the other 5 channels of data), or do you want to mix all 6 channels
together into a mono file?

Dan
Creative Labs (UK) Ltd.

Notice
The information in this message is confidential and may be legally
privileged.  It is intended solely for the addressee.  Access to this
message by anyone else is unauthorized.  If you are not the intended
recipient,  any disclosure,  copying or distribution of the message,  or
any action taken by you in reliance on it,  is prohibited and may be
unlawful.  If you have received this message in error,  please delete it
and contact the sender immediately.  Thank you.

Creative Labs UK Ltd company number 2658256 registered in England and Wales
at 79 Knightsbridge, London SW1X 7RB



                                                                           
             Ümit Uzun                                                     
             <umituzun84 at gmail                                             
             .com>                                                      To 
             Sent by:                  OpenAL                              
             openal-bounces at op         <openal at opensource.creative.com>    
             ensource.creative                                          cc 
             .com                                                          
                                                                   Subject 
                                       [Openal] AL_FORMAT Types and        
             10/01/2009 02:17          Meanings                            
             PM                                                            
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hi All,

I have needed to control every channel manually so I have injected
Framework.cpp of OpenAL SDK.
I added

template<typename T> T *LoadData(const T *data, int size, const char
*channels, short channelType)
{     size /= sizeof(T);      T *multData = new T[size * channelType];  
for(int i = 0; i < size; i++)     {         for(int k = 0; k < channelType;
k++)         {             multData[i * channelType + k] = channels[k] == '1'
? data[i] : 0;         }     }      return multData;
}

const char *channels; // For example 110010
// Find channelType by counting channels value for example 5.1's
channelType == 6
short channelType;
for(channelType = 0; channels[channelType] != NULL; channelType++);
if(fmt.wBitsPerSample == 16)   // assumes 16-bit short
{     ALshort *data = LoadData((const ALshort*)pData, iDataSize, channels,
channelType);     switch(channelType)     {     case 2: 
alBufferData(uiBufferID, alGetEnumValue("AL_FORMAT_MONO16"), data,
iDataSize * channelType, iFrequency);     break;     case 4: 
alBufferData(uiBufferID, alGetEnumValue("AL_FORMAT_QUAD16"), data,
iDataSize * channelType, iFrequency);     break;     case 6: 
alBufferData(uiBufferID, alGetEnumValue("AL_FORMAT_51CHN16"), data,
iDataSize * channelType, iFrequency);     break;     case 7: 
alBufferData(uiBufferID, alGetEnumValue("AL_FORMAT_61CHN16"), data,
iDataSize * channelType, iFrequency);     break;     case 8: 
alBufferData(uiBufferID, alGetEnumValue("AL_FORMAT_71CHN16"), data,
iDataSize * channelType, iFrequency);     break;     }     delete[] data;
}

instead of
alBufferData(uiBufferID, eBufferFormat, pData, iDataSize, iFrequency);
command.

With this changing I can specify each channel for related buffer's will be
played.
I specify each sounds channel value by;
<!-- Channels Enum for 5.1 123456   -->
<!--   1 : Front Left      Speaker  -->
<!--   2 : Front Right     Speaker  -->
<!--   3 : Front Center    Speaker  -->
<!--   4 : Low   Frequency Speaker  -->
<!--   5 : Back  Left      Speaker  -->
<!--   6 : Back  Right     Speaker  -->

In LoadData template function I create the multData sound buffer data in
this sequence. I mean for example we have 16 bit sampled 5.1 sound which
will be played only front left(this sound's channels:100000) I send the raw
pData sound buffer to LoadData function and multiplex this sound data for 6
channel in given sequence order. Create new multData array for 6 channel
and start to set this sound array firstly Front Left and Front Right and so
on.
So do you think this operation right or now?

With all those changing I want to control channels. Because I have some
sounds which only must played on rear left channel and some sounds only
front right and etc.
Do you think this approach is suitable?

And another question I want to handle 2.0 speaker like 5.1 and as you can
see I use AL_FORMAT_MONO16 for 2 channel. Do you think it's right or not?
Should I use AL_FORMAT_STEREO16? Or which enumeration do I need?

If I am so complex, please ask me question to lead you right direction.
Regards.

Ümit Uzun_______________________________________________
Openal mailing list
Openal at opensource.creative.com
http://opensource.creative.com/mailman/listinfo/openal

ForwardSourceID:NT000754CE




More information about the Openal mailing list