Fwd: [Openal] How can I play mono wav sound in specific channel?
Ümit Uzun
umituzun84 at gmail.com
Thu Apr 16 02:55:10 PDT 2009
---------- Forwarded message ----------
From: Ümit Uzun <umituzun84 at gmail.com>
Date: 2009/4/16
Subject: Re: [Openal] How can I play mono wav sound in specific channel?
To: Chris Robinson <chris.kcat at gmail.com>
Hi Chris;
>
>
> ALshort monodata[samples];
>
> you can fill it into a 7.1 buffer like this:
>
> ALshort data71[samples*8];
> for(int i = 0;i < samples;i++) {
> data71[i*8 + 0] = 0; // front-left
> data71[i*8 + 1] = 0; // front-right
> data71[i*8 + 2] = 0; // front-center
> data71[i*8 + 3] = 0; // lfe (sub-woofer)
> data71[i*8 + 4] = 0; // back-left
> data71[i*8 + 5] = 0; // back-right
> data71[i*8 + 6] = monodata[i]; // side-left
> data71[i*8 + 7] = monodata[i]; // side-right
> }
> alBufferData(bID, alGetEnumValue("AL_FORMAT_71CHN16"), data71,
> samples*8*sizeof(ALshort), frequency);
>
> I have look at the Framework and there is ALFWLoadWaveToBuffer;
ALboolean ALFWLoadWaveToBuffer(const char *szWaveFile, ALuint uiBufferID,
ALenum eXRAMBufferMode)
{
WAVEID WaveID;
ALint iDataSize, iFrequency;
ALenum eBufferFormat;
ALchar *pData;
ALboolean bReturn;
bReturn = AL_FALSE;
if(g_pWaveLoader)
{
if(SUCCEEDED(g_pWaveLoader->LoadWaveFile(szWaveFile, &WaveID)))
{
if((SUCCEEDED(g_pWaveLoader->GetWaveSize(WaveID, (unsigned
long*)&iDataSize))) &&
(SUCCEEDED(g_pWaveLoader->GetWaveData(WaveID,
(void**)&pData))) &&
(SUCCEEDED(g_pWaveLoader->GetWaveFrequency(WaveID, (unsigned
long*)&iFrequency))) &&
(SUCCEEDED(g_pWaveLoader->GetWaveALBufferFormat(WaveID,
&alGetEnumValue, (unsigned long*)&eBufferFormat))))
{
// Set XRAM Mode (ifapplication)
if(eaxSetBufferMode && eXRAMBufferMode)
{
eaxSetBufferMode(1, &uiBufferID, eXRAMBufferMode);
}
alGetError();
alBufferData(uiBufferID, eBufferFormat, pData, iDataSize,
iFrequency);
if(alGetError() == AL_NO_ERROR)
{
bReturn = AL_TRUE;
}
g_pWaveLoader->DeleteWaveFile(WaveID);
}
}
}
return bReturn;
}
You have given ALshort monodata[samples]; but in this code ALchar *pData;
This variable are same or not. because alBufferData takes void format and
ALchar is 1 byte and ALshort 2 byte. I can't get what should I do.
And you have talk about samples. I have an iDataSize, How I get samples
size? I have open up the sound properties and in Summary tab there is Audio
Sample Size is 16 bit information. Should I divide iDataSize to 16 and then
get samples value?
Thanks for valueable informations.
Best wishes.
--
Ümit Uzun
--
Ümit Uzun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20090416/a355ffbd/attachment-0001.html
More information about the Openal
mailing list