### Get DSDcc Help Information Source: https://github.com/f4exb/dsdcc/blob/master/Readme.md This command displays the help message for the `dsdccx` binary, providing information on available options and usage. It's a quick way to understand the capabilities and configuration parameters of the DSDcc decoder. ```bash dsdccx -h ``` -------------------------------- ### dsdccx Command-Line Tool Examples Source: https://context7.com/f4exb/dsdcc/llms.txt Demonstrates various ways to use the `dsdccx` command-line utility for decoding different digital voice protocols. Examples cover input/output redirection, protocol selection, and specific decoding options. ```bash # Basic usage - decode from file to audio output sox -t s16 -r 48k -c 1 input.raw -t s16 -r 48k -c 1 - | \ dsdccx -i - -fa -o - | \ play -q -t s16 -r 8k -c 1 - # Decode DMR from UDP stream with both TDMA slots socat stdout udp-listen:9999 | \ dsdccx -i - -fr -T3 -U6 -o - | \ play -q -t s16 -r 48k -c 1 - # Decode D-Star only with verbose output dsdsccx -i input.raw -fd -v 2 -e -o output.raw # Decode dPMR (requires 2400 baud rate) dsdsccx -i dpmr_signal.raw -fm -d0 -o decoded.raw # Decode YSF with status messages to file dsdsccx -i ysf_signal.raw -fy -M status.txt -m 0.5 -o audio.raw # Use ThumbDV hardware decoder dsdsccx -i input.raw -fa -D /dev/ttyUSB0 -o - | play -q -t s16 -r 8k -c 1 - # Decode with position for D-Star distance/bearing calculation dsdsccx -i dstar.raw -fd -P 48.8566 -Q 2.3522 -M status.txt -o audio.raw # Common options: # -i Input file (- for stdin) # -o Output file (- for stdout) # -fa Auto-detect protocol # -fr DMR/MOTOTRBO only # -fd D-Star only # -fm dPMR only # -fy YSF only # -fi NXDN48 only # -fn NXDN96 only # -d <0-2> Data rate: 0=2400, 1=4800, 2=9600 # -T <0-3> TDMA slots: 0=none, 1=slot1, 2=slot2, 3=both # -U <0-7> Upsampling: 0=8k, 6=48k ``` -------------------------------- ### Compile and Install DSDcc Source: https://github.com/f4exb/dsdcc/blob/master/Readme.md Standard make commands to compile the DSDcc project after configuration with CMake. 'make' compiles the code, and 'make install' places the built binaries and libraries in the specified installation directory. ```bash make make -j8 make install ``` -------------------------------- ### Install dsdcc Executable and Library Files (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/CMakeLists.txt This snippet shows how to install the dsdcc executable and library files using CMake. It conditionally installs the 'dsdccx' executable if a build tool is detected. It then installs the 'dsdcc' library to a specified installation directory and the project's header files to the include directory. ```cmake if(BUILD_TOOL) install(TARGETS dsdccx DESTINATION bin) endif(BUILD_TOOL) install(TARGETS dsdcc DESTINATION ${LIB_INSTALL_DIR}) install(FILES ${dsdcc_HEADERS} DESTINATION include/${PROJECT_NAME}) ``` -------------------------------- ### Project Setup and Versioning (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/CMakeLists.txt Initializes the CMake project, sets version information, and defines build options. It configures the C++ standard to C++11 and specifies compiler flags based on the operating system. ```cmake cmake_minimum_required(VERSION 3.5) project(dsdcc) set(MAJOR_VERSION 1) set(MINOR_VERSION 9) set(PATCH_VERSION 0) set(PACKAGE libdsdcc) set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}) set(VERSION ${VERSION_STRING}) option(BUILD_TOOL "Build dsdccx tool" ON) # use c++11 set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # use, i.e. don't skip the full RPATH for the build tree set(CMAKE_SKIP_BUILD_RPATH FALSE) # when building, don't use the install RPATH already # (but later on when installing) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # Compiler flags. if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall ${EXTRA_FLAGS}") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fmax-errors=10 -O2 -ffast-math -ftree-vectorize ${EXTRA_FLAGS}") endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) include(GNUInstallDirs) set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") # "lib" or "lib64" if (BUILD_TYPE MATCHES RELEASE) set(CMAKE_BUILD_TYPE "Release") elseif (BUILD_TYPE MATCHES RELEASEWITHDBGINFO) set(CMAKE_BUILD_TYPE "ReleaseWithDebugInfo") elseif (BUILD_TYPE MATCHES DEBUG) set(CMAKE_BUILD_TYPE "Debug") elseif (BUILD_TYPE MATCHES DEBIAN) set(CMAKE_BUILD_TYPE "Release") set(BUILD_DEBIAN TRUE) else() set(CMAKE_BUILD_TYPE "Release") endif() ``` -------------------------------- ### Install MBELIB Library (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/mbelib/CMakeLists.txt This snippet defines the installation rules for the MBELIB target. It installs the shared library to the 'lib' directory within the destination. ```cmake install(TARGETS mbelib DESTINATION lib) ``` -------------------------------- ### Build DSDcc with mbelib Support (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/Readme.md This command configures the build process for DSDcc using CMake, enabling mbelib support and specifying a custom installation prefix and library paths. It's used for compiling DSDcc with specific dependencies. ```bash cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/dsdcc -DUSE_MBELIB=ON -DLIBMBE_INCLUDE_DIR=/opt/install/mbelib/include -DLIBMBE_LIBRARY=/opt/install/mbelib/lib/libmbe.so .. ``` -------------------------------- ### Build DSDcc with CMake (Bash) Source: https://context7.com/f4exb/dsdcc/llms.txt This snippet demonstrates how to build the DSDcc project using CMake. It covers cloning the repository, creating a build directory, and performing basic builds, builds with mbelib support, and builds with SerialDV support. It also shows how to specify custom installation paths and perform a full build with all options. ```bash # Clone repository git clone https://github.com/f4exb/dsdcc.git cd dsdcc # Create build directory mkdir build && cd build # Basic build without mbelib (MBE frames only, no audio decoding) cmake .. make -j$(nproc) sudo make install # Build with mbelib support (enables software audio decoding) cmake -DUSE_MBELIB=ON .. make -j$(nproc) sudo make install # Build with custom mbelib installation path cmake -DUSE_MBELIB=ON \ -DLIBMBE_INCLUDE_DIR=/opt/install/mbelib/include \ -DLIBMBE_LIBRARY=/opt/install/mbelib/lib/libmbe.so \ .. # Build with SerialDV support for ThumbDV/AMBE3000 cmake -DLIBSERIALDV_INCLUDE_DIR=/opt/install/serialdv/include/serialdv \ -DLIBSERIALDV_LIBRARY=/opt/install/serialdv/lib/libserialdv.so \ .. # Full build with custom prefix, mbelib, and SerialDV cmake -Wno-dev \ -DCMAKE_INSTALL_PREFIX=/opt/install/dsdcc \ -DUSE_MBELIB=ON \ -DLIBMBE_INCLUDE_DIR=/opt/install/mbelib/include \ -DLIBMBE_LIBRARY=/opt/install/mbelib/lib/libmbe.so \ -DLIBSERIALDV_INCLUDE_DIR=/opt/install/serialdv/include/serialdv \ -DLIBSERIALDV_LIBRARY=/opt/install/serialdv/lib/libserialdv.so \ .. make -j$(nproc) sudo make install # Note: For ThumbDV dongles on Linux kernel 4.4.52+, set low latency: # echo 1 | sudo tee /sys/bus/usb-serial/devices/ttyUSB0/latency_timer # Or use: sudo setserial /dev/ttyUSB0 low_latency ``` -------------------------------- ### Build DSDcc without mbelib, with SerialDV Support (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/Readme.md This CMake command configures the DSDcc build without mbelib but with SerialDV support. It sets a custom installation prefix and specifies include and library paths for the SerialDV library, essential for serial device communication. ```bash cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/dsdcc -DLIBSERIALDV_INCLUDE_DIR=/opt/install/serialdv/include/serialdv -DLIBSERIALDV_LIBRARY=/opt/install/serialdv/lib/libserialdv.so ``` -------------------------------- ### Piping Discriminator Samples to dsdccx with SoX and Play Source: https://github.com/f4exb/dsdcc/blob/master/samples/Readme.md This example demonstrates how to pipe a discriminator output sample file (.dis) to the dsdccx utility for decoding. It utilizes the sox utility to read the raw S16LE samples and pipe them to dsdccx, which then pipes its output to the play utility for audio playback. Specific options for dsdccx, such as protocol type and slot, may be required depending on the sample file. ```bash sox -t s16 -r 48k -c 1 dmr_it_8.dis -t s16 -r 48k -c 1 - | /opt/install/dsdcc/bin/dsdccx -T3 -i - -fa -o - | play -q -t s16 -r 8k -c 1 - ``` -------------------------------- ### DSDDecoder Object Initialization (C++) Source: https://github.com/f4exb/dsdcc/blob/master/Readme.md This C++ code snippet illustrates the basic steps for integrating DSDcc into a custom application. It involves allocating a `DSDDecoder` object, setting its options and state, preparing input, and processing samples. ```cpp // 1. Allocate a new DSDDecoder object DSDDecoder* decoder = new DSDDecoder(); // 2. Set the options and state object (example) DSDOpts opts; DSDState state; decoder->setOpts(&opts); decoder->setState(&state); // 3. Prepare the input (e.g., open a file or stream) // ... prepare input stream ... // 4. Get a new sample from the stream // ... get sample data ... float sample = getNextSample(); // 5. Push this sample to the decoder decoder->pushSample(sample); // 6. Check for audio output (with mbelib support) // ... check and process audio output ... ``` -------------------------------- ### Initialize and Run DSDDecoder for Audio Decoding Source: https://context7.com/f4exb/dsdcc/llms.txt This C++ snippet demonstrates how to initialize the DSDDecoder class, configure its settings (like decode mode, gain, and upsampling), and process raw audio samples from an input file. It shows how to push audio samples into the decoder and retrieve decoded audio output. ```cpp #include "dsd_decoder.h" #include int main() { DSDcc::DSDDecoder dsdDecoder; // Configure decoder options dsdDecoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeAuto, true); // Auto-detect protocol dsdDecoder.setAudioGain(1.0f); // Set audio output gain dsdDecoder.setUpsampling(6); // Upsample to 48kHz (0=8kHz, 6=48kHz) dsdDecoder.enableCosineFiltering(true); // Enable matched filter dsdDecoder.enableAudioOut(true); // Enable audio output dsdDecoder.setDataRate(DSDcc::DSDDecoder::DSDRate4800); // 4800 baud (default) // Open input file (S16LE 48kS/s mono samples) std::ifstream inFile("discriminator_samples.raw", std::ios::binary); short sample; while (inFile.read(reinterpret_cast(&sample), sizeof(short))) { // Push sample to decoder dsdDecoder.run(sample); // Check for decoded audio output int nbSamples; short *audioSamples = dsdDecoder.getAudio1(nbSamples); if (nbSamples > 0) { // Write decoded audio to output (S16LE 8kS/s or 48kS/s based on upsampling) // process audioSamples[0..nbSamples-1] dsdDecoder.resetAudio1(); // Reset audio buffer after processing } } return 0; } ``` -------------------------------- ### Run DSDcc Binary with UDP Input and SoX Output Source: https://github.com/f4exb/dsdcc/blob/master/Readme.md This command demonstrates how to run the compiled `dsdccx` binary. It pipes discriminator output samples from a UDP source via `socat` into `dsdccx` and then pipes the processed audio to `play` (part of `sox`) for playback. ```bash socat stdout udp-listen:9999 | /opt/install/dsdcc/bin/dsdccx -i - -fa -o - | play -q -t s16 -r 8k -c 1 - ``` -------------------------------- ### Dependency Handling and Definitions (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/CMakeLists.txt Finds and configures dependencies like LibMbe and SerialDV. It adds preprocessor definitions based on whether these libraries are found and used. ```cmake if (USE_MBELIB) find_package(LibMbe REQUIRED) add_definitions(-DDSD_USE_MBELIB) endif() find_package(SerialDV) if (LIBSERIALDV_FOUND) add_definitions(-DDSD_USE_SERIALDV) endif() ``` -------------------------------- ### DSDcc Integration with DVSI AMBE3000 Serial Device (C++) Source: https://github.com/f4exb/dsdcc/blob/master/Readme.md This C++ code snippet outlines the integration process for DSDcc with a DVSI AMBE3000 based serial device using the `SerialDV` support. It highlights the use of the `DVController` helper class to manage serial communication and audio output. ```cpp // 7. With a DVSI AMBE3000 based serial device and SerialDV support: // a. use DSDcc::DVController helper class with the processDVSerial method DSDcc::DVController dvController; // ... prepare serial data ... dvController.processDVSerial(serialData, dataLength); // b. Check if any audio output is available from the helper class // ... get audio output pointer and number of samples ... const float* audioOutput = nullptr; size_t numSamples = 0; if (dvController.getAudioOutput(&audioOutput, &numSamples)) { // Push these samples to the audio device or the output file or stream // ... process audioOutput ... } ``` -------------------------------- ### Debian Build Specific Configuration (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/CMakeLists.txt Handles specific configurations for building on Debian, including adding subdirectories for mbelib and serialdv, setting definitions, and linking libraries. This block is executed only if BUILD_DEBIAN is true. ```cmake if (BUILD_DEBIAN) add_subdirectory(mbelib) add_subdirectory(serialdv) add_definitions(-DDSD_USE_SERIALDV) include_directories(${LIBSERIALDVSRC}) target_link_libraries(dsdcc serialdv) add_definitions(-DDSD_USE_MBELIB) include_directories(${LIBMBELIBSRC}) target_link_libraries(dsdcc mbelib) endif() ``` -------------------------------- ### Include Directories Configuration (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/CMakeLists.txt Configures include paths for the project, including the source directory, build directory, and directories for external dependencies like LibMbe and SerialDV if they are used. ```cmake include_directories( ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) if (USE_MBELIB) include_directories( ${LIBMBE_INCLUDE_DIR} ) endif() if (LIBSERIALDV_FOUND) include_directories( ${LIBSERIALDV_INCLUDE_DIR} ) endif() ``` -------------------------------- ### Configure Logging and Verbosity in C++ Source: https://context7.com/f4exb/dsdcc/llms.txt Control the output level and destination for decoder logs. Options include setting verbosity, enabling quiet mode, showing error bars, symbol timing, and directing logs to a file. ```cpp #include "dsd_decoder.h" void configureLogging(DSDcc::DSDDecoder& decoder) { // Set verbosity level (0-4) // 0 = quiet, 4 = most verbose decoder.setVerbosity(2); // Quiet mode - suppress frame info and error bars decoder.setQuiet(); // Show error bars in output decoder.showErrorBars(); // Show symbol timing information during sync decoder.showSymbolTiming(); // Log to file instead of stderr decoder.setLogFile("/var/log/dsdcc.log"); // For log verbosity specifically (independent of display) decoder.setLogVerbosity(3); // Access logger instance for custom handling const DSDcc::DSDLogger& logger = decoder.getLogger(); } ``` -------------------------------- ### Add Preprocessor Definitions (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/mbelib/CMakeLists.txt This snippet adds preprocessor definitions for the build. It specifically defines Q_SHARED, likely for Qt shared library usage. ```cmake add_definitions(-DQT_SHARED) ``` -------------------------------- ### Set Include Directories (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/mbelib/CMakeLists.txt This snippet configures the include directories for the build. It adds the current directory, the binary directory, and the source directory for MBELIB headers. ```cmake include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${LIBMBELIBSRC} ) ``` -------------------------------- ### Configure DSDDecoder Protocol Detection Mode Source: https://context7.com/f4exb/dsdcc/llms.txt This C++ function shows how to configure the DSDDecoder's protocol detection mode. It allows setting the decoder to auto-detect all supported protocols or to focus on specific ones like DMR, D-Star, YSF, dPMR, or NXDN at different baud rates. It also demonstrates setting the data rate for specific protocols like dPMR. ```cpp #include "dsd_decoder.h" void configureDecoder(DSDcc::DSDDecoder& decoder, const char* mode) { // First disable all modes decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeNone, true); if (strcmp(mode, "auto") == 0) { // Auto-detect all supported protocols decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeAuto, true); } else if (strcmp(mode, "dmr") == 0) { // DMR/MOTOTRBO only - ETSI two slot TDMA decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeDMR, true); } else if (strcmp(mode, "dstar") == 0) { // D-Star only - Icom amateur radio protocol decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeDStar, true); } else if (strcmp(mode, "ysf") == 0) { // Yaesu System Fusion only decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeYSF, true); } else if (strcmp(mode, "dpmr") == 0) { // dPMR Tier 1/2 (6.25 kHz) - requires 2400 baud rate decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeDPMR, true); decoder.setDataRate(DSDcc::DSDDecoder::DSDRate2400); } else if (strcmp(mode, "nxdn48") == 0) { // NXDN 4800 baud (6.25 kHz) decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeNXDN48, true); } else if (strcmp(mode, "nxdn96") == 0) { // NXDN 9600 baud (12.5 kHz) decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeNXDN96, true); } // Available DSDDecodeMode values: // DSDDecodeAuto - Auto-detect all protocols // DSDDecodeNone - Disable all protocols // DSDDecodeDMR - DMR/MOTOTRBO // DSDDecodeDStar - D-Star // DSDDecodeDPMR - dPMR // DSDDecodeYSF - Yaesu System Fusion // DSDDecodeNXDN48 - NXDN 4800 baud // DSDDecodeNXDN96 - NXDN 9600 baud // DSDDecodeP25P1 - P25 Phase 1 (not fully supported) // DSDDecodeX2TDMA - X2-TDMA (not fully supported) // DSDDecodeProVoice - ProVoice (not fully supported) } ``` -------------------------------- ### Building the dsdcc Library (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/CMakeLists.txt Defines and builds the shared library 'dsdcc' using the specified source and header files. It sets the library's version information and links against external libraries if they are found and enabled. ```cmake add_library(dsdcc SHARED ${dsdcc_SOURCES} ) set_target_properties(dsdcc PROPERTIES VERSION ${VERSION} SOVERSION ${MAJOR_VERSION}) if (USE_MBELIB) target_link_libraries(dsdcc ${LIBMBE_LIBRARY}) endif() if (LIBSERIALDV_FOUND) target_link_libraries(dsdcc ${LIBSERIALDV_LIBRARY}) endif() ``` -------------------------------- ### Configure Serialdv CMake Project Source: https://github.com/f4exb/dsdcc/blob/master/serialdv/CMakeLists.txt This snippet defines the CMake project name, lists source and header files for the 'serialdv' library, and sets up include directories. It also adds a preprocessor definition and creates a shared library. ```cmake project(serialdv) set(serialdv_SOURCES ${LIBSERIALDVSRC}/dvcontroller.cpp ${LIBSERIALDVSRC}/serialdatacontroller.cpp ) set(serialdv_HEADERS ${LIBSERIALDVSRC}/dvcontroller.h ${LIBSERIALDVSRC}/serialdatacontroller.h ) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${LIBSERIALDVSRC} ) add_definitions(-DQT_SHARED) add_library(serialdv SHARED ${serialdv_SOURCES} ) target_link_libraries(serialdv ${LIBUSB_LIBRARIES} ) install(TARGETS serialdv DESTINATION lib) ``` -------------------------------- ### Source and Header File Declaration (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/CMakeLists.txt Lists the source and header files required for the dsdcc library. It conditionally includes additional headers if LibMbe is enabled. ```cmake set(dsdcc_SOURCES descramble.cpp dmr.cpp dsd_decoder.cpp dsd_filters.cpp dsd_logger.cpp dsd_mbe.cpp dsd_opts.cpp dsd_state.cpp dsd_symbol.cpp dsd_sync.cpp dstar.cpp ysf.cpp dpmr.cpp nxdn.cpp nxdnconvolution.cpp nxdncrc.cpp nxdnmessage.cpp p25p1_heuristics.cpp dsd_upsample.cpp fec.cpp viterbi.cpp viterbi3.cpp viterbi5.cpp crc.cpp pn.cpp mbefec.cpp locator.cpp phaselock.cpp timeutil.cpp ) set(dsdcc_HEADERS descramble.h dmr.h dsd_decoder.h dsd_filters.h dsd_logger.h dsd_mbe.h dsd_opts.h dsd_state.h dsd_symbol.h dsd_sync.h dstar.h ysf.h dpmr.h nxdn.h nxdnconvolution.h nxdncrc.h nxdnmessage.h p25p1_heuristics.h dsd_upsample.h runningmaxmin.h doublebuffer.h fec.h viterbi.h viterbi3.h viterbi5.h crc.h pn.h mbefec.h locator.h phaselock.h iirfilter.h timeutil.h export.h ) if (USE_MBELIB) set(dsdcc_headers ${dsdcc_headers} dsd_mbelib.h ) endif() ``` -------------------------------- ### Building the dsdccx Executable (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/CMakeLists.txt Conditionally builds the 'dsdccx' executable if the BUILD_TOOL option is enabled. It specifies the source file and links the dsdcc library to it. ```cmake if(BUILD_TOOL) add_executable(dsdccx dsd_main.cpp ) target_include_directories(dsdccx PUBLIC ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) target_link_libraries(dsdccx dsdcc) endif(BUILD_TOOL) ``` -------------------------------- ### Define MBELIB Library Sources (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/mbelib/CMakeLists.txt This snippet defines the source files for the MBELIB library. It uses the set command to list all C source files located in the ${LIBMBELIBSRC} directory. ```cmake set(mbelib_SOURCES ${LIBMBELIBSRC}/ambe3600x2400.c ${LIBMBELIBSRC}/ambe3600x2450.c ${LIBMBELIBSRC}/ecc.c ${LIBMBELIBSRC}/imbe7100x4400.c ${LIBMBELIBSRC}/imbe7200x4400.c ${LIBMBELIBSRC}/mbelib.c ) ``` -------------------------------- ### Configure FTDI Latency Timer for SerialDV Source: https://github.com/f4exb/dsdcc/blob/master/Readme.md These commands are used to adjust the latency timer for FTDI USB serial devices, which is crucial for the proper functioning of the ThumbDV dongle with SerialDV support. It ensures low latency for AMBE packet flow. ```bash echo 1 | sudo tee /sys/bus/usb-serial/devices/ttyUSB0/latency_timer sudo setserial /dev/ttyUSB0 low_latency ``` -------------------------------- ### Define MBELIB Library Headers (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/mbelib/CMakeLists.txt This snippet defines the header files for the MBELIB library. It uses the set command to list all header files located in the ${LIBMBELIBSRC} directory. ```cmake set(mbelib_HEADERS ${LIBMBELIBSRC}/ambe3600x2400_const.h ${LIBMBELIBSRC}/ambe3600x2450_const.h ${LIBMBELIBSRC}/ecc_const.h ${LIBMBELIBSRC}/imbe7200x4400_const.h ${LIBMBELIBSRC}/mbelib.h ${LIBMBELIBSRC}/mbelib_const.h ) ``` -------------------------------- ### Pkg-Config File Generation (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/CMakeLists.txt Generates a pkg-config file ('libdsdcc.pc') for the dsdcc library. It formats variables for requires, CFLAGS, and LIBS, and configures the output file using a template. ```cmake ######################################################################## # Create Pkg Config File ######################################################################## # use space-separation format for the pc file STRING(REPLACE ";" " " DSDCC_PC_REQUIRES "${DSDCC_PC_REQUIRES}") STRING(REPLACE ";" " " DSDCC_PC_CFLAGS "${DSDCC_PC_CFLAGS}") STRING(REPLACE ";" " " DSDCC_PC_LIBS "${DSDCC_PC_LIBS}") # unset these vars to avoid hard-coded paths to cross environment IF(CMAKE_CROSSCOMPILING) UNSET(DSDCC_PC_CFLAGS) UNSET(DSDCC_PC_LIBS) ENDIF(CMAKE_CROSSCOMPILING) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libdsdcc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/libdsdcc.pc @ONLY) INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/libdsdcc.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig ) ``` -------------------------------- ### Configure Audio Output Parameters Source: https://context7.com/f4exb/dsdcc/llms.txt Configures various audio output parameters for the DSD decoder, including gain, upsampling, stereo mode, and high-pass filtering. This function allows for fine-tuning audio quality and output format. ```cpp #include "dsd_decoder.h" void configureAudioOutput(DSDcc::DSDDecoder& decoder) { // Audio gain: 0 = auto gain, -1 = disabled, >0 = fixed gain multiplier decoder.setAudioGain(0.0f); // Auto gain // Upsampling factor for output: // 0 = no upsampling (8kS/s output) // 2-5 = upsample to 16k/24k/32k/40k // 6 = standard upsampling to 48kS/s (recommended) // 7 = 7x upsampling (trades audio drops for quality) decoder.setUpsampling(6); // Stereo output (duplicate samples to L+R channels) decoder.setStereo(true); decoder.setTDMAStereo(true); // Separate TDMA slots to L/R channels // Enable high-pass filter for cleaner audio with mbelib decoder.useHPMbelib(true); // Unvoiced speech quality (0-4, default 3) decoder.setUvQuality(3); // Enable/disable audio output entirely decoder.enableAudioOut(true); // Enable/disable cosine matched filter for symbol detection decoder.enableCosineFiltering(true); } ``` -------------------------------- ### Hardware Decode with DVSI AMBE3000 via SerialDV Source: https://context7.com/f4exb/dsdcc/llms.txt Supports DVSI AMBE3000 hardware decoding using the MBE DV frame interface. It retrieves raw encoded frames instead of software-decoded audio, allowing for hardware-accelerated decoding. Requires DSD_USE_SERIALDV to be defined and includes dvcontroller.h and dsd_decoder.h. ```cpp #include "dsd_decoder.h" #ifdef DSD_USE_SERIALDV #include "dvcontroller.h" void processWithSerialDV(DSDcc::DSDDecoder& decoder, const char* serialDevice, short* inputSamples, int numSamples, short* outputAudio, int& outputLen) { SerialDV::DVController dvController; short dvAudioSamples[SerialDV::MBE_AUDIO_BLOCK_SIZE]; outputLen = 0; // Open serial device (e.g., /dev/ttyUSB0) if (!dvController.open(serialDevice)) { fprintf(stderr, "Failed to open serial device\n"); return; } // Disable mbelib software decoding when using hardware decoder.enableMbelib(false); for (int i = 0; i < numSamples; i++) { decoder.run(inputSamples[i]); // Check if MBE encoded frame is ready for slot 1 if (decoder.mbeDVReady1()) { // Get the raw MBE encoded frame (9 or 18 bytes depending on protocol) const unsigned char* mbeFrame = decoder.getMbeDVFrame1(); DSDcc::DSDDecoder::DSDMBERate mbeRate = decoder.getMbeRate(); // Decode using hardware AMBE3000 chip dvController.decode(dvAudioSamples, mbeFrame, (SerialDV::DVRate)mbeRate, 0); // 0 dB gain // Copy decoded audio to output memcpy(outputAudio + outputLen, dvAudioSamples, SerialDV::MBE_AUDIO_BLOCK_BYTES); outputLen += SerialDV::MBE_AUDIO_BLOCK_SIZE; decoder.resetMbeDV1(); } // Similarly for slot 2 in TDMA modes if (decoder.mbeDVReady2()) { const unsigned char* mbeFrame2 = decoder.getMbeDVFrame2(); dvController.decode(dvAudioSamples, mbeFrame2, (SerialDV::DVRate)decoder.getMbeRate(), 0); memcpy(outputAudio + outputLen, dvAudioSamples, SerialDV::MBE_AUDIO_BLOCK_BYTES); outputLen += SerialDV::MBE_AUDIO_BLOCK_SIZE; decoder.resetMbeDV2(); } } dvController.close(); } #endif ``` -------------------------------- ### Access YSF Protocol Information in C++ Source: https://context7.com/f4exb/dsdcc/llms.txt Retrieve detailed information about Yaesu System Fusion (YSF) communications, including frame data, callsigns, and network parameters. This function requires an initialized DSDDecoder object. ```cpp #include "dsd_decoder.h" void getYSFInfo(DSDcc::DSDDecoder& decoder) { const DSDcc::DSDYSF& ysfDecoder = decoder.getYSFDecoder(); // Get FICH (Frame Information Channel) data const DSDcc::DSDYSF::FICH& fich = ysfDecoder.getFICH(); // Frame information type DSDcc::DSDYSF::FrameInformation frameInfo = fich.getFrameInformation(); // FIHeader, FICommunication, FITerminator, FITest // Call mode DSDcc::DSDYSF::CallMode callMode = fich.getCallMode(); // CMGroupCQ, CMRadioID, CMReserved, CMIndividual // Data type DSDcc::DSDYSF::DataType dataType = fich.getDataType(); // DTVoiceData1, DTDataFullRate, DTVoiceData2, DTVoiceFullRate // Frame/block counts int frameNum = fich.getFrameNumber(); int frameTotal = fich.getFrameTotal(); int blockNum = fich.getBlockNumber(); int blockTotal = fich.getBlockTotal(); // Communication parameters bool narrowMode = fich.isNarrowMode(); // Narrow (true) or Wide (false) band bool internetPath = fich.isInternetPath(); // Internet or local path bool squelchEnabled = fich.isSquelchCodeEnabled(); int squelchCode = fich.getSquelchCode(); // 0-127 // Callsign information const char* dest = ysfDecoder.getDest(); // Destination callsign const char* src = ysfDecoder.getSrc(); // Source callsign const char* downlink = ysfDecoder.getDownlink(); // Downlink repeater const char* uplink = ysfDecoder.getUplink(); // Uplink repeater // Radio ID mode if (ysfDecoder.radioIdMode()) { const char* destId = ysfDecoder.getDestId(); const char* srcId = ysfDecoder.getSrcId(); printf("YSF Radio ID: %s -> %s\n", srcId, destId); } printf("YSF: %s -> %s [%s/%s] Frame %d/%d\n", src, dest, downlink, uplink, frameNum, frameTotal); } ``` -------------------------------- ### Access D-Star Protocol Information Source: https://context7.com/f4exb/dsdcc/llms.txt Provides access to D-Star specific protocol information, including callsigns, repeater details, slow data text, and GPS/locator data. This is useful for applications that need to parse and display D-Star communications. ```cpp #include "dsd_decoder.h" void getDStarInfo(DSDcc::DSDDecoder& decoder) { // Get the D-Star decoder instance const DSDcc::DSDDstar& dstarDecoder = decoder.getDStarDecoder(); // Callsign information const std::string& myCall = dstarDecoder.getMySign(); // Origin callsign (MY) const std::string& yourCall = dstarDecoder.getYourSign(); // Destination (YOUR/UR) const std::string& rpt1 = dstarDecoder.getRpt1(); // Origin repeater (RPT1) const std::string& rpt2 = dstarDecoder.getRpt2(); // Destination repeater (RPT2) // Slow data information (transmitted in voice frames) const char* infoText = dstarDecoder.getInfoText(); // 20-char info text // GPS/Locator information const char* locator = dstarDecoder.getLocator(); // 6-char Maidenhead locator int bearing = dstarDecoder.getBearing(); // Bearing to station (degrees) float distance = dstarDecoder.getDistance(); // Distance to station (km) printf("D-Star: %s -> %s via %s/%s\n", myCall.c_str(), yourCall.c_str(), rpt1.c_str(), rpt2.c_str()); printf("Info: %s, Locator: %s, Bearing: %d, Distance: %.1f km\n", infoText, locator, bearing, distance); } // Set your own position for bearing/distance calculations void setMyPosition(DSDcc::DSDDecoder& decoder, float latitude, float longitude) { // Latitude: positive = North, negative = South // Longitude: positive = East, negative = West decoder.setMyPoint(latitude, longitude); } ``` -------------------------------- ### Link Libraries for MBELIB (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/mbelib/CMakeLists.txt This snippet specifies the libraries to be linked with the MBELIB target. Currently, it's empty, indicating no external libraries are linked by default. ```cmake target_link_libraries(mbelib ) ``` -------------------------------- ### Create MBELIB Shared Library (CMake) Source: https://github.com/f4exb/dsdcc/blob/master/mbelib/CMakeLists.txt This snippet creates a shared library named 'mbelib'. It specifies the source files to be compiled into the library. ```cmake add_library(mbelib SHARED ${mbelib_SOURCES} ) ``` -------------------------------- ### Retrieve Decoder Status and Signal Information Source: https://context7.com/f4exb/dsdcc/llms.txt Retrieves real-time status information from the DSD decoder, including sync type, frame details, signal strength, and protocol-specific data. This function is essential for monitoring the decoding process. ```cpp #include "dsd_decoder.h" void getDecoderStatus(DSDcc::DSDDecoder& decoder) { // Get current sync type DSDcc::DSDDecoder::DSDSyncType syncType = decoder.getSyncType(); // Possible values: DSDSyncDMRDataP, DSDSyncDMRVoiceP, DSDSyncDStarP, // DSDSyncYSF, DSDSyncDPMR, DSDSyncNXDNP, etc. // Get station type (base station or mobile station) DSDcc::DSDDecoder::DSDStationType stationType = decoder.getStationType(); // Values: DSDBaseStation, DSDMobileStation, DSDStationTypeNotApplicable // Get frame type and subtype text descriptions const char* frameType = decoder.getFrameTypeText(); const char* frameSubtype = decoder.getFrameSubtypeText(); // Signal level and quality metrics int inputLevel = decoder.getInLevel(); // Input signal level (0-100) int carrierPos = decoder.getCarrierPos(); // Carrier position offset int zeroCrossing = decoder.getZeroCrossingPos(); // Zero crossing position int syncQuality = decoder.getSymbolSyncQuality(); // Symbol sync quality int samplesPerSymbol = decoder.getSamplesPerSymbol(); bool pllLocked = decoder.getSymbolPLLLocked(); // PLL lock status // Data rate DSDcc::DSDDecoder::DSDRate dataRate = decoder.getDataRate(); // Values: DSDRate2400, DSDRate4800, DSDRate9600 // Voice activity indicators bool voice1Active = decoder.getVoice1On(); bool voice2Active = decoder.getVoice2On(); // Get formatted status text (128 char buffer) char statusText[128]; decoder.formatStatusText(statusText); printf("Status: %s\n", statusText); } ``` -------------------------------- ### Configure DMR Basic Privacy Decryption in C++ Source: https://context7.com/f4exb/dsdcc/llms.txt Set the DMR Basic Privacy (BP) key for decrypting communications. This function requires an initialized DSDDecoder object and supports keys from 1 to 255. Key 0 disables encryption. ```cpp #include "dsd_decoder.h" void configureDMRPrivacy(DSDcc::DSDDecoder& decoder) { // DMR Basic Privacy uses a key number from 1-255 // Key 0 means no encryption // The actual XOR key is derived from the key number // Set Basic Privacy key number (1-255) decoder.setDMRBasicPrivacyKey(42); // Note: This only works for Basic Privacy (BP) encryption // Enhanced Privacy (EP) and other encryption methods are not supported // To disable decryption, set key to 0 // decoder.setDMRBasicPrivacyKey(0); } ``` -------------------------------- ### Process DMR TDMA Slots with DSDcc Decoder Source: https://context7.com/f4exb/dsdcc/llms.txt Processes two time slots in TDMA mode for DMR signals. It retrieves audio from each slot independently using getAudio1() and getAudio2() and provides access to DMR-specific information like color code and status text. Requires the dsd_decoder.h header. ```cpp #include "dsd_decoder.h" void processDMRWithTDMA(DSDcc::DSDDecoder& decoder, short* inputSamples, int numSamples, short* outputSlot1, int& outLen1, short* outputSlot2, int& outLen2) { outLen1 = 0; outLen2 = 0; decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeNone, true); decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeDMR, true); for (int i = 0; i < numSamples; i++) { decoder.run(inputSamples[i]); // Get audio from slot 1 int nbSamples1; short *audio1 = decoder.getAudio1(nbSamples1); if (nbSamples1 > 0) { memcpy(outputSlot1 + outLen1, audio1, nbSamples1 * sizeof(short)); outLen1 += nbSamples1; decoder.resetAudio1(); } // Get audio from slot 2 int nbSamples2; short *audio2 = decoder.getAudio2(nbSamples2); if (nbSamples2 > 0) { memcpy(outputSlot2 + outLen2, audio2, nbSamples2 * sizeof(short)); outLen2 += nbSamples2; decoder.resetAudio2(); } } // Check voice activity on each slot bool slot1Active = decoder.getVoice1On(); bool slot2Active = decoder.getVoice2On(); // Get DMR-specific information const DSDcc::DSDDMR& dmrDecoder = decoder.getDMRDecoder(); unsigned char colorCode = dmrDecoder.getColorCode(); const char* slot0Text = dmrDecoder.getSlot0Text(); // Status text for slot 1 const char* slot1Text = dmrDecoder.getSlot1Text(); // Status text for slot 2 } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.