- Timestamp:
- Mar 11, 2008 8:50:46 PM (17 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/config.h
r1813 r1859 486 486 487 487 /** 488 * Enable high quality of tone generation, the better quality will cost 489 * more CPU load. This is only applied to floating point enabled machines. 490 * 491 * By default it is enabled. 492 */ 493 #ifndef PJMEDIA_USE_HIGH_QUALITY_TONEGEN 494 # define PJMEDIA_USE_HIGH_QUALITY_TONEGEN 1 495 #endif 496 497 498 /** 488 499 * Enable support for SRTP media transport. This will require linking 489 500 * with libsrtp from the third_party directory. -
pjproject/trunk/pjmedia/src/pjmedia/tonegen.c
r1676 r1859 40 40 41 41 #if defined(PJ_HAS_FLOATING_POINT) && PJ_HAS_FLOATING_POINT!=0 42 /*43 * Default floating-point based tone generation using sine wave44 * generation from:45 * http://www.musicdsp.org/showone.php?id=10.46 * This produces good quality tone in relatively faster time than47 * the normal sin() generator.48 * Speed = 40.6 cycles per sample.49 */50 42 # include <math.h> 51 struct gen 52 { 53 DATA a, s0, s1; 54 }; 55 56 # define GEN_INIT(var,R,F,A) var.a = (DATA) (2.0 * sin(M_PI * F / R)); \ 57 var.s0 = A; \ 58 var.s1 = 0 59 # define GEN_SAMP(val,var) var.s0 = var.s0 - var.a * var.s1; \ 60 var.s1 = var.s1 + var.a * var.s0; \ 61 val = (short) var.s0 62 63 64 #elif !defined(PJ_HAS_FLOATING_POINT) || PJ_HAS_FLOATING_POINT==0 43 44 # if defined(PJMEDIA_USE_HIGH_QUALITY_TONEGEN) && \ 45 PJMEDIA_USE_HIGH_QUALITY_TONEGEN!=0 46 47 /* 48 * This is the good old tone generator using sin(). 49 * Speed = 222.5 cycles per sample. 50 */ 51 struct gen 52 { 53 DATA add; 54 DATA c; 55 DATA vol; 56 }; 57 58 # define GEN_INIT(var,R,F,A) var.add = ((DATA)F)/R, var.c=0, var.vol=A 59 # define GEN_SAMP(val,var) val = (short)(sin(var.c * 2 * M_PI) * \ 60 var.vol); \ 61 var.c += var.add 62 63 # else 64 65 /* 66 * Default floating-point based tone generation using sine wave 67 * generation from: 68 * http://www.musicdsp.org/showone.php?id=10. 69 * This produces good quality tone in relatively faster time than 70 * the normal sin() generator. 71 * Speed = 40.6 cycles per sample. 72 */ 73 struct gen 74 { 75 DATA a, s0, s1; 76 }; 77 78 # define GEN_INIT(var,R,F,A) var.a = (DATA) (2.0 * sin(M_PI * F / R)); \ 79 var.s0 = A; \ 80 var.s1 = 0 81 # define GEN_SAMP(val,var) var.s0 = var.s0 - var.a * var.s1; \ 82 var.s1 = var.s1 + var.a * var.s0; \ 83 val = (short) var.s0 84 # endif 85 86 #else 87 65 88 /* 66 89 * Fallback algorithm when floating point is disabled. … … 100 123 var.c += var.add 101 124 102 103 #else104 # error "Should never get to this part"105 # include <math.h>106 /*107 * Should never really reach here, but anyway it's provided for reference.108 * This is the good old tone generator using sin().109 * Speed = 222.5 cycles per sample.110 */111 struct gen112 {113 DATA add;114 DATA c;115 DATA vol;116 };117 118 # define GEN_INIT(var,R,F,A) var.add = ((DATA)F)/R, var.c=0, var.vol=A119 # define GEN_SAMP(val,var) val = (short)(sin(var.c * 2 * M_PI) * var.vol);\120 var.c += var.add121 122 125 #endif 123 126
Note: See TracChangeset
for help on using the changeset viewer.