buffer "BYTE" to "short" and viceversa

T

tarlino

Hi! I'm play with the sound generation (c++ and directX).
Now I would like to manage same filter on my sample. But now I must to
convert my audio buffer "BYTE" (from DirectX) to an arry of "short" and
viceversa.
I found this source:
**************************************************************
double dPowI = ceil( log10( (double)iLen / ( ((double)wBitsPerSample / 8 )
+ wChannels - 1 ) ) / log10( 2.0 ) );
int iNearTwoPower = (int)pow( 2.0, dPowI );
short *psTemp = new short [iNearTwoPower];

short sSample = 0;
long lBit = 0;
int ik;
long l;
unsigned long dwTemp;
unsigned long dwDen = 0xFFFFFFFF >> ( 32 - wBitsPerSample );

for( l = lBit = 0; l < iNearTwoPower * wChannels; l++ )
{
if( lBit < iLen-1 )
{
dwTemp = 0xFFFFFFFF;
for( ik = 0; ik < wBitsPerSample / 8; ik++ )
( ( unsigned char * )&dwTemp )[ik] = pBuffer[lBit + ik];
lBit += ik;
sSample = ( short )MulDiv( dwTemp, 0xFFFF, dwDen );
}
if( l && !( l % wChannels ))
{
psTemp[lKont] = sSample;
lKont++;
if( sSample < iMinSample )
iMinSample = sSample;
if( abs( sSample ) > iMaxSample )
iMaxSample = abs( sSample );
}
}
**************************************************************

So I can convert my "pBuffer" to "psTemp" and I can filert it! :)
But...
Now, I don't know how I can re-convert "psTemp" to "pBuffer"

Someone can help me??

Thanks!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top