Fixed CTCSS tone detection (#1226)

* Fixed erroneous rounding code

* Fixed CTCSS tone detection

* Correct tone index for XZ/WZ and sort table by tone freq
This commit is contained in:
Mark Thompson 2023-07-01 08:36:07 -05:00 committed by GitHub
parent c2279e297c
commit 4e128e8930
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -25,10 +25,11 @@
namespace tonekey { namespace tonekey {
// Keep list in ascending order by tone frequency
const tone_key_t tone_keys = { const tone_key_t tone_keys = {
{"None", 0.0}, {"None", 0.0},
{"0 XZ", 67.000}, {"1 XZ", 67.000},
{"1 WZ", 69.400}, {"39 WZ", 69.300},
{"2 XA", 71.900}, {"2 XA", 71.900},
{"3 WA", 74.400}, {"3 WA", 74.400},
{"4 XB", 77.000}, {"4 XB", 77.000},
@ -77,11 +78,11 @@ const tone_key_t tone_keys = {
{"37 M6", 241.800}, {"37 M6", 241.800},
{"38 M7", 250.300}, {"38 M7", 250.300},
{"50 0Z", 254.100}, {"50 0Z", 254.100},
{"Shure 19kHz", 19000.0},
{"Axient 28kHz", 28000.0}, {"Axient 28kHz", 28000.0},
{"Senn. 32.768k", 32768.0},
{"Senn. 32.000k", 32000.0}, {"Senn. 32.000k", 32000.0},
{"Sony 32.382k", 32382.0}, {"Sony 32.382k", 32382.0},
{"Shure 19kHz", 19000.0}}; {"Senn. 32.768k", 32768.0}};
void tone_keys_populate(OptionsField& field) { void tone_keys_populate(OptionsField& field) {
using option_t = std::pair<std::string, int32_t>; using option_t = std::pair<std::string, int32_t>;
@ -120,7 +121,7 @@ std::string tone_key_string_by_value(uint32_t value) {
tone_index tone_key_index_by_value(uint32_t value) { tone_index tone_key_index_by_value(uint32_t value) {
float diff; float diff;
float min_diff{(float)value}; float min_diff{(float)value};
float fvalue{(float)((min_diff + 50.0) / 100.0)}; float fvalue{(float)(min_diff / 100.0)};
tone_index min_idx{-1}; tone_index min_idx{-1};
tone_index idx; tone_index idx;

View File

@ -72,7 +72,7 @@ void NarrowbandFMAudio::execute(const buffer_c8_t& buffer) {
cur_sample = audio_f[c]; cur_sample = audio_f[c];
if (cur_sample * prev_sample < 0.0) { if (cur_sample * prev_sample < 0.0) {
z_acc += z_timer; z_acc += z_timer;
z_timer = 0; z_timer = 1;
z_count++; z_count++;
} else } else
z_timer++; z_timer++;