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