=)
Here is a faster Power code to use in the dB to Linear module.
There is a problem with this code that I dont really understand. It only works in mono.
What happens is that, if the inputs are stream and you feed it with a packed stereo signal the output will only be the left channel. The right channel is gone some how.
Maybe this is a feature ? ... it is a very fast code. 211 cycles compared to the one you used that was about 800 or more cycles.
What I did to get around that problem was that I unpacked the signal and used 2 codes, one on each channel and then packed them again. This works and still saves at least 400 cycles.
Heres that code. Only in asm Im afraid.
- Code: Select all
streamin exp;
streamin bas;
streamout out;
//--- Variables...
float fBas = 0.0;
float fExp = 0.0;
float fAns = 0.0;
float fHlf = 0.5;
//--- Get the base/exponent values...
movaps xmm0,bas;
movaps fBas,xmm0;
movaps xmm0,exp;
movaps fExp,xmm0;
//--- base^exponent [0]...
fld fExp[0];
fld fBas[0];
fyl2x;
fld st(0);
fld fHlf[0];
fsub;
frndint;
fxch;
fld st(1);
fsub;
f2xm1;
fld1;
fadd;
fxch;
fld1;
fscale;
fstp st(1);
fmul;
fstp fAns[0];
//--- Move the answer into 'out'...
movaps xmm0,fAns;
movaps out,xmm0;
//--- Done!