Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > buffer "BYTE" t...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 43656 of 48044
Post > Topic >>

buffer "BYTE" to "short" and viceversa

by "tarlino" <tarlino@[EMAIL PROTECTED] > Mar 4, 2008 at 10:06 AM

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!!
 




 1 Posts in Topic:
buffer "BYTE" to "short" and viceversa
"tarlino" <t  2008-03-04 10:06:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 22:32:02 CDT 2008.