Ticket #494: ticket494.patch
File ticket494.patch, 3.5 KB (added by nanang, 17 years ago) |
---|
-
pjmedia/src/pjmedia/tonegen.c
39 39 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 gen52 {53 DATA a, s0, s1;54 };55 43 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 44 # if defined(PJMEDIA_USE_HIGH_QUALITY_TONEGEN) && \ 45 PJMEDIA_USE_HIGH_QUALITY_TONEGEN!=0 62 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 }; 63 57 64 #elif !defined(PJ_HAS_FLOATING_POINT) || PJ_HAS_FLOATING_POINT==0 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. 67 90 * This is a very fast fixed point tone generation using sine wave … … 99 122 # define GEN_SAMP(val,var) val = (short) VOL(var,SIN(var.c)>>16);\ 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 124 127 struct gen_state -
pjmedia/include/pjmedia/config.h
485 485 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. 490 501 *