Changeset 2321:9df21a38f3af in roaraudio


Ignore:
Timestamp:
08/06/09 00:19:29 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added basic threshold based /DTX/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarphone.c

    r2312 r2321  
    5151 int samples; 
    5252 int transcode; 
     53 int64_t dtx_threshold; 
    5354} g_conf; 
    5455 
     
    6869        "  --device   DEVICE    - Set the device\n" 
    6970        "  --antiecho AEMODE    - Set the anti echo mode\n" 
     71        "  --threshold DTXTHRES - Set the DTX threshold, disabled by default\n" 
    7072        "  --transcode          - Use local transcodeing\n" 
    7173        "  --help               - Show this help\n" 
     
    154156} 
    155157 
     158int zero_if_noise16 (int16_t * data, size_t samples) { 
     159 int64_t rms = roar_rms2_1_16(data, samples); 
     160 
     161 if ( rms < g_conf.dtx_threshold ) 
     162  memset(data, 0, samples*2); 
     163 
     164 return 0; 
     165} 
     166 
    156167int run_stream (struct roar_vio_calls * s0, struct roar_vio_calls * s1, struct roar_audio_info * info) { 
    157168 size_t len; 
     
    171182  if ( (miclen = roar_vio_read(s0, micbuf, len)) <= 0 ) 
    172183   break; 
     184 
     185  if ( g_conf.dtx_threshold > 0 ) 
     186   if ( info->bits == 16 ) 
     187    zero_if_noise16(micbuf, miclen/2); 
     188 
    173189  if ( g_conf.transcode ) { 
    174190   if ( roar_bixcoder_write_packet(transcoder, micbuf, miclen) == -1 ) 
     
    218234 memset(&g_conf, 0, sizeof(g_conf)); 
    219235 
    220  g_conf.antiecho = AE_ROARD; 
     236 g_conf.antiecho      = AE_ROARD; 
     237 g_conf.dtx_threshold = -1; 
    221238 
    222239 for (i = 1; i < argc; i++) { 
     
    251268    return 1; 
    252269   } 
     270  } else if ( strcmp(k, "--threshold") == 0 ) { 
     271   g_conf.dtx_threshold = atol(argv[++i]); 
     272 
     273   // use threshold^2 or threshold < 0 for not using DTX 
     274   if ( g_conf.dtx_threshold > 0 ) 
     275    g_conf.dtx_threshold *= g_conf.dtx_threshold; 
    253276  } else if ( strcmp(k, "--transcode") == 0 ) { 
    254277   g_conf.transcode = 1; 
Note: See TracChangeset for help on using the changeset viewer.