Faster tone

Status
Not open for further replies.

valdez

New member
I was looking at the tone detection and noticed if I went to 32 bit math as opposed to the 64 bit, the execution was ~ 1/4 the time.
(I have a small dynamic rage ~ less than 512)

If one reduces bits in the coefficient

eg:
coef = (int32_t)(cos((double)freq
* (2.0 * 3.14159265358979323846 / samples_per_second))
* (double)32767.999);

one would have to also adjust multiplication (and power calculation) as well..

something like :
q0 = (wave_data) + ( ((int32_t)coef * (int32_t) q1)>>14) - q2;


Any suggestions on selecting the correct integer math for 32 bit operation (at the expense of reducing the dynamic range)?
 
If one was interested in getting better performance, would there be a way to evaluate a safe minimum frequency (one could down sample if needed, but one would also need to add a high pass filter to be sure one was safe)?
 
Status
Not open for further replies.
Back
Top