Changeset 5553:a17285dc6fd6 in roaraudio for libroardsp/dtmf.c
- Timestamp:
- 07/05/12 16:12:28 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroardsp/dtmf.c
r5547 r5553 158 158 }; 159 159 160 static const struct tone * __lookup_tone (const int options, uint16_t c) {160 static const struct tone * __lookup_tone_by_char(const int options, uint16_t c) { 161 161 size_t i; 162 162 163 163 (void)options; 164 164 165 if ( c >= 'a' ) 165 if ( (c >= ROAR_DTMF_CHAR_DTMF('a') && c <= ROAR_DTMF_CHAR_DTMF('z')) || 166 (c >= ROAR_DTMF_CHAR_ROAR('a') && c <= ROAR_DTMF_CHAR_ROAR('z')) 167 ) 166 168 c -= 'a' - 'A'; 167 169 … … 170 172 return &(_roardsp_tones[i]); 171 173 } 174 } 175 176 roar_err_set(ROAR_ERROR_NOENT); 177 return NULL; 178 } 179 180 static const struct tone * __lookup_tone_by_freq(const int options, float f0, float f1) { 181 const struct tone * ct; 182 size_t i; 183 float tmp; 184 185 (void)options; 186 187 if ( f0 > f1 ) { 188 tmp = f0; 189 f0 = f1; 190 f1 = tmp; 191 } 192 193 for (i = 0; _roardsp_tones[i].c != 0; i++) { 194 ct = &(_roardsp_tones[i]); 195 196 // allow 3.5% freq error as defined in ITU-T Q.23 and Q.24. 197 198 if ( ct->f0 < f0*.965 || ct->f0 > f0*1.035 ) 199 continue; 200 if ( ct->f1 < f1*.965 || ct->f1 > f1*1.035 ) 201 continue; 202 return ct; 172 203 } 173 204 … … 190 221 } 191 222 192 ct = __lookup_tone(options, c); 223 if ( c == ROAR_DTMF_CHAR_BREAK ) 224 return roar_dtmf_break(samples, len, rate, options); 225 226 ct = __lookup_tone_by_char(options, c); 193 227 194 228 if ( ct == NULL ) { … … 209 243 } 210 244 245 uint16_t roar_dtmf_freqs2char(const int options, float f0, float f1) { 246 const struct tone * ct = __lookup_tone_by_freq(options, f0, f1); 247 248 if ( ct == NULL ) 249 return ROAR_DTMF_CHAR_BREAK; 250 return ct->c; 251 } 211 252 212 253 //ll
Note: See TracChangeset
for help on using the changeset viewer.