1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Changeset 2162

Show
Ignore:
Timestamp:
11/26/11 22:06:19 (18 months ago)
Author:
sm0svx
Message:

The tone detector has now been further improved. Instead of using the
tone power to passband power relation, the passband power is recalculated
to a noise floor estimation. This estimation can then be used to calculate an
SNR value for the tone detector. Doing this have at least two benefits.
One is that the CTCSS detector now work all over the CTCSS band with good
performance. There is still a problem though if the frequency response is
not flat over the whole band. However, this can now be easily compensated
for by changing the thresholds in the configuration.
That bring us to the second benefit. The threshold is now expressed in dB
which make it an understandable parameter which users can change in the
configuration, much like they turn the squelch knob on their radio.

Location:
branches/improved_tone_detector/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branches/improved_tone_detector/src/svxlink/remotetrx/remotetrx.conf

    r1928 r2162  
    5151VOX_FILTER_DEPTH=20 
    5252VOX_THRESH=1000 
     53#CTCSS_MODE=3 
    5354CTCSS_FQ=136.5 
    5455CTCSS_THRESH=10 
     56CTCSS_SNR_OPEN_THRESH=16 
     57CTCSS_SNR_CLOSE_THRESH=10 
    5558SERIAL_PORT=/dev/ttyS0 
    5659SERIAL_PIN=CTS:SET 
     
    103106VOX_FILTER_DEPTH=20 
    104107VOX_THRESH=1000 
     108#CTCSS_MODE=3 
    105109CTCSS_FQ=136.5 
    106110CTCSS_THRESH=10 
     111CTCSS_SNR_OPEN_THRESH=16 
     112CTCSS_SNR_CLOSE_THRESH=10 
    107113SERIAL_PORT=/dev/ttyS0 
    108114SERIAL_PIN=CTS:SET 
  • branches/improved_tone_detector/src/svxlink/svxlink/svxlink.conf

    r2010 r2162  
    135135VOX_FILTER_DEPTH=20 
    136136VOX_THRESH=1000 
     137#CTCSS_MODE=3 
    137138CTCSS_FQ=136.5 
    138139CTCSS_THRESH=10 
     140CTCSS_SNR_OPEN_THRESH=16 
     141CTCSS_SNR_CLOSE_THRESH=10 
    139142SERIAL_PORT=/dev/ttyS0 
    140143SERIAL_PIN=CTS:SET 
  • branches/improved_tone_detector/src/svxlink/trx/SquelchCtcss.h

    r2146 r2162  
    161161      int ctcss_mode = 1; 
    162162      cfg.getValue(rx_name, "CTCSS_MODE", ctcss_mode); 
     163       
     164      float snr_open_thresh = 16; 
     165      cfg.getValue(rx_name, "CTCSS_SNR_OPEN_THRESH", snr_open_thresh); 
     166 
     167      float snr_close_thresh = 10; 
     168      cfg.getValue(rx_name, "CTCSS_SNR_CLOSE_THRESH", snr_close_thresh); 
    163169 
    164170      det = new ToneDetector(ctcss_fq, 8.0f); 
     
    170176      { 
    171177        case 2: 
    172           std::cout << "### CTCSS mode: Center to total passband power\n"; 
     178          std::cout << "### CTCSS mode: Estimated SNR\n"; 
    173179          //det->setDetectBw(6.0f); 
    174180          det->setDetectUseWindowing(false); 
    175181          det->setDetectPeakThresh(0.0f); 
    176           det->setDetectPeakToTotPwrThresh(0.6f); 
     182          //det->setDetectPeakToTotPwrThresh(0.6f); 
     183          det->setDetectSnrThresh(snr_open_thresh, 210.0f); 
    177184          det->setDetectStableCountThresh(1); 
    178185 
     
    180187          det->setUndetectUseWindowing(false); 
    181188          det->setUndetectPeakThresh(0.0f); 
    182           det->setUndetectPeakToTotPwrThresh(0.3f); 
     189          //det->setUndetectPeakToTotPwrThresh(0.3f); 
     190          det->setUndetectSnrThresh(snr_close_thresh, 210.0f); 
    183191          det->setUndetectStableCountThresh(2); 
    184192 
     
    190198 
    191199        case 3: 
    192           std::cout << "### CTCSS mode: Phase\n"; 
     200          std::cout << "### CTCSS mode: Estimated SNR + Phase\n"; 
    193201          //det->setDetectUseWindowing(false); 
    194202          det->setDetectBw(16.0f); 
    195203          det->setDetectPeakThresh(0.0f); 
    196           det->setDetectPeakToTotPwrThresh(0.6f); 
     204          //det->setDetectPeakToTotPwrThresh(0.6f); 
     205          det->setDetectSnrThresh(snr_open_thresh, 210.0f); 
    197206          det->setDetectStableCountThresh(1); 
    198207          det->setDetectPhaseBwThresh(2.0f, 2.0f); 
     
    201210          det->setUndetectUseWindowing(false); 
    202211          det->setUndetectPeakThresh(0.0f); 
    203           det->setUndetectPeakToTotPwrThresh(0.3f); 
     212          //det->setUndetectPeakToTotPwrThresh(0.3f); 
     213          det->setUndetectSnrThresh(snr_close_thresh, 210.0f); 
    204214          det->setUndetectStableCountThresh(2); 
    205215          //det->setUndetectPhaseBwThresh(4.0f, 16.0f); 
  • branches/improved_tone_detector/src/svxlink/trx/ToneDetector.cpp

    r2154 r2162  
    104104  float               peak_to_tot_pwr_thresh; 
    105105  float               passband_energy_thresh; 
     106  float               snr_thresh; 
     107  float               passband_bw; 
    106108}; 
    107109 
     
    156158  det_par->peak_to_tot_pwr_thresh = 0.0f; 
    157159  det_par->passband_energy_thresh = 0.0f; 
     160  det_par->snr_thresh = 0.0f; 
     161  det_par->passband_bw = 0.0f; 
    158162 
    159163  setDetectBw(width_hz); 
     
    376380 
    377381 
     382void ToneDetector::setDetectSnrThresh(float thresh_db, float passband_bw_hz) 
     383{ 
     384  det_par->snr_thresh = thresh_db; 
     385  det_par->passband_bw = passband_bw_hz; 
     386} /* ToneDetector::setDetectSnrThresh */ 
     387 
     388 
     389void ToneDetector::setUndetectSnrThresh(float thresh_db, float passband_bw_hz) 
     390{ 
     391  undet_par->snr_thresh = thresh_db;   
     392  undet_par->passband_bw = passband_bw_hz; 
     393} /* ToneDetector::setUndetectSnrThresh */ 
     394 
     395 
    378396void ToneDetector::setDetectPhaseBwThresh(float bw_hz, float stddev_hz) 
    379397{ 
     
    556574      // are doing: 
    557575      // 
    558       //    float Ptone = res_center / ((par->block_len*par->block_len) / 2); 
     576      //    float Ptone = 2.0f * res_center / (par->block_len*par->block_len); 
    559577      //    float Ppassband = passband_energy / par->block_len; 
    560578      //    float peak_to_tot_pwr = Ptone / Ppassband; 
     
    565583  } 
    566584 
     585  if (par->passband_bw > 0.0f) 
     586  { 
     587      // Calculate mean tone power 
     588    float Ptone = 2.0f * res_center / (par->block_len*par->block_len); 
     589     
     590      // Calculate mean passband power 
     591    float Ppassband = passband_energy / par->block_len; 
     592     
     593      // Estimate the mean noise floor over the whole passband 
     594    float Pnoise = (Ppassband - Ptone) / ((par->passband_bw-par->bw) / par->bw); 
     595     
     596      // Calculate the signal to noise ratio 
     597    float snr = 10 * log10(Ptone / Pnoise); 
     598     
     599      // Check if the SNR is over the threshold 
     600    active = active && (snr > par->snr_thresh); 
     601  } 
     602   
    567603    // If phase checking is active, check the phase 
    568604  if (phase_check_left > 0) 
  • branches/improved_tone_detector/src/svxlink/trx/ToneDetector.h

    r2154 r2162  
    292292     */ 
    293293    void setUndetectPeakToTotPwrThresh(float thresh); 
     294 
     295    /** 
     296     * @brief  Set the peak to noise floor SNR threshold when inactive 
     297     * @param  thresh_db        The threshold in dB 
     298     * @param  passband_bw_hz   Passband bandwidth in Hz 
     299     * 
     300     * This function is used to set the signal to noise ratio 
     301     * threshold when the tone detector is in its inactive state, that is 
     302     * when a tone is not being detected. 
     303     * This will compare the narrow band Goertzel tone detector power to 
     304     * an estimated noise floor. The noise floor estimation is deduced from 
     305     * the total passband power where the tone has been removed. This will 
     306     * be a mean value of the noise floor for the whole passband. If the 
     307     * amplitude response for the passband is not flat, the noise floor will 
     308     * have an offset and so will the tone. This will mean that the SNR will 
     309     * also have an offset. So, for example, if the part of the passband where 
     310     * the tone is expected to appear is attenuated by 6dB in comparision to 
     311     * the mean passband gain, the threshold need to also be lowered by 6dB. 
     312     */ 
     313    void setDetectSnrThresh(float thresh_db, float passband_bw_hz); 
     314 
     315    /** 
     316     * @brief  Set the peak to noise floor SNR threshold when active 
     317     * @param  thresh_db        The threshold in dB 
     318     * @param  passband_bw_hz   Passband bandwidth in Hz 
     319     * 
     320     * This function is used to set the signal to noise ratio 
     321     * threshold when the tone detector is in its active state, that is 
     322     * when a tone is being detected. 
     323     * This will compare the narrow band Goertzel tone detector power to 
     324     * an estimated noise floor. The noise floor estimation is deduced from 
     325     * the total passband power where the tone has been removed. This will 
     326     * be a mean value of the noise floor for the whole passband. If the 
     327     * amplitude response for the passband is not flat, the noise floor will 
     328     * have an offset and so will the tone. This will mean that the SNR will 
     329     * also have an offset. So, for example, if the part of the passband where 
     330     * the tone is expected to appear is attenuated by 6dB in comparision to 
     331     * the mean passband gain, the threshold need to also be lowered by 6dB. 
     332     */ 
     333    void setUndetectSnrThresh(float thresh_db, float passband_bw_hz); 
    294334 
    295335    /** 
  • branches/improved_tone_detector/src/versions

    r2144 r2162  
    1212 
    1313# SvxLink versions 
    14 SVXLINK=0.13.99.0 
     14SVXLINK=0.13.99.1 
    1515SVXLINK_RPM_RELEASE=1 
    1616MODULE_HELP=0.7.0.99.0