Changeset 5546:faff3e9677c4 in roaraudio
- Timestamp:
- 06/17/12 15:31:52 (11 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r5544 r5546 6 6 * Done more hardending work. 7 7 * Improved error handling (including on win32) (Closes: #235) 8 * Added small DTMF library. 8 9 9 10 v. 1.0beta2 - Wed Jun 06 2012 19:56 CEST -
include/libroardsp/libroardsp.h
r5381 r5546 58 58 #include "filters.h" 59 59 #include "codecs.h" 60 #include "dtmf.h" 60 61 #include "transcode.h" 61 62 #include "vio_transcode.h" -
libroardsp/Makefile
r5270 r5546 5 5 6 6 TARGETS=$(SLIB) libroardsp.a 7 OBJS=libroardsp.o convert.o midside.o poly.o filter.o filterchain.o remove.o transcode.o vio_transcode.o rms.o fader.o mixer.o amp.o interleave.o channels.o resampler_poly3.o float.o 7 OBJS=libroardsp.o convert.o midside.o poly.o filter.o filterchain.o remove.o transcode.o vio_transcode.o rms.o fader.o mixer.o amp.o interleave.o channels.o resampler_poly3.o float.o dtmf.o 8 8 OLDROAR=midi.o 9 9 FILTER=filter_lowp.o filter_highp.o filter_amp.o filter_quantify.o filter_add.o filter_clip.o filter_downmix.o filter_dcblock.o filter_swap.o filter_agc.o filter_speex_prep.o filter_responsecurve.o -
roarclients/Makefile
r5516 r5546 3 3 TARGETS_IO=roarcat roarcatplay roarcatvio roarbidir roarmon roarmonhttp roarradio 4 4 TARGETS_CTL=roarctl roarlight roarinterconnect roarclientpass 5 TARGETS_DSP=roarfilt roarvumeter 5 TARGETS_DSP=roarfilt roarvumeter roardtmf 6 6 TARGETS_MISC=roarsockconnect roarphone roarshout 7 TARGETS_M= roardtmf7 TARGETS_M= 8 8 TARGETS_VIO=roarvio 9 9 TARGETS_PLUGINS=roarpluginrunner roarpluginapplication … … 78 78 ${CC} ${LDFLAGS} -o roarvumeter roarvumeter.o $(LIBS) $(LIBROARDSP) $(lib_m) 79 79 roardtmf: roardtmf.o 80 ${CC} ${LDFLAGS} -o roardtmf roardtmf.o $(LIBS) $( lib_m)80 ${CC} ${LDFLAGS} -o roardtmf roardtmf.o $(LIBS) $(LIBROARDSP) 81 81 roarsockconnect: roarsockconnect.o 82 82 $L -
roarclients/roardtmf.c
r5545 r5546 25 25 26 26 #include <roaraudio.h> 27 #include <libroardsp/libroardsp.h> 27 28 28 29 #ifdef ROAR_HAVE_LIBM … … 30 31 31 32 // in ms: 33 #if 0 32 34 #define ON_TIME (180) 33 35 #define OFF_TIME ( 80) 36 #else 37 #define ON_TIME (180) 38 #define OFF_TIME ( 80) 39 #endif 34 40 #define SUM_TIME (ON_TIME+OFF_TIME) 35 36 struct tone {37 char c;38 float f0;39 float f1;40 } g_tones[] = {41 {'1', 697, 1209},42 {'2', 697, 1336},43 {'3', 697, 1477},44 {'A', 697, 1633},45 46 {'4', 770, 1209},47 {'5', 770, 1336},48 {'6', 770, 1477},49 {'B', 770, 1633},50 51 {'7', 852, 1209},52 {'8', 852, 1336},53 {'9', 852, 1477},54 {'C', 852, 1633},55 56 {'*', 941, 1209},57 {'0', 941, 1336},58 {'#', 941, 1477},59 {'D', 941, 1633},60 61 {0, -1, -1}62 };63 41 64 42 void usage (void) { … … 74 52 } 75 53 76 int calc_break (int16_t * samples, size_t len, int rate, char c) {77 (void)rate, (void)c;78 // printf("calc_break(*): len=%zu\n", len);79 memset(samples, 0, len);80 return 0;81 }82 83 int calc_tone (int16_t * samples, size_t len, int rate, char c) {84 struct tone * ct = NULL;85 int i;86 float t;87 float t_inc = 1./rate;88 float t_max = ON_TIME / 1000.;89 float fc0, fc1;90 91 // printf("calc_tone(*): len=%zu\n", len);92 93 // printf("calc(*): t_inc=%f, t_max=%f\n", t_inc, t_max);94 95 if ( c >= 'a' )96 c -= 'a' - 'A';97 98 for (i = 0; g_tones[i].c != 0; i++) {99 if ( g_tones[i].c == c ) {100 ct = &(g_tones[i]);101 break;102 }103 }104 105 // printf("calc(*): ct=%p\n", ct);106 107 if ( ct == NULL )108 return -1;109 110 fc0 = 2 * M_PI * ct->f0;111 fc1 = 2 * M_PI * ct->f1;112 113 // printf("fc0=%f, fc1=%f\n", fc0, fc1);114 115 memset(samples, 0, len);116 117 for (i = 0, t = 0; t < t_max; t += t_inc, i++) {118 // printf("i=%i, t=%f\n", i, t);119 samples[i] = (sinf(fc0*t) + sinf(fc1*t))*8192.0;120 }121 122 // printf("i=%i\n", i);123 124 return 0;125 }126 127 54 int main (int argc, char * argv[]) { 128 55 int rate = ROAR_RATE_DEFAULT; … … 134 61 const char * tones = NULL; 135 62 void * buf; 63 size_t len_break; 64 size_t len_tone; 136 65 size_t samples; 137 66 size_t len; … … 162 91 } 163 92 164 samples = SUM_TIME * rate / 1000; 93 len_break = roar_dtmf_mus2samples(OFF_TIME * 1000, rate); 94 len_tone = roar_dtmf_mus2samples(ON_TIME * 1000, rate); 95 samples = len_break + len_tone; 165 96 97 printf("samples=%llu\n", (long long unsigned int)samples); 166 98 /* 167 printf("samples=%llu\n", (long long unsigned int)samples);168 99 return 0; 169 100 */ … … 185 116 186 117 if ( c == ' ' ) { 187 calc_break(buf, len, rate, c);118 roar_dtmf_break(buf, len_tone, rate, ROAR_DTMF_OPTIONS_NONE); 188 119 } else { 189 if ( calc_tone(buf, len, rate, c) == -1 ) {120 if ( roar_dtmf_tone(buf, len_tone, rate, ROAR_DTMF_OPTIONS_NONE, c) == -1 ) { 190 121 roar_mm_free(buf); 191 122 return 5; 192 123 } 193 124 } 125 roar_dtmf_break(buf+len_tone*sizeof(int16_t), len_break, rate, ROAR_DTMF_OPTIONS_NONE); 194 126 if ( roar_vs_write(vss, buf, len, &err) != (ssize_t)len ) { 195 127 fprintf(stderr, "Error: can not write data: %s\n", roar_vs_strerr(err));
Note: See TracChangeset
for help on using the changeset viewer.