From ac2a45ce88a58e1cfad4b744b9c4649d01777ac6 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 20 Jul 2022 05:47:48 +0200 Subject: [PATCH] M17 code reorganization --- CMakeLists.txt | 5 +- exports/export.h | 10 ++-- modemm17/CMakeLists.txt | 56 +++++++++++++++++++ {modems/m17 => modemm17}/CRC16.h | 0 {modems/m17 => modemm17}/CarrierDetect.h | 0 {modems/m17 => modemm17}/ClockRecovery.h | 0 {modems/m17 => modemm17}/Convolution.h | 0 {modems/m17 => modemm17}/Correlator.cpp | 0 {modems/m17 => modemm17}/Correlator.h | 2 +- {modems/m17 => modemm17}/DataCarrierDetect.h | 0 {modems/m17 => modemm17}/DeviationError.h | 0 {modems/m17 => modemm17}/Filter.h | 0 {modems/m17 => modemm17}/FirFilter.h | 0 {modems/m17 => modemm17}/FreqDevEstimator.cpp | 0 {modems/m17 => modemm17}/FreqDevEstimator.h | 2 +- {modems/m17 => modemm17}/FrequencyError.h | 0 {modems/m17 => modemm17}/Fsk4Demod.h | 0 {modems/m17 => modemm17}/Golay24.cpp | 0 {modems/m17 => modemm17}/Golay24.h | 2 +- {modems/m17 => modemm17}/IirFilter.h | 0 {modems/m17 => modemm17}/LinkSetupFrame.h | 0 {modems/m17 => modemm17}/M17Demodulator.cpp | 0 {modems/m17 => modemm17}/M17Demodulator.h | 2 +- {modems/m17 => modemm17}/M17FrameDecoder.h | 0 {modems/m17 => modemm17}/M17Framer.h | 0 {modems/m17 => modemm17}/M17Modulator.cpp | 0 {modems/m17 => modemm17}/M17Modulator.h | 0 {modems/m17 => modemm17}/M17Randomizer.h | 0 {modems/m17 => modemm17}/M17Synchronizer.h | 0 {modems/m17 => modemm17}/PhaseEstimator.h | 0 .../m17 => modemm17}/PolynomialInterleaver.h | 0 {modems/m17 => modemm17}/SlidingDFT.h | 0 {modems/m17 => modemm17}/SymbolEvm.h | 0 {modems/m17 => modemm17}/Trellis.h | 4 +- {modems/m17 => modemm17}/Util.h | 5 +- {modems/m17 => modemm17}/Viterbi.h | 0 {modems/m17 => modemm17}/ax25_frame.h | 0 {modems/m17 => modemm17}/queue.h | 0 modems/CMakeLists.txt | 56 ------------------- plugins/channelrx/CMakeLists.txt | 2 +- plugins/channelrx/demodm17/CMakeLists.txt | 4 +- .../channelrx/demodm17/m17demodprocessor.cpp | 2 +- .../channelrx/demodm17/m17demodprocessor.h | 2 +- plugins/channeltx/CMakeLists.txt | 2 +- plugins/channeltx/modm17/CMakeLists.txt | 4 +- plugins/channeltx/modm17/m17modprocessor.cpp | 2 +- plugins/channeltx/modm17/m17modprocessor.h | 2 +- 47 files changed, 82 insertions(+), 82 deletions(-) create mode 100644 modemm17/CMakeLists.txt rename {modems/m17 => modemm17}/CRC16.h (100%) rename {modems/m17 => modemm17}/CarrierDetect.h (100%) rename {modems/m17 => modemm17}/ClockRecovery.h (100%) rename {modems/m17 => modemm17}/Convolution.h (100%) rename {modems/m17 => modemm17}/Correlator.cpp (100%) rename {modems/m17 => modemm17}/Correlator.h (99%) rename {modems/m17 => modemm17}/DataCarrierDetect.h (100%) rename {modems/m17 => modemm17}/DeviationError.h (100%) rename {modems/m17 => modemm17}/Filter.h (100%) rename {modems/m17 => modemm17}/FirFilter.h (100%) rename {modems/m17 => modemm17}/FreqDevEstimator.cpp (100%) rename {modems/m17 => modemm17}/FreqDevEstimator.h (98%) rename {modems/m17 => modemm17}/FrequencyError.h (100%) rename {modems/m17 => modemm17}/Fsk4Demod.h (100%) rename {modems/m17 => modemm17}/Golay24.cpp (100%) rename {modems/m17 => modemm17}/Golay24.h (98%) rename {modems/m17 => modemm17}/IirFilter.h (100%) rename {modems/m17 => modemm17}/LinkSetupFrame.h (100%) rename {modems/m17 => modemm17}/M17Demodulator.cpp (100%) rename {modems/m17 => modemm17}/M17Demodulator.h (98%) rename {modems/m17 => modemm17}/M17FrameDecoder.h (100%) rename {modems/m17 => modemm17}/M17Framer.h (100%) rename {modems/m17 => modemm17}/M17Modulator.cpp (100%) rename {modems/m17 => modemm17}/M17Modulator.h (100%) rename {modems/m17 => modemm17}/M17Randomizer.h (100%) rename {modems/m17 => modemm17}/M17Synchronizer.h (100%) rename {modems/m17 => modemm17}/PhaseEstimator.h (100%) rename {modems/m17 => modemm17}/PolynomialInterleaver.h (100%) rename {modems/m17 => modemm17}/SlidingDFT.h (100%) rename {modems/m17 => modemm17}/SymbolEvm.h (100%) rename {modems/m17 => modemm17}/Trellis.h (96%) rename {modems/m17 => modemm17}/Util.h (99%) rename {modems/m17 => modemm17}/Viterbi.h (100%) rename {modems/m17 => modemm17}/ax25_frame.h (100%) rename {modems/m17 => modemm17}/queue.h (100%) delete mode 100644 modems/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index a9a6e3b83..5d40117b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -549,10 +549,7 @@ add_subdirectory(qrtplib) add_subdirectory(swagger) add_subdirectory(devices) add_subdirectory(sdrbench) - -if (LINUX) - add_subdirectory(modems) -endif() +add_subdirectory(modemm17) if (BUILD_GUI) add_subdirectory(sdrgui) diff --git a/exports/export.h b/exports/export.h index 0ad1c8a7e..eee96b603 100644 --- a/exports/export.h +++ b/exports/export.h @@ -139,16 +139,16 @@ # define SDRBENCH_API #endif -/* the 'M17_API' controls the import/export of 'm17' symbols +/* the 'MODEMM17_API' controls the import/export of 'modemm17' symbols */ #if !defined(sdrangel_STATIC) -# ifdef m17_EXPORTS -# define M17_API __SDR_EXPORT +# ifdef modemm17_EXPORTS +# define MODEMM17_API __SDR_EXPORT # else -# define M17_API __SDR_IMPORT +# define MODEMM17_API __SDR_IMPORT # endif #else -# define M17_API +# define MODEMM17_API #endif #endif /* __SDRANGEL_EXPORT_H */ diff --git a/modemm17/CMakeLists.txt b/modemm17/CMakeLists.txt new file mode 100644 index 000000000..baf81dc31 --- /dev/null +++ b/modemm17/CMakeLists.txt @@ -0,0 +1,56 @@ +project(modemm17) + +set(modemm17_SOURCES + Correlator.cpp + FreqDevEstimator.cpp + Golay24.cpp + M17Demodulator.cpp + M17Modulator.cpp +) + +set(modemm17_HEADERS + ax25_frame.h + CarrierDetect.h + ClockRecovery.h + Convolution.h + Correlator.h + CRC16.h + DataCarrierDetect.h + DeviationError.h + Filter.h + FirFilter.h + FreqDevEstimator.h + FrequencyError.h + Fsk4Demod.h + Golay24.h + IirFilter.h + LinkSetupFrame.h + M17Demodulator.h + M17FrameDecoder.h + M17Framer.h + M17Modulator.h + M17Randomizer.h + M17Synchronizer.h + PhaseEstimator.h + PolynomialInterleaver.h + queue.h + SlidingDFT.h + SymbolEvm.h + Trellis.h + Util.h + Viterbi.h +) + +include_directories( + ${CMAKE_SOURCE_DIR}/exports +) + +add_library(modemm17 SHARED + ${modemm17_SOURCES} +) + +target_link_libraries(modemm17 + Qt5::Core +) + +install(TARGETS modemm17 DESTINATION ${INSTALL_LIB_DIR}) diff --git a/modems/m17/CRC16.h b/modemm17/CRC16.h similarity index 100% rename from modems/m17/CRC16.h rename to modemm17/CRC16.h diff --git a/modems/m17/CarrierDetect.h b/modemm17/CarrierDetect.h similarity index 100% rename from modems/m17/CarrierDetect.h rename to modemm17/CarrierDetect.h diff --git a/modems/m17/ClockRecovery.h b/modemm17/ClockRecovery.h similarity index 100% rename from modems/m17/ClockRecovery.h rename to modemm17/ClockRecovery.h diff --git a/modems/m17/Convolution.h b/modemm17/Convolution.h similarity index 100% rename from modems/m17/Convolution.h rename to modemm17/Convolution.h diff --git a/modems/m17/Correlator.cpp b/modemm17/Correlator.cpp similarity index 100% rename from modems/m17/Correlator.cpp rename to modemm17/Correlator.cpp diff --git a/modems/m17/Correlator.h b/modemm17/Correlator.h similarity index 99% rename from modems/m17/Correlator.h rename to modemm17/Correlator.h index b63cecfe2..f199297a6 100644 --- a/modems/m17/Correlator.h +++ b/modemm17/Correlator.h @@ -18,7 +18,7 @@ namespace modemm17 { -struct M17_API Correlator +struct MODEMM17_API Correlator { static constexpr size_t SYMBOLS = 8; static constexpr size_t SAMPLES_PER_SYMBOL = 10; diff --git a/modems/m17/DataCarrierDetect.h b/modemm17/DataCarrierDetect.h similarity index 100% rename from modems/m17/DataCarrierDetect.h rename to modemm17/DataCarrierDetect.h diff --git a/modems/m17/DeviationError.h b/modemm17/DeviationError.h similarity index 100% rename from modems/m17/DeviationError.h rename to modemm17/DeviationError.h diff --git a/modems/m17/Filter.h b/modemm17/Filter.h similarity index 100% rename from modems/m17/Filter.h rename to modemm17/Filter.h diff --git a/modems/m17/FirFilter.h b/modemm17/FirFilter.h similarity index 100% rename from modems/m17/FirFilter.h rename to modemm17/FirFilter.h diff --git a/modems/m17/FreqDevEstimator.cpp b/modemm17/FreqDevEstimator.cpp similarity index 100% rename from modems/m17/FreqDevEstimator.cpp rename to modemm17/FreqDevEstimator.cpp diff --git a/modems/m17/FreqDevEstimator.h b/modemm17/FreqDevEstimator.h similarity index 98% rename from modems/m17/FreqDevEstimator.h rename to modemm17/FreqDevEstimator.h index 92ba59405..284c91c7b 100644 --- a/modems/m17/FreqDevEstimator.h +++ b/modemm17/FreqDevEstimator.h @@ -26,7 +26,7 @@ namespace modemm17 { * Estimates are expected to be updated at each sync word. But they can * be updated more frequently, such as during the preamble. */ -class M17_API FreqDevEstimator +class MODEMM17_API FreqDevEstimator { using sample_filter_t = BaseIirFilter<3>; diff --git a/modems/m17/FrequencyError.h b/modemm17/FrequencyError.h similarity index 100% rename from modems/m17/FrequencyError.h rename to modemm17/FrequencyError.h diff --git a/modems/m17/Fsk4Demod.h b/modemm17/Fsk4Demod.h similarity index 100% rename from modems/m17/Fsk4Demod.h rename to modemm17/Fsk4Demod.h diff --git a/modems/m17/Golay24.cpp b/modemm17/Golay24.cpp similarity index 100% rename from modems/m17/Golay24.cpp rename to modemm17/Golay24.cpp diff --git a/modems/m17/Golay24.h b/modemm17/Golay24.h similarity index 98% rename from modems/m17/Golay24.h rename to modemm17/Golay24.h index 630f6cef0..fe07166ad 100644 --- a/modems/m17/Golay24.h +++ b/modemm17/Golay24.h @@ -81,7 +81,7 @@ constexpr array sort(array array) } // Golay24_detail -struct M17_API Golay24 +struct MODEMM17_API Golay24 { #pragma pack(push, 1) struct SyndromeMapEntry diff --git a/modems/m17/IirFilter.h b/modemm17/IirFilter.h similarity index 100% rename from modems/m17/IirFilter.h rename to modemm17/IirFilter.h diff --git a/modems/m17/LinkSetupFrame.h b/modemm17/LinkSetupFrame.h similarity index 100% rename from modems/m17/LinkSetupFrame.h rename to modemm17/LinkSetupFrame.h diff --git a/modems/m17/M17Demodulator.cpp b/modemm17/M17Demodulator.cpp similarity index 100% rename from modems/m17/M17Demodulator.cpp rename to modemm17/M17Demodulator.cpp diff --git a/modems/m17/M17Demodulator.h b/modemm17/M17Demodulator.h similarity index 98% rename from modems/m17/M17Demodulator.h rename to modemm17/M17Demodulator.h index 1603ed274..338a0732a 100644 --- a/modems/m17/M17Demodulator.h +++ b/modemm17/M17Demodulator.h @@ -22,7 +22,7 @@ namespace modemm17 { -struct M17_API M17Demodulator +struct MODEMM17_API M17Demodulator { static const uint16_t SAMPLE_RATE = 48000; static const uint16_t SYMBOL_RATE = 4800; diff --git a/modems/m17/M17FrameDecoder.h b/modemm17/M17FrameDecoder.h similarity index 100% rename from modems/m17/M17FrameDecoder.h rename to modemm17/M17FrameDecoder.h diff --git a/modems/m17/M17Framer.h b/modemm17/M17Framer.h similarity index 100% rename from modems/m17/M17Framer.h rename to modemm17/M17Framer.h diff --git a/modems/m17/M17Modulator.cpp b/modemm17/M17Modulator.cpp similarity index 100% rename from modems/m17/M17Modulator.cpp rename to modemm17/M17Modulator.cpp diff --git a/modems/m17/M17Modulator.h b/modemm17/M17Modulator.h similarity index 100% rename from modems/m17/M17Modulator.h rename to modemm17/M17Modulator.h diff --git a/modems/m17/M17Randomizer.h b/modemm17/M17Randomizer.h similarity index 100% rename from modems/m17/M17Randomizer.h rename to modemm17/M17Randomizer.h diff --git a/modems/m17/M17Synchronizer.h b/modemm17/M17Synchronizer.h similarity index 100% rename from modems/m17/M17Synchronizer.h rename to modemm17/M17Synchronizer.h diff --git a/modems/m17/PhaseEstimator.h b/modemm17/PhaseEstimator.h similarity index 100% rename from modems/m17/PhaseEstimator.h rename to modemm17/PhaseEstimator.h diff --git a/modems/m17/PolynomialInterleaver.h b/modemm17/PolynomialInterleaver.h similarity index 100% rename from modems/m17/PolynomialInterleaver.h rename to modemm17/PolynomialInterleaver.h diff --git a/modems/m17/SlidingDFT.h b/modemm17/SlidingDFT.h similarity index 100% rename from modems/m17/SlidingDFT.h rename to modemm17/SlidingDFT.h diff --git a/modems/m17/SymbolEvm.h b/modemm17/SymbolEvm.h similarity index 100% rename from modems/m17/SymbolEvm.h rename to modemm17/SymbolEvm.h diff --git a/modems/m17/Trellis.h b/modemm17/Trellis.h similarity index 96% rename from modems/m17/Trellis.h rename to modemm17/Trellis.h index 892df360e..5998cb7ef 100644 --- a/modems/m17/Trellis.h +++ b/modemm17/Trellis.h @@ -14,7 +14,7 @@ namespace modemm17 { -inline constexpr std::array make_p1() { +inline std::array make_p1() { std::array result{}; for (size_t i = 0, j = 2; i != 61; ++i) { if (i == j) { @@ -107,7 +107,7 @@ struct CostTable using cost_table_t = std::array, K>; template - static constexpr cost_table_t makeCostTable(const Trellis_& trellis) + static constexpr cost_table_t makeCostTable() { cost_table_t result; for (size_t i = 0; i != K; ++i) diff --git a/modems/m17/Util.h b/modemm17/Util.h similarity index 99% rename from modems/m17/Util.h rename to modemm17/Util.h index 8a18c7b65..cdd159464 100644 --- a/modems/m17/Util.h +++ b/modemm17/Util.h @@ -146,7 +146,10 @@ auto llr(float sample) template auto depunctured(std::array puncture_matrix, std::array in) { - static_assert(M % N == 0); + if (M % N != 0) { + return; + } + std::array result; size_t index = 0; size_t pindex = 0; diff --git a/modems/m17/Viterbi.h b/modemm17/Viterbi.h similarity index 100% rename from modems/m17/Viterbi.h rename to modemm17/Viterbi.h diff --git a/modems/m17/ax25_frame.h b/modemm17/ax25_frame.h similarity index 100% rename from modems/m17/ax25_frame.h rename to modemm17/ax25_frame.h diff --git a/modems/m17/queue.h b/modemm17/queue.h similarity index 100% rename from modems/m17/queue.h rename to modemm17/queue.h diff --git a/modems/CMakeLists.txt b/modems/CMakeLists.txt deleted file mode 100644 index d8babc1d2..000000000 --- a/modems/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -project(modems) - -set(modems_SOURCES - m17/Correlator.cpp - m17/FreqDevEstimator.cpp - m17/Golay24.cpp - m17/M17Demodulator.cpp - m17/M17Modulator.cpp -) - -set(modems_HEADERS - m17/ax25_frame.h - m17/CarrierDetect.h - m17/ClockRecovery.h - m17/Convolution.h - m17/Correlator.h - m17/CRC16.h - m17/DataCarrierDetect.h - m17/DeviationError.h - m17/Filter.h - m17/FirFilter.h - m17/FreqDevEstimator.h - m17/FrequencyError.h - m17/Fsk4Demod.h - m17/Golay24.h - m17/IirFilter.h - m17/LinkSetupFrame.h - m17/M17Demodulator.h - m17/M17FrameDecoder.h - m17/M17Framer.h - m17/M17Modulator.h - m17/M17Randomizer.h - m17/M17Synchronizer.h - m17/PhaseEstimator.h - m17/PolynomialInterleaver.h - m17/queue.h - m17/SlidingDFT.h - m17/SymbolEvm.h - m17/Trellis.h - m17/Util.h - m17/Viterbi.h -) - -include_directories( - ${CMAKE_SOURCE_DIR}/exports -) - -add_library(modems SHARED - ${modems_SOURCES} -) - -target_link_libraries(modems - Qt5::Core -) - -install(TARGETS modems DESTINATION ${INSTALL_LIB_DIR}) diff --git a/plugins/channelrx/CMakeLists.txt b/plugins/channelrx/CMakeLists.txt index 1f8457772..81aec8548 100644 --- a/plugins/channelrx/CMakeLists.txt +++ b/plugins/channelrx/CMakeLists.txt @@ -97,7 +97,7 @@ if (ENABLE_CHANNELRX_DEMODFREEDV AND CODEC2_FOUND) add_subdirectory(demodfreedv) endif() -if (LINUX AND ENABLE_CHANNELRX_DEMODM17 AND CODEC2_FOUND) +if (ENABLE_CHANNELRX_DEMODM17 AND CODEC2_FOUND) add_subdirectory(demodm17) endif() diff --git a/plugins/channelrx/demodm17/CMakeLists.txt b/plugins/channelrx/demodm17/CMakeLists.txt index 68d6d892c..792748365 100644 --- a/plugins/channelrx/demodm17/CMakeLists.txt +++ b/plugins/channelrx/demodm17/CMakeLists.txt @@ -27,7 +27,7 @@ set(m17_HEADERS include_directories( ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${CODEC2_INCLUDE_DIR} - ${CMAKE_SOURCE_DIR}/modems + ${CMAKE_SOURCE_DIR}/modemm17 ) if(NOT SERVER_MODE) @@ -69,7 +69,7 @@ target_link_libraries(${TARGET_NAME} ${TARGET_LIB_GUI} swagger ${CODEC2_LIBRARIES} - modems + modemm17 ) install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER}) diff --git a/plugins/channelrx/demodm17/m17demodprocessor.cpp b/plugins/channelrx/demodm17/m17demodprocessor.cpp index 3ff0acc9c..69eb3d72c 100644 --- a/plugins/channelrx/demodm17/m17demodprocessor.cpp +++ b/plugins/channelrx/demodm17/m17demodprocessor.cpp @@ -25,7 +25,7 @@ #include "audio/audiofifo.h" #include "util/ax25.h" -#include "m17/ax25_frame.h" +#include "ax25_frame.h" #include "m17demod.h" #include "m17demodprocessor.h" diff --git a/plugins/channelrx/demodm17/m17demodprocessor.h b/plugins/channelrx/demodm17/m17demodprocessor.h index 52160b679..4503f33e0 100644 --- a/plugins/channelrx/demodm17/m17demodprocessor.h +++ b/plugins/channelrx/demodm17/m17demodprocessor.h @@ -21,7 +21,7 @@ #include #include "audio/audiocompressor.h" -#include "m17/M17Demodulator.h" +#include "M17Demodulator.h" #include "m17demodfilters.h" class AudioFifo; diff --git a/plugins/channeltx/CMakeLists.txt b/plugins/channeltx/CMakeLists.txt index 4b5a8f90e..c8b81e3b6 100644 --- a/plugins/channeltx/CMakeLists.txt +++ b/plugins/channeltx/CMakeLists.txt @@ -63,6 +63,6 @@ if (ENABLE_CHANNELTX_MODFREEDV AND CODEC2_FOUND) add_subdirectory(modfreedv) endif() -if (LINUX AND ENABLE_CHANNELTX_MODM17 AND CODEC2_FOUND) +if (ENABLE_CHANNELTX_MODM17 AND CODEC2_FOUND) add_subdirectory(modm17) endif() diff --git a/plugins/channeltx/modm17/CMakeLists.txt b/plugins/channeltx/modm17/CMakeLists.txt index 08a086509..889b17f1a 100644 --- a/plugins/channeltx/modm17/CMakeLists.txt +++ b/plugins/channeltx/modm17/CMakeLists.txt @@ -29,7 +29,7 @@ set(modm17_HEADERS include_directories( ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${CODEC2_INCLUDE_DIR} - ${CMAKE_SOURCE_DIR}/modems + ${CMAKE_SOURCE_DIR}/modemm17 ) if(NOT SERVER_MODE) @@ -69,7 +69,7 @@ target_link_libraries(${TARGET_NAME} ${TARGET_LIB_GUI} swagger ${CODEC2_LIBRARIES} - modems + modemm17 ) install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER}) diff --git a/plugins/channeltx/modm17/m17modprocessor.cpp b/plugins/channeltx/modm17/m17modprocessor.cpp index 2d276a4b6..cdce49c9d 100644 --- a/plugins/channeltx/modm17/m17modprocessor.cpp +++ b/plugins/channeltx/modm17/m17modprocessor.cpp @@ -17,7 +17,7 @@ #include -#include "m17/M17Modulator.h" +#include "M17Modulator.h" #include "maincore.h" #include "m17modax25.h" diff --git a/plugins/channeltx/modm17/m17modprocessor.h b/plugins/channeltx/modm17/m17modprocessor.h index 521eaebb6..94c7f2989 100644 --- a/plugins/channeltx/modm17/m17modprocessor.h +++ b/plugins/channeltx/modm17/m17modprocessor.h @@ -21,7 +21,7 @@ #include #include -#include "m17/M17Modulator.h" +#include "M17Modulator.h" #include "dsp/dsptypes.h" #include "util/message.h" #include "util/messagequeue.h"