diff --git a/openrtx/include/protocols/M17/M17DSP.h b/openrtx/include/protocols/M17/M17DSP.h index f6fb2d24..b61cc718 100644 --- a/openrtx/include/protocols/M17/M17DSP.h +++ b/openrtx/include/protocols/M17/M17DSP.h @@ -34,43 +34,62 @@ namespace M17 { /* - * Coefficients for M17 RRC filter + * Coefficients for M17 RRC filters */ -static constexpr std::array rrc_taps = +static constexpr std::array rrc_taps_48k = { -0.003195702904062073, -0.002930279157647190, -0.001940667871554463, - -0.000356087678023658, 0.001547011339077758, 0.003389554791179751, - 0.004761898604225673, 0.005310860846138910, 0.004824746306020221, - 0.003297923526848786, 0.000958710871218619, -0.001749908029791816, + -0.000356087678023658, 0.001547011339077758, 0.003389554791179751, + 0.004761898604225673, 0.005310860846138910, 0.004824746306020221, + 0.003297923526848786, 0.000958710871218619, -0.001749908029791816, -0.004238694106631223, -0.005881783042101693, -0.006150256456781309, - -0.004745376707651645, -0.001704189656473565, 0.002547854551539951, - 0.007215575568844704, 0.011231038205363532, 0.013421952197060707, - 0.012730475385624438, 0.008449554307303753, 0.000436744366018287, + -0.004745376707651645, -0.001704189656473565, 0.002547854551539951, + 0.007215575568844704, 0.011231038205363532, 0.013421952197060707, + 0.012730475385624438, 0.008449554307303753, 0.000436744366018287, -0.010735380379191660, -0.023726883538258272, -0.036498030780605324, -0.046500883189991064, -0.050979050575999614, -0.047340680079891187, - -0.033554880492651755, -0.008513823955725943, 0.027696543159614194, - 0.073664520037517042, 0.126689053778116234, 0.182990955139333916, - 0.238080025892859704, 0.287235637987091563, 0.326040247765297220, - 0.350895727088112619, 0.359452932027607974, 0.350895727088112619, - 0.326040247765297220, 0.287235637987091563, 0.238080025892859704, - 0.182990955139333916, 0.126689053778116234, 0.073664520037517042, - 0.027696543159614194, -0.008513823955725943, -0.033554880492651755, + -0.033554880492651755, -0.008513823955725943, 0.027696543159614194, + 0.073664520037517042, 0.126689053778116234, 0.182990955139333916, + 0.238080025892859704, 0.287235637987091563, 0.326040247765297220, + 0.350895727088112619, 0.359452932027607974, 0.350895727088112619, + 0.326040247765297220, 0.287235637987091563, 0.238080025892859704, + 0.182990955139333916, 0.126689053778116234, 0.073664520037517042, + 0.027696543159614194, -0.008513823955725943, -0.033554880492651755, -0.047340680079891187, -0.050979050575999614, -0.046500883189991064, -0.036498030780605324, -0.023726883538258272, -0.010735380379191660, - 0.000436744366018287, 0.008449554307303753, 0.012730475385624438, - 0.013421952197060707, 0.011231038205363532, 0.007215575568844704, - 0.002547854551539951, -0.001704189656473565, -0.004745376707651645, + 0.000436744366018287, 0.008449554307303753, 0.012730475385624438, + 0.013421952197060707, 0.011231038205363532, 0.007215575568844704, + 0.002547854551539951, -0.001704189656473565, -0.004745376707651645, -0.006150256456781309, -0.005881783042101693, -0.004238694106631223, - -0.001749908029791816, 0.000958710871218619, 0.003297923526848786, - 0.004824746306020221, 0.005310860846138910, 0.004761898604225673, - 0.003389554791179751, 0.001547011339077758, -0.000356087678023658, + -0.001749908029791816, 0.000958710871218619, 0.003297923526848786, + 0.004824746306020221, 0.005310860846138910, 0.004761898604225673, + 0.003389554791179751, 0.001547011339077758, -0.000356087678023658, -0.001940667871554463, -0.002930279157647190, -0.003195702904062073, }; +static constexpr std::array rrc_taps_24k = +{ + -0.00451938415438936, -0.00274450532197076, 0.00218779365365964, + 0.00673430845820838, 0.00682318809319229, 0.00135581524631680, + -0.00599438920196964, -0.00869773330332975, -0.00241007626827605, + 0.0102043146279916, 0.0189814134484353, 0.0119494155102909, + -0.0151820458389266, -0.0516157561976790, -0.0720949100387685, + -0.0474535336210882, 0.0391686342706687, 0.179164496628150, + 0.336694345124862, 0.461088271869920, 0.508340710642860, + 0.461088271869920, 0.336694345124862, 0.179164496628150, + 0.0391686342706687, -0.0474535336210882, -0.0720949100387685, + -0.0516157561976790, -0.0151820458389266, 0.0119494155102909, + 0.0189814134484353, 0.0102043146279916, -0.00241007626827605, + -0.00869773330332975, -0.00599438920196964, 0.00135581524631680, + 0.00682318809319229, 0.00673430845820838, 0.00218779365365964, + -0.00274450532197076, -0.00451938415438936 +}; + /* - * FIR implementation of the RRC filter for baseband audio generation. + * FIR implementations of the RRC filter for baseband audio generation. */ -extern Fir< std::tuple_size< decltype(rrc_taps) >::value > rrc; +extern Fir< std::tuple_size< decltype(rrc_taps_48k) >::value > rrc_48k; +extern Fir< std::tuple_size< decltype(rrc_taps_24k) >::value > rrc_24k; } /* M17 */ diff --git a/openrtx/include/protocols/M17/M17Demodulator.h b/openrtx/include/protocols/M17/M17Demodulator.h index 831d00f3..0bbb2fd1 100644 --- a/openrtx/include/protocols/M17/M17Demodulator.h +++ b/openrtx/include/protocols/M17/M17Demodulator.h @@ -115,7 +115,7 @@ private: static constexpr size_t M17_SYMBOL_RATE = 4800; static constexpr size_t M17_FRAME_SYMBOLS = 192; static constexpr size_t M17_SYNCWORD_SYMBOLS = 8; - static constexpr size_t M17_RX_SAMPLE_RATE = 48000; + static constexpr size_t M17_RX_SAMPLE_RATE = 24000; static constexpr size_t M17_SAMPLES_PER_SYMBOL = M17_RX_SAMPLE_RATE / M17_SYMBOL_RATE; static constexpr size_t M17_FRAME_BYTES = M17_FRAME_SYMBOLS / 4; @@ -123,7 +123,7 @@ private: static constexpr size_t M17_SAMPLE_BUF_SIZE = M17_FRAME_SAMPLES / 2; static constexpr size_t M17_BRIDGE_SIZE = M17_SAMPLES_PER_SYMBOL * M17_SYNCWORD_SYMBOLS; - static constexpr float CONV_STATS_ALPHA = 0.001f; + static constexpr float CONV_STATS_ALPHA = 0.005f; static constexpr float CONV_THRESHOLD_FACTOR = 3.40; static constexpr int16_t QNT_SMA_WINDOW = 8; diff --git a/openrtx/src/protocols/M17/M17DSP.cpp b/openrtx/src/protocols/M17/M17DSP.cpp index f559f28a..a4a4d117 100644 --- a/openrtx/src/protocols/M17/M17DSP.cpp +++ b/openrtx/src/protocols/M17/M17DSP.cpp @@ -20,4 +20,5 @@ #include -Fir< std::tuple_size< decltype(M17::rrc_taps) >::value > M17::rrc(M17::rrc_taps); +Fir< std::tuple_size< decltype(M17::rrc_taps_48k) >::value > M17::rrc_48k(M17::rrc_taps_48k); +Fir< std::tuple_size< decltype(M17::rrc_taps_24k) >::value > M17::rrc_24k(M17::rrc_taps_24k); diff --git a/openrtx/src/protocols/M17/M17Demodulator.cpp b/openrtx/src/protocols/M17/M17Demodulator.cpp index 894c9845..35f106d6 100644 --- a/openrtx/src/protocols/M17/M17Demodulator.cpp +++ b/openrtx/src/protocols/M17/M17Demodulator.cpp @@ -103,7 +103,7 @@ void M17Demodulator::stopBasebandSampling() void M17Demodulator::resetCorrelationStats() { - conv_emvar = 80000000.0f; + conv_emvar = 40000000.0f; } /** @@ -307,7 +307,7 @@ bool M17Demodulator::update() for(size_t i = 0; i < baseband.len; i++) { float elem = static_cast< float >(baseband.data[i]); - baseband.data[i] = static_cast< int16_t >(M17::rrc(elem)); + baseband.data[i] = static_cast< int16_t >(M17::rrc_24k(elem)); } // Process the buffer @@ -324,7 +324,7 @@ bool M17Demodulator::update() { syncDetected = true; isLSF = syncword.lsf; - offset = syncword.index + 4; + offset = syncword.index + 1; phase = 0; frame_index = 0; } diff --git a/openrtx/src/protocols/M17/M17Modulator.cpp b/openrtx/src/protocols/M17/M17Modulator.cpp index 27009097..561b7112 100644 --- a/openrtx/src/protocols/M17/M17Modulator.cpp +++ b/openrtx/src/protocols/M17/M17Modulator.cpp @@ -99,7 +99,7 @@ void M17Modulator::generateBaseband() for(size_t i = 0; i < M17_FRAME_SAMPLES_48K; i++) { float elem = static_cast< float >(idleBuffer[i]); - idleBuffer[i] = static_cast< int16_t >((M17::rrc(elem) * M17_RRC_GAIN) + idleBuffer[i] = static_cast< int16_t >((M17::rrc_48k(elem) * M17_RRC_GAIN) - M17_RRC_OFFSET); } } diff --git a/tests/platform/rx_test.c b/tests/platform/rx_test.c index 43d4590b..db9a7e40 100644 --- a/tests/platform/rx_test.c +++ b/tests/platform/rx_test.c @@ -37,7 +37,7 @@ int main() audio_enableMic(); streamId id = inputStream_start(SOURCE_RTX, PRIO_TX, sampleBuf, numSamples, - BUF_LINEAR, 48000); + BUF_LINEAR, 24000); sleepFor(3u, 0u); platform_ledOn(GREEN);