Version 2 (modified by bennylp, 16 years ago) (diff) |
---|
Analyzing the PJMEDIA Tone Generator Algorithms Performance
This article presents the performance analysis of various back-end algorithms of the tone generator that are implemented in PJMEDIA. We will measure the performance in both speed and accuracy terms.
The Algorithms
The tone generator (tonegen.c) supports several algorithms, and since version 1.0-rc3, the use of these algorithms is controlled by PJMEDIA_TONEGEN_ALG setting:
- PJMEDIA_TONEGEN_SINE: The good-old generation using math's sine(), floating point. This has very good precision but it's the slowest and requires floating point support and linking with the math library.
- PJMEDIA_TONEGEN_FLOATING_POINT: Floating point approximation of sine(). This has relatively good precision and much faster than plain sine(), but it requires floating-point support and linking with the math library.
- PJMEDIA_TONEGEN_FIXED_POINT_CORDIC (new in 1.0-rc3): Fixed point using sine signal generated by Cordic algorithm. This algorithm can be tuned to provide balance between precision and performance by tuning the PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP setting, and may be suitable for platforms that lack floating-point support.
- PJMEDIA_TONEGEN_FAST_FIXED_POINT: Fast fixed point using some approximation to generate sine waves. The tone generated by this algorithm is not very precise, however the algorithm is very fast.
Accuracy
For the accuracy test, we setup the tone generator to generate digit A from DTMF, with frequencies of 697 and 1209. We then saved the tone to a WAV file and analyzed the frequency using CoolEdit (now becomes Adobe Audition).
This is simple to do with pjsua really:
pjsua --play-tone 697,1209,200,2000 --rec-file tone.wav
then issue these commands:
cc 1 2 sleep 5000 cd 1 2 q
And here is the graphics from the frequency analysis.
Attachments (8)
- cordic7.JPG (37.1 KB) - added by bennylp 16 years ago.
- cordic8.JPG (37.4 KB) - added by bennylp 16 years ago.
- cordic10.JPG (36.2 KB) - added by bennylp 16 years ago.
- fast-fixed-point.JPG (37.1 KB) - added by bennylp 16 years ago.
- float.JPG (35.0 KB) - added by bennylp 16 years ago.
- sine.JPG (35.8 KB) - added by bennylp 16 years ago.
- cordic16.JPG (35.7 KB) - added by bennylp 16 years ago.
- cordic12.JPG (35.8 KB) - added by bennylp 16 years ago.
Download all attachments as: .zip