mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-07-08 18:15:21 +02:00
Compare commits
1 Commits
debug
...
new_source
Author | SHA1 | Date | |
---|---|---|---|
c488d72ce2 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -7,8 +7,6 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
# WARNING: Filling out the template below is NOT optional. Issues not filling out this template will be closed without review.
|
||||
|
||||
FIRST: Before reporting any bug, make sure that the bug you are reporting has not been reported before. Also, try to use the [nightly version](https://www.sdrpp.org/nightly) if possible in case I've already fixed the bug.
|
||||
|
||||
**Hardware**
|
||||
|
4
.github/pull_request_template.md
vendored
4
.github/pull_request_template.md
vendored
@ -1,4 +0,0 @@
|
||||
# Important
|
||||
|
||||
Only bandplan, colormaps and themes are accepted. Code pull requests are **NOT welcome**.
|
||||
Open an issue requesting a feature or discussing a possible bugfix instead.
|
246
.github/workflows/build_all.yml
vendored
246
.github/workflows/build_all.yml
vendored
@ -18,7 +18,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/build
|
||||
@ -34,13 +34,13 @@ jobs:
|
||||
|
||||
- name: Patch Pothos with earlier libusb version
|
||||
working-directory: ${{runner.workspace}}
|
||||
run: 7z x libusb.7z -olibusb_old ; rm "C:/Program Files/PothosSDR/bin/libusb-1.0.dll" ; cp "libusb_old/MS64/dll/libusb-1.0.dll" "C:/Program Files/PothosSDR/bin/" ; rm "C:/Program Files/PothosSDR/lib/libusb-1.0.lib" ; cp "libusb_old/MS64/dll/libusb-1.0.lib" "C:/Program Files/PothosSDR/lib/"
|
||||
run: 7z x libusb.7z -olibusb_old ; rm "C:/Program Files/PothosSDR/bin/libusb-1.0.dll" ; cp "libusb_old/MS64/dll/libusb-1.0.dll" "C:/Program Files/PothosSDR/bin/"
|
||||
|
||||
- name: Download SDRPlay API
|
||||
run: Invoke-WebRequest -Uri "https://www.sdrpp.org/SDRplay.zip" -OutFile ${{runner.workspace}}/SDRplay.zip
|
||||
run: Invoke-WebRequest -Uri "https://drive.google.com/uc?id=12UHPMwkfa67A11QZDmpCT4iwHnyJHWuu" -OutFile ${{runner.workspace}}/SDRPlay.zip
|
||||
|
||||
- name: Install SDRPlay API
|
||||
run: 7z x ${{runner.workspace}}/SDRplay.zip -o"C:/Program Files/"
|
||||
run: 7z x ${{runner.workspace}}/SDRPlay.zip -o"C:/Program Files/"
|
||||
|
||||
- name: Download codec2
|
||||
run: git clone https://github.com/AlexandreRouma/codec2
|
||||
@ -58,72 +58,65 @@ jobs:
|
||||
run: mkdir "C:/Program Files/codec2" ; mkdir "C:/Program Files/codec2/include" ; mkdir "C:/Program Files/codec2/include/codec2" ; mkdir "C:/Program Files/codec2/lib" ; cd "codec2" ; xcopy "src" "C:/Program Files/codec2/include" ; cd "build" ; xcopy "src" "C:/Program Files/codec2/lib" ; xcopy "codec2" "C:/Program Files/codec2/include/codec2"
|
||||
|
||||
- name: Install vcpkg dependencies
|
||||
run: vcpkg install fftw3:x64-windows glfw3:x64-windows portaudio:x64-windows zstd:x64-windows libusb:x64-windows
|
||||
run: vcpkg install fftw3:x64-windows glfw3:x64-windows portaudio:x64-windows zstd:x64-windows
|
||||
|
||||
- name: Install rtaudio
|
||||
run: git clone https://github.com/thestk/rtaudio ; cd rtaudio ; git checkout 2f2fca4502d506abc50f6d4473b2836d24cfb1e3 ; mkdir build ; cd build ; cmake .. ; cmake --build . --config Release ; cmake --install .
|
||||
|
||||
- name: Install libperseus-sdr
|
||||
run: git clone https://github.com/AlexandreRouma/libperseus-sdr ; cd libperseus-sdr ; mkdir build ; cd build ; cmake "-DLIBUSB_LIBRARIES=C:/Program Files/PothosSDR/lib/libusb-1.0.lib" "-DLIBUSB_INCLUDE_DIRS=C:/Program Files/PothosSDR/include/libusb-1.0" .. "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" ; cmake --build . --config Release ; mkdir "C:/Program Files/PothosSDR/include/perseus-sdr" ; cp Release/perseus-sdr.dll "C:/Program Files/PothosSDR/bin" ; cp Release/perseus-sdr.lib "C:/Program Files/PothosSDR/bin" ; cd .. ; xcopy "src" "C:/Program Files/PothosSDR/include/perseus-sdr"
|
||||
|
||||
- name: Prepare CMake
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: cmake "$Env:GITHUB_WORKSPACE" "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=Debug -DCOPY_MSVC_REDISTRIBUTABLES=ON -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_PERSEUS_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
|
||||
run: cmake "$Env:GITHUB_WORKSPACE" "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: cmake --build . --config Debug --verbose
|
||||
|
||||
- name: Run tests
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: ./Debug/min_broken.exe
|
||||
run: cmake --build . --config Release --verbose
|
||||
|
||||
- name: Create Archive
|
||||
working-directory: ${{runner.workspace}}
|
||||
run: '&($Env:GITHUB_WORKSPACE + "/make_windows_package.ps1") ./build ($Env:GITHUB_WORKSPACE + "/root")'
|
||||
|
||||
- name: Save Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_windows_x64
|
||||
path: ${{runner.workspace}}/sdrpp_windows_x64.zip
|
||||
|
||||
build_macos_intel:
|
||||
runs-on: macos-12
|
||||
build_macos:
|
||||
runs-on: macos-11
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/build
|
||||
|
||||
- name: Update brew repositories
|
||||
run: brew update
|
||||
|
||||
- name: Fix stuff
|
||||
run: rm -f /usr/local/bin/2to3* /usr/local/bin/idle3* /usr/local/bin/pydoc3* /usr/local/bin/python3* /usr/local/bin/python3-config* && brew reinstall gettext
|
||||
|
||||
- name: Install dependencies
|
||||
run: brew install pkg-config libusb fftw glfw airspy airspyhf portaudio hackrf libbladerf codec2 zstd autoconf automake libtool && pip3 install mako
|
||||
run: brew install pkg-config libusb fftw glfw airspy airspyhf portaudio hackrf rtl-sdr libbladerf codec2 zstd && pip3 install mako
|
||||
|
||||
- name: Install volk
|
||||
run: git clone --recursive https://github.com/gnuradio/volk && cd volk && mkdir build && cd build && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
run: git clone --recursive https://github.com/gnuradio/volk && cd volk && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
|
||||
- name: Install SDRplay API
|
||||
run: wget https://www.sdrplay.com/software/SDRplayAPI-macos-installer-universal-3.15.0.pkg && sudo installer -pkg SDRplayAPI-macos-installer-universal-3.15.0.pkg -target /
|
||||
run: wget https://www.sdrplay.com/software/SDRplay_RSP_API-MacOSX-3.07.3.pkg && sudo installer -pkg SDRplay_RSP_API-MacOSX-3.07.3.pkg -target /
|
||||
|
||||
- name: Install libiio
|
||||
run: wget https://github.com/analogdevicesinc/libiio/archive/refs/tags/v0.25.zip && 7z x v0.25.zip && cd libiio-0.25 && mkdir build && cd build && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
run: git clone https://github.com/analogdevicesinc/libiio && cd libiio && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
|
||||
- name: Install libad9361
|
||||
run: git clone https://github.com/analogdevicesinc/libad9361-iio && cd libad9361-iio && mkdir build && cd build && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
run: git clone https://github.com/analogdevicesinc/libad9361-iio && cd libad9361-iio && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
|
||||
- name: Install LimeSuite
|
||||
run: git clone https://github.com/myriadrf/LimeSuite && cd LimeSuite && mkdir builddir && cd builddir && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
|
||||
- name: Install libperseus
|
||||
run: git clone https://github.com/Microtelecom/libperseus-sdr && cd libperseus-sdr && autoreconf -i && ./configure --prefix=/usr/local && make && make install && cd ..
|
||||
|
||||
- name: Install more recent librtlsdr
|
||||
run: git clone https://github.com/osmocom/rtl-sdr && cd rtl-sdr && mkdir build && cd build && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 LIBRARY_PATH=$(pkg-config --libs-only-L libusb-1.0 | sed 's/\-L//') && sudo make install && cd ../../
|
||||
run: git clone https://github.com/myriadrf/LimeSuite && cd LimeSuite && mkdir builddir && cd builddir && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
|
||||
- name: Prepare CMake
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 $GITHUB_WORKSPACE -DOPT_BUILD_PLUTOSDR_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_AUDIO_SINK=OFF -DOPT_BUILD_PORTAUDIO_SINK=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON -DOPT_BUILD_AUDIO_SOURCE=OFF -DUSE_BUNDLE_DEFAULTS=ON -DCMAKE_BUILD_TYPE=Release
|
||||
run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_PLUTOSDR_SOURCE=ON -DOPT_BUILD_SOAPY_SOURCE=OFF -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_AUDIO_SINK=OFF -DOPT_BUILD_PORTAUDIO_SINK=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_AUDIO_SOURCE=OFF -DUSE_BUNDLE_DEFAULTS=ON -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
@ -134,68 +127,17 @@ jobs:
|
||||
run: cd $GITHUB_WORKSPACE && sh make_macos_bundle.sh ${{runner.workspace}}/build ./SDR++.app && zip -r ${{runner.workspace}}/sdrpp_macos_intel.zip SDR++.app
|
||||
|
||||
- name: Save Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_macos_intel
|
||||
path: ${{runner.workspace}}/sdrpp_macos_intel.zip
|
||||
|
||||
build_macos_arm:
|
||||
runs-on: macos-14
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/build
|
||||
|
||||
- name: Install dependencies
|
||||
run: brew install pkg-config libusb fftw glfw airspy airspyhf portaudio hackrf libbladerf codec2 zstd autoconf automake libtool && pip3 install mako --break-system-packages
|
||||
|
||||
- name: Install volk
|
||||
run: git clone --recursive https://github.com/gnuradio/volk && cd volk && mkdir build && cd build && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
|
||||
- name: Install SDRplay API
|
||||
run: wget https://www.sdrplay.com/software/SDRplayAPI-macos-installer-universal-3.15.0.pkg && sudo installer -pkg SDRplayAPI-macos-installer-universal-3.15.0.pkg -target /
|
||||
|
||||
- name: Install libiio
|
||||
run: wget https://github.com/analogdevicesinc/libiio/archive/refs/tags/v0.25.zip && 7z x v0.25.zip && cd libiio-0.25 && mkdir build && cd build && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
|
||||
- name: Install libad9361
|
||||
run: git clone https://github.com/analogdevicesinc/libad9361-iio && cd libad9361-iio && mkdir build && cd build && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
|
||||
- name: Install LimeSuite
|
||||
run: git clone https://github.com/myriadrf/LimeSuite && cd LimeSuite && mkdir builddir && cd builddir && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
|
||||
|
||||
# - name: Install libperseus
|
||||
# run: git clone https://github.com/Microtelecom/libperseus-sdr && cd libperseus-sdr && autoreconf -i && ./configure --prefix=/usr/local && make && make install && cd ..
|
||||
|
||||
- name: Install more recent librtlsdr
|
||||
run: git clone https://github.com/osmocom/rtl-sdr && cd rtl-sdr && mkdir build && cd build && cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_BUILD_TYPE=Release .. && make -j3 LIBRARY_PATH=$(pkg-config --libs-only-L libusb-1.0 | sed 's/\-L//') && sudo make install && cd ../../
|
||||
|
||||
- name: Prepare CMake
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 $GITHUB_WORKSPACE -DOPT_BUILD_PLUTOSDR_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_AUDIO_SINK=OFF -DOPT_BUILD_PORTAUDIO_SINK=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=OFF -DOPT_BUILD_PERSEUS_SOURCE=OFF -DOPT_BUILD_AUDIO_SOURCE=OFF -DUSE_BUNDLE_DEFAULTS=ON -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: make VERBOSE=1 -j3
|
||||
|
||||
- name: Create Archive
|
||||
working-directory: ${{runner.workspace}}
|
||||
run: cd $GITHUB_WORKSPACE && sh make_macos_bundle.sh ${{runner.workspace}}/build ./SDR++.app && zip -r ${{runner.workspace}}/sdrpp_macos_arm.zip SDR++.app
|
||||
|
||||
- name: Save Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sdrpp_macos_arm
|
||||
path: ${{runner.workspace}}/sdrpp_macos_arm.zip
|
||||
|
||||
|
||||
build_debian_buster:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Docker Image
|
||||
run: cd $GITHUB_WORKSPACE/docker_builds/debian_buster && docker build . --tag sdrpp_build
|
||||
|
||||
@ -207,7 +149,7 @@ jobs:
|
||||
run: docker cp build:/root/SDRPlusPlus/sdrpp_debian_amd64.deb ./
|
||||
|
||||
- name: Save Deb Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_debian_buster_amd64
|
||||
path: ${{runner.workspace}}/sdrpp_debian_amd64.deb
|
||||
@ -216,7 +158,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Docker Image
|
||||
run: cd $GITHUB_WORKSPACE/docker_builds/debian_bullseye && docker build . --tag sdrpp_build
|
||||
@ -229,38 +171,16 @@ jobs:
|
||||
run: docker cp build:/root/SDRPlusPlus/sdrpp_debian_amd64.deb ./
|
||||
|
||||
- name: Save Deb Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_debian_bullseye_amd64
|
||||
path: ${{runner.workspace}}/sdrpp_debian_amd64.deb
|
||||
|
||||
build_debian_bookworm:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Create Docker Image
|
||||
run: cd $GITHUB_WORKSPACE/docker_builds/debian_bookworm && docker build . --tag sdrpp_build
|
||||
|
||||
- name: Run Container
|
||||
run: docker run --name build -v $GITHUB_WORKSPACE:/root/SDRPlusPlus --env BUILD_NO="-$GITHUB_RUN_NUMBER" sdrpp_build /root/do_build.sh
|
||||
|
||||
- name: Recover Deb Archive
|
||||
working-directory: ${{runner.workspace}}
|
||||
run: docker cp build:/root/SDRPlusPlus/sdrpp_debian_amd64.deb ./
|
||||
|
||||
- name: Save Deb Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sdrpp_debian_bookworm_amd64
|
||||
path: ${{runner.workspace}}/sdrpp_debian_amd64.deb
|
||||
|
||||
build_debian_sid:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Docker Image
|
||||
run: cd $GITHUB_WORKSPACE/docker_builds/debian_sid && docker build . --tag sdrpp_build
|
||||
@ -273,16 +193,38 @@ jobs:
|
||||
run: docker cp build:/root/SDRPlusPlus/sdrpp_debian_amd64.deb ./
|
||||
|
||||
- name: Save Deb Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_debian_sid_amd64
|
||||
path: ${{runner.workspace}}/sdrpp_debian_amd64.deb
|
||||
|
||||
# build_ubuntu_bionic:
|
||||
# runs-on: ubuntu-latest
|
||||
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
|
||||
# - name: Create Docker Image
|
||||
# run: cd $GITHUB_WORKSPACE/docker_builds/ubuntu_bionic && docker build . --tag sdrpp_build
|
||||
|
||||
# - name: Run Container
|
||||
# run: docker run --name build -v $GITHUB_WORKSPACE:/root/SDRPlusPlus --env BUILD_NO="-$GITHUB_RUN_NUMBER" sdrpp_build /root/do_build.sh
|
||||
|
||||
# - name: Recover Deb Archive
|
||||
# working-directory: ${{runner.workspace}}
|
||||
# run: docker cp build:/root/SDRPlusPlus/sdrpp_debian_amd64.deb ./
|
||||
|
||||
# - name: Save Deb Archive
|
||||
# uses: actions/upload-artifact@v3
|
||||
# with:
|
||||
# name: sdrpp_ubuntu_bionic_amd64
|
||||
# path: ${{runner.workspace}}/sdrpp_debian_amd64.deb
|
||||
|
||||
build_ubuntu_focal:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Docker Image
|
||||
run: cd $GITHUB_WORKSPACE/docker_builds/ubuntu_focal && docker build . --tag sdrpp_build
|
||||
@ -295,7 +237,7 @@ jobs:
|
||||
run: docker cp build:/root/SDRPlusPlus/sdrpp_debian_amd64.deb ./
|
||||
|
||||
- name: Save Deb Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_ubuntu_focal_amd64
|
||||
path: ${{runner.workspace}}/sdrpp_debian_amd64.deb
|
||||
@ -304,7 +246,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Docker Image
|
||||
run: cd $GITHUB_WORKSPACE/docker_builds/ubuntu_jammy && docker build . --tag sdrpp_build
|
||||
@ -317,67 +259,23 @@ jobs:
|
||||
run: docker cp build:/root/SDRPlusPlus/sdrpp_debian_amd64.deb ./
|
||||
|
||||
- name: Save Deb Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_ubuntu_jammy_amd64
|
||||
path: ${{runner.workspace}}/sdrpp_debian_amd64.deb
|
||||
|
||||
build_ubuntu_mantic:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Create Docker Image
|
||||
run: cd $GITHUB_WORKSPACE/docker_builds/ubuntu_mantic && docker build . --tag sdrpp_build
|
||||
|
||||
- name: Run Container
|
||||
run: docker run --name build -v $GITHUB_WORKSPACE:/root/SDRPlusPlus --env BUILD_NO="-$GITHUB_RUN_NUMBER" sdrpp_build /root/do_build.sh
|
||||
|
||||
- name: Recover Deb Archive
|
||||
working-directory: ${{runner.workspace}}
|
||||
run: docker cp build:/root/SDRPlusPlus/sdrpp_debian_amd64.deb ./
|
||||
|
||||
- name: Save Deb Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sdrpp_ubuntu_mantic_amd64
|
||||
path: ${{runner.workspace}}/sdrpp_debian_amd64.deb
|
||||
|
||||
build_ubuntu_noble:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Create Docker Image
|
||||
run: cd $GITHUB_WORKSPACE/docker_builds/ubuntu_noble && docker build . --tag sdrpp_build
|
||||
|
||||
- name: Run Container
|
||||
run: docker run --name build -v $GITHUB_WORKSPACE:/root/SDRPlusPlus --env BUILD_NO="-$GITHUB_RUN_NUMBER" sdrpp_build /root/do_build.sh
|
||||
|
||||
- name: Recover Deb Archive
|
||||
working-directory: ${{runner.workspace}}
|
||||
run: docker cp build:/root/SDRPlusPlus/sdrpp_debian_amd64.deb ./
|
||||
|
||||
- name: Save Deb Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sdrpp_ubuntu_noble_amd64
|
||||
path: ${{runner.workspace}}/sdrpp_debian_amd64.deb
|
||||
|
||||
build_raspios_bullseye_armhf:
|
||||
runs-on: ARM
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Create Build Environment
|
||||
run: rm -rf ${{runner.workspace}}/build && cmake -E make_directory ${{runner.workspace}}/build
|
||||
|
||||
- name: Prepare CMake
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
@ -388,7 +286,7 @@ jobs:
|
||||
run: sh $GITHUB_WORKSPACE/make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk2-dev, librtaudio-dev' && mv sdrpp_debian_amd64.deb sdrpp_debian_armhf.deb
|
||||
|
||||
- name: Save Deb Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_raspios_bullseye_armhf
|
||||
path: ${{runner.workspace}}/sdrpp_debian_armhf.deb
|
||||
@ -397,7 +295,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Fetch container
|
||||
working-directory: ${{runner.workspace}}
|
||||
@ -415,37 +313,33 @@ jobs:
|
||||
run: docker cp build:/root/SDRPlusPlus/android/app/build/outputs/apk/debug/app-debug.apk ./ && mv app-debug.apk sdrpp.apk
|
||||
|
||||
- name: Save APK
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_android
|
||||
path: ${{runner.workspace}}/sdrpp.apk
|
||||
|
||||
create_full_archive:
|
||||
needs: ['build_windows', 'build_macos_intel', 'build_macos_arm', 'build_debian_buster', 'build_debian_bullseye', 'build_debian_bookworm', 'build_debian_sid', 'build_ubuntu_focal', 'build_ubuntu_jammy', 'build_ubuntu_mantic', 'build_ubuntu_noble', 'build_raspios_bullseye_armhf', 'build_android']
|
||||
needs: ['build_windows', 'build_macos', 'build_debian_buster', 'build_debian_bullseye', 'build_debian_sid', 'build_ubuntu_focal', 'build_ubuntu_jammy', 'build_raspios_bullseye_armhf', 'build_android']
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download All Builds
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
|
||||
- name: Create Archive
|
||||
run: >
|
||||
mkdir sdrpp_all &&
|
||||
mv sdrpp_windows_x64/sdrpp_windows_x64.zip sdrpp_all/ &&
|
||||
mv sdrpp_macos_intel/sdrpp_macos_intel.zip sdrpp_all/ &&
|
||||
mv sdrpp_macos_arm/sdrpp_macos_arm.zip sdrpp_all/ &&
|
||||
mv sdrpp_debian_buster_amd64/sdrpp_debian_amd64.deb sdrpp_all/sdrpp_debian_buster_amd64.deb &&
|
||||
mv sdrpp_debian_bullseye_amd64/sdrpp_debian_amd64.deb sdrpp_all/sdrpp_debian_bullseye_amd64.deb &&
|
||||
mv sdrpp_debian_bookworm_amd64/sdrpp_debian_amd64.deb sdrpp_all/sdrpp_debian_bookworm_amd64.deb &&
|
||||
mv sdrpp_debian_sid_amd64/sdrpp_debian_amd64.deb sdrpp_all/sdrpp_debian_sid_amd64.deb &&
|
||||
mv sdrpp_ubuntu_focal_amd64/sdrpp_debian_amd64.deb sdrpp_all/sdrpp_ubuntu_focal_amd64.deb &&
|
||||
mv sdrpp_ubuntu_jammy_amd64/sdrpp_debian_amd64.deb sdrpp_all/sdrpp_ubuntu_jammy_amd64.deb &&
|
||||
mv sdrpp_ubuntu_mantic_amd64/sdrpp_debian_amd64.deb sdrpp_all/sdrpp_ubuntu_mantic_amd64.deb &&
|
||||
mv sdrpp_ubuntu_noble_amd64/sdrpp_debian_amd64.deb sdrpp_all/sdrpp_ubuntu_noble_amd64.deb &&
|
||||
mv sdrpp_raspios_bullseye_armhf/sdrpp_debian_armhf.deb sdrpp_all/sdrpp_raspios_bullseye_armhf.deb &&
|
||||
mv sdrpp_android/sdrpp.apk sdrpp_all/sdrpp.apk
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sdrpp_all
|
||||
path: sdrpp_all/
|
||||
@ -457,7 +351,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Download All Builds
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
|
||||
- name: Update Nightly
|
||||
run: gh release upload nightly sdrpp_all/* -R ${{github.repository}} --clobber
|
||||
@ -466,7 +360,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install codespell
|
||||
run: sudo apt update -y && sudo apt install -y codespell
|
||||
@ -478,7 +372,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Run check_clang_format
|
||||
run: cd $GITHUB_WORKSPACE && chmod +x ./check_clang_format.sh && ./check_clang_format.sh || true
|
||||
|
@ -12,33 +12,29 @@ option(OPT_OVERRIDE_STD_FILESYSTEM "Use a local version of std::filesystem on sy
|
||||
option(OPT_BUILD_AIRSPY_SOURCE "Build Airspy Source Module (Dependencies: libairspy)" ON)
|
||||
option(OPT_BUILD_AIRSPYHF_SOURCE "Build Airspy HF+ Source Module (Dependencies: libairspyhf)" ON)
|
||||
option(OPT_BUILD_AUDIO_SOURCE "Build Audio Source Module (Dependencies: rtaudio)" ON)
|
||||
option(OPT_BUILD_BADGESDR_SOURCE "Build BadgeSDR Source Module (Dependencies: libusb)" OFF)
|
||||
option(OPT_BUILD_BLADERF_SOURCE "Build BladeRF Source Module (Dependencies: libbladeRF)" OFF)
|
||||
option(OPT_BUILD_FILE_SOURCE "Wav file source" ON)
|
||||
option(OPT_BUILD_HACKRF_SOURCE "Build HackRF Source Module (Dependencies: libhackrf)" ON)
|
||||
option(OPT_BUILD_HERMES_SOURCE "Build Hermes Source Module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_LIMESDR_SOURCE "Build LimeSDR Source Module (Dependencies: liblimesuite)" OFF)
|
||||
option(OPT_BUILD_NETWORK_SOURCE "Build Network Source Module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_PERSEUS_SOURCE "Build Perseus Source Module (Dependencies: libperseus-sdr)" OFF)
|
||||
option(OPT_BUILD_PLUTOSDR_SOURCE "Build PlutoSDR Source Module (Dependencies: libiio, libad9361)" ON)
|
||||
option(OPT_BUILD_RFNM_SOURCE "Build RFNM Source Module (Dependencies: librfnm)" OFF)
|
||||
option(OPT_BUILD_SDRPP_SERVER_SOURCE "Build SDR++ Server Source Module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_RFSPACE_SOURCE "Build RFspace Source Module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_RTL_SDR_SOURCE "Build RTL-SDR Source Module (Dependencies: librtlsdr)" ON)
|
||||
option(OPT_BUILD_RTL_TCP_SOURCE "Build RTL-TCP Source Module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_SDRPP_SERVER_SOURCE "Build SDR++ Server Source Module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_SDRPLAY_SOURCE "Build SDRplay Source Module (Dependencies: libsdrplay)" OFF)
|
||||
option(OPT_BUILD_SOAPY_SOURCE "Build SoapySDR Source Module (Dependencies: soapysdr)" OFF)
|
||||
option(OPT_BUILD_SOAPY_SOURCE "Build SoapySDR Source Module (Dependencies: soapysdr)" ON)
|
||||
option(OPT_BUILD_SPECTRAN_SOURCE "Build Spectran Source Module (Dependencies: Aaronia RTSA Suite)" OFF)
|
||||
option(OPT_BUILD_SPECTRAN_HTTP_SOURCE "Build Spectran HTTP Source Module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_SPYSERVER_SOURCE "Build SpyServer Source Module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_PLUTOSDR_SOURCE "Build PlutoSDR Source Module (Dependencies: libiio, libad9361)" ON)
|
||||
option(OPT_BUILD_USRP_SOURCE "Build USRP Source Module (libuhd)" OFF)
|
||||
|
||||
# Sinks
|
||||
option(OPT_BUILD_ANDROID_AUDIO_SINK "Build Android Audio Sink Module (Dependencies: AAudio, only for android)" OFF)
|
||||
option(OPT_BUILD_AUDIO_SINK "Build Audio Sink Module (Dependencies: rtaudio)" ON)
|
||||
option(OPT_BUILD_PORTAUDIO_SINK "Build PortAudio Sink Module (Dependencies: portaudio)" OFF)
|
||||
option(OPT_BUILD_NETWORK_SINK "Build Audio Sink Module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_NEW_PORTAUDIO_SINK "Build the new PortAudio Sink Module (Dependencies: portaudio)" OFF)
|
||||
option(OPT_BUILD_PORTAUDIO_SINK "Build PortAudio Sink Module (Dependencies: portaudio)" OFF)
|
||||
|
||||
# Decoders
|
||||
option(OPT_BUILD_ATV_DECODER "Build ATV decoder (no dependencies required)" OFF)
|
||||
@ -46,14 +42,12 @@ option(OPT_BUILD_FALCON9_DECODER "Build the falcon9 live decoder (Dependencies:
|
||||
option(OPT_BUILD_KG_SSTV_DECODER "Build the KG SSTV (KG-STV) decoder module (no dependencies required)" OFF)
|
||||
option(OPT_BUILD_M17_DECODER "Build the M17 decoder module (Dependencies: codec2)" OFF)
|
||||
option(OPT_BUILD_METEOR_DEMODULATOR "Build the meteor demodulator module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_PAGER_DECODER "Build the pager decoder module (no dependencies required)" ON)
|
||||
option(OPT_BUILD_RADIO "Main audio modulation decoder (AM, FM, SSB, etc...)" ON)
|
||||
option(OPT_BUILD_WEATHER_SAT_DECODER "Build the HRPT decoder module (no dependencies required)" OFF)
|
||||
|
||||
# Misc
|
||||
option(OPT_BUILD_DISCORD_PRESENCE "Build the Discord Rich Presence module" ON)
|
||||
option(OPT_BUILD_FREQUENCY_MANAGER "Build the Frequency Manager module" ON)
|
||||
option(OPT_BUILD_IQ_EXPORTER "Build the IQ Exporter module" ON)
|
||||
option(OPT_BUILD_RECORDER "Audio and baseband recorder" ON)
|
||||
option(OPT_BUILD_RIGCTL_CLIENT "Rigctl client to make SDR++ act as a panadapter" ON)
|
||||
option(OPT_BUILD_RIGCTL_SERVER "Rigctl backend for controlling SDR++ with software like gpredict" ON)
|
||||
@ -63,7 +57,6 @@ option(OPT_BUILD_SCHEDULER "Build the scheduler" OFF)
|
||||
# Other options
|
||||
option(USE_INTERNAL_LIBCORRECT "Use an internal version of libcorrect" ON)
|
||||
option(USE_BUNDLE_DEFAULTS "Set the default resource and module directories to the right ones for a MacOS .app" OFF)
|
||||
option(COPY_MSVC_REDISTRIBUTABLES "Copy over the Visual C++ Redistributable" OFF)
|
||||
|
||||
# Module cmake path
|
||||
set(SDRPP_MODULE_CMAKE "${CMAKE_SOURCE_DIR}/sdrpp_module.cmake")
|
||||
@ -128,10 +121,6 @@ if (OPT_BUILD_AUDIO_SOURCE)
|
||||
add_subdirectory("source_modules/audio_source")
|
||||
endif (OPT_BUILD_AUDIO_SOURCE)
|
||||
|
||||
if (OPT_BUILD_BADGESDR_SOURCE)
|
||||
add_subdirectory("source_modules/badgesdr_source")
|
||||
endif (OPT_BUILD_BADGESDR_SOURCE)
|
||||
|
||||
if (OPT_BUILD_BLADERF_SOURCE)
|
||||
add_subdirectory("source_modules/bladerf_source")
|
||||
endif (OPT_BUILD_BLADERF_SOURCE)
|
||||
@ -152,21 +141,9 @@ if (OPT_BUILD_LIMESDR_SOURCE)
|
||||
add_subdirectory("source_modules/limesdr_source")
|
||||
endif (OPT_BUILD_LIMESDR_SOURCE)
|
||||
|
||||
if (OPT_BUILD_NETWORK_SOURCE)
|
||||
add_subdirectory("source_modules/network_source")
|
||||
endif (OPT_BUILD_NETWORK_SOURCE)
|
||||
|
||||
if (OPT_BUILD_PERSEUS_SOURCE)
|
||||
add_subdirectory("source_modules/perseus_source")
|
||||
endif (OPT_BUILD_PERSEUS_SOURCE)
|
||||
|
||||
if (OPT_BUILD_PLUTOSDR_SOURCE)
|
||||
add_subdirectory("source_modules/plutosdr_source")
|
||||
endif (OPT_BUILD_PLUTOSDR_SOURCE)
|
||||
|
||||
if (OPT_BUILD_RFNM_SOURCE)
|
||||
add_subdirectory("source_modules/rfnm_source")
|
||||
endif (OPT_BUILD_RFNM_SOURCE)
|
||||
if (OPT_BUILD_SDRPP_SERVER_SOURCE)
|
||||
add_subdirectory("source_modules/sdrpp_server_source")
|
||||
endif (OPT_BUILD_SDRPP_SERVER_SOURCE)
|
||||
|
||||
if (OPT_BUILD_RFSPACE_SOURCE)
|
||||
add_subdirectory("source_modules/rfspace_source")
|
||||
@ -180,10 +157,6 @@ if (OPT_BUILD_RTL_TCP_SOURCE)
|
||||
add_subdirectory("source_modules/rtl_tcp_source")
|
||||
endif (OPT_BUILD_RTL_TCP_SOURCE)
|
||||
|
||||
if (OPT_BUILD_SDRPP_SERVER_SOURCE)
|
||||
add_subdirectory("source_modules/sdrpp_server_source")
|
||||
endif (OPT_BUILD_SDRPP_SERVER_SOURCE)
|
||||
|
||||
if (OPT_BUILD_SDRPLAY_SOURCE)
|
||||
add_subdirectory("source_modules/sdrplay_source")
|
||||
endif (OPT_BUILD_SDRPLAY_SOURCE)
|
||||
@ -204,6 +177,10 @@ if (OPT_BUILD_SPYSERVER_SOURCE)
|
||||
add_subdirectory("source_modules/spyserver_source")
|
||||
endif (OPT_BUILD_SPYSERVER_SOURCE)
|
||||
|
||||
if (OPT_BUILD_PLUTOSDR_SOURCE)
|
||||
add_subdirectory("source_modules/plutosdr_source")
|
||||
endif (OPT_BUILD_PLUTOSDR_SOURCE)
|
||||
|
||||
if (OPT_BUILD_USRP_SOURCE)
|
||||
add_subdirectory("source_modules/usrp_source")
|
||||
endif (OPT_BUILD_USRP_SOURCE)
|
||||
@ -252,10 +229,6 @@ if (OPT_BUILD_METEOR_DEMODULATOR)
|
||||
add_subdirectory("decoder_modules/meteor_demodulator")
|
||||
endif (OPT_BUILD_METEOR_DEMODULATOR)
|
||||
|
||||
if (OPT_BUILD_PAGER_DECODER)
|
||||
add_subdirectory("decoder_modules/pager_decoder")
|
||||
endif (OPT_BUILD_PAGER_DECODER)
|
||||
|
||||
if (OPT_BUILD_RADIO)
|
||||
add_subdirectory("decoder_modules/radio")
|
||||
endif (OPT_BUILD_RADIO)
|
||||
@ -274,10 +247,6 @@ if (OPT_BUILD_FREQUENCY_MANAGER)
|
||||
add_subdirectory("misc_modules/frequency_manager")
|
||||
endif (OPT_BUILD_FREQUENCY_MANAGER)
|
||||
|
||||
if (OPT_BUILD_IQ_EXPORTER)
|
||||
add_subdirectory("misc_modules/iq_exporter")
|
||||
endif (OPT_BUILD_IQ_EXPORTER)
|
||||
|
||||
if (OPT_BUILD_RECORDER)
|
||||
add_subdirectory("misc_modules/recorder")
|
||||
endif (OPT_BUILD_RECORDER)
|
||||
@ -298,40 +267,19 @@ if (OPT_BUILD_SCHEDULER)
|
||||
add_subdirectory("misc_modules/scheduler")
|
||||
endif (OPT_BUILD_SCHEDULER)
|
||||
|
||||
if (MSVC)
|
||||
add_executable(sdrpp "src/main.cpp" "win32/resources.rc")
|
||||
add_executable(min_broken "min_broken/main.cpp" "win32/resources.rc")
|
||||
else ()
|
||||
add_executable(sdrpp "src/main.cpp")
|
||||
endif ()
|
||||
|
||||
add_executable(sdrpp "src/main.cpp" "win32/resources.rc")
|
||||
target_link_libraries(sdrpp PRIVATE sdrpp_core)
|
||||
|
||||
# Compiler arguments
|
||||
target_compile_options(sdrpp PRIVATE ${SDRPP_COMPILER_FLAGS})
|
||||
target_compile_options(min_broken PRIVATE ${SDRPP_COMPILER_FLAGS})
|
||||
|
||||
# Copy dynamic libs over
|
||||
if (MSVC)
|
||||
add_custom_target(do_always ALL xcopy /s \"$<TARGET_FILE_DIR:sdrpp_core>\\*.dll\" \"$<TARGET_FILE_DIR:sdrpp>\" /Y)
|
||||
add_custom_target(do_always_volk ALL xcopy /s \"C:/Program Files/PothosSDR/bin\\volk.dll\" \"$<TARGET_FILE_DIR:sdrpp>\" /Y)
|
||||
|
||||
if (COPY_MSVC_REDISTRIBUTABLES)
|
||||
# Get the list of Visual C++ runtime DLLs
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP True)
|
||||
include(InstallRequiredSystemLibraries)
|
||||
|
||||
# Create a space sperated list
|
||||
set(REDIST_DLLS_STR "")
|
||||
foreach(DLL IN LISTS CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
|
||||
set(REDIST_DLLS_STR COMMAND xcopy /F \"${DLL}\" \"$<TARGET_FILE_DIR:sdrpp>\" /Y ${REDIST_DLLS_STR})
|
||||
endforeach()
|
||||
|
||||
# Create target
|
||||
add_custom_target(do_always_msvc ALL ${REDIST_DLLS_STR})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||
add_custom_target(do_always ALL cp \"$<TARGET_FILE_DIR:sdrpp_core>/libsdrpp_core.so\" \"$<TARGET_FILE_DIR:sdrpp>\")
|
||||
endif ()
|
||||
@ -349,7 +297,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
add_custom_target(do_always ALL cp \"$<TARGET_FILE_DIR:sdrpp_core>/libsdrpp_core.dylib\" \"$<TARGET_FILE_DIR:sdrpp>\")
|
||||
endif ()
|
||||
|
||||
# cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake" -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_SCANNER=ON -DOPT_BUILD_SCHEDULER=ON -DOPT_BUILD_USRP_SOURCE=ON -DOPT_BUILD_PAGER_DECODER=ON
|
||||
# cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake" -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_SCANNER=ON -DOPT_BUILD_SCHEDULER=ON -DOPT_BUILD_USRP_SOURCE=ON
|
||||
|
||||
# Create module cmake file
|
||||
configure_file(${CMAKE_SOURCE_DIR}/sdrpp_module.cmake ${CMAKE_CURRENT_BINARY_DIR}/sdrpp_module.cmake @ONLY)
|
||||
|
@ -10,7 +10,7 @@ android {
|
||||
minSdkVersion 28
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "1.2.0"
|
||||
versionName "1.1.0"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
|
@ -1,6 +1,64 @@
|
||||
# Pull Requests
|
||||
|
||||
Code pull requests are **NOT welcome**. Please open an issue discussing potential bugfixes or feature requests instead.
|
||||
TODO
|
||||
|
||||
# Code Style
|
||||
|
||||
## Naming Convention
|
||||
|
||||
- Files: `snake_case.h` `snake_case.cpp`
|
||||
- Namespaces: `CamelCase`
|
||||
- Classes: `CamelCase`
|
||||
- Structs: `CamelCase_t`
|
||||
- Members: `camelCase`
|
||||
- Enum: `SNAKE_CASE`
|
||||
- Macros: `SNAKE_CASE`
|
||||
|
||||
## Brace Style
|
||||
|
||||
```c++
|
||||
int myFunction() {
|
||||
if (shortIf) { shortFunctionName(); }
|
||||
|
||||
if (longIf) {
|
||||
longFunction();
|
||||
otherStuff();
|
||||
myLongFunction();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Note: If it makes the code cleaner, remember to use the `?` keyword instead of a `if else` statement.
|
||||
|
||||
## Pointers
|
||||
|
||||
Please use `type* name` for pointers.
|
||||
|
||||
## Structure
|
||||
|
||||
Headers and their associated C++ files shall be in the same directory. All headers must use `#pragma once` instead of other include guards. Only include files in a header that are being used in that header. Include the rest in the associated C++ file.
|
||||
|
||||
# Modules
|
||||
|
||||
## Module Naming Convention
|
||||
|
||||
All modules names must be `snake_case`. If the module is a source, it must end with `_source`. If it is a sink, it must end with `_sink`.
|
||||
|
||||
For example, lets take the module named `cool_source`:
|
||||
|
||||
- Directory: `cool_source`
|
||||
- Class: `CoolSourceModule`
|
||||
- Binary: `cool_source.<os dynlib extension>`
|
||||
|
||||
## Integration into main repository
|
||||
|
||||
If the module meets the code quality requirements, it may be added to the official repository. A module that doesn't require any external dependencies that the core doesn't already use may be enabled for build by default. Otherwise, they must be disabled for build by default with a `OPT_BUILD_MODULE_NAME` variable set to `OFF`.
|
||||
|
||||
# JSON Formatting
|
||||
|
||||
The ability to add new radio band allocation identifiers and color maps relies on JSON files. Proper formatting of these JSON files is important for reference and readability. The following guides will show you how to properly format the JSON files for their respective uses.
|
||||
|
||||
**IMPORTANT: JSON File cannot contain comments, there are only in this example for clarity**
|
||||
|
||||
## Band Frequency Allocation
|
||||
|
||||
@ -60,8 +118,8 @@ Please follow this guide to properly format the JSON files for custom color maps
|
||||
}
|
||||
```
|
||||
|
||||
# JSON Formatting
|
||||
# Best Practices
|
||||
|
||||
The ability to add new radio band allocation identifiers and color maps relies on JSON files. Proper formatting of these JSON files is important for reference and readability. The following guides will show you how to properly format the JSON files for their respective uses.
|
||||
|
||||
**IMPORTANT: JSON File cannot contain comments, there are only in this example for clarity**
|
||||
* All additions and/or bug fixes to the core must not add additional dependencies.
|
||||
* Use VSCode for development, VS seems to cause issues.
|
||||
* DO NOT use libboost for any code meant for this repository
|
@ -13,7 +13,6 @@ endif (USE_BUNDLE_DEFAULTS)
|
||||
file(GLOB_RECURSE SRC "src/*.cpp" "src/*.c")
|
||||
|
||||
add_definitions(-DSDRPP_IS_CORE)
|
||||
add_definitions(-DFLOG_ANDROID_TAG="SDR++")
|
||||
if (MSVC)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
endif ()
|
||||
@ -108,6 +107,7 @@ elseif (ANDROID)
|
||||
)
|
||||
|
||||
target_link_libraries(sdrpp_core PUBLIC
|
||||
/sdr-kit/${ANDROID_ABI}/lib/libcpu_features.a
|
||||
/sdr-kit/${ANDROID_ABI}/lib/libvolk.so
|
||||
/sdr-kit/${ANDROID_ABI}/lib/libfftw3f.so
|
||||
/sdr-kit/${ANDROID_ABI}/lib/libzstd.so
|
||||
|
@ -45,7 +45,7 @@ uint8_t *history_buffer_get_slice(history_buffer *buf) { return buf->history[buf
|
||||
|
||||
shift_register_t history_buffer_search(history_buffer *buf, const distance_t *distances,
|
||||
unsigned int search_every) {
|
||||
shift_register_t bestpath = 0;
|
||||
shift_register_t bestpath;
|
||||
distance_t leasterror = USHRT_MAX;
|
||||
// search for a state with the least error
|
||||
for (shift_register_t state = 0; state < buf->num_states; state += search_every) {
|
||||
|
@ -88,7 +88,7 @@ int CommandArgsParser::parse(int argc, char* argv[]) {
|
||||
try {
|
||||
carg.ival = std::stoi(arg);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
catch (std::exception e) {
|
||||
printf("Invalid argument, failed to parse integer\n");
|
||||
showHelp();
|
||||
return -1;
|
||||
@ -98,7 +98,7 @@ int CommandArgsParser::parse(int argc, char* argv[]) {
|
||||
try {
|
||||
carg.fval = std::stod(arg);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
catch (std::exception e) {
|
||||
printf("Invalid argument, failed to parse float\n");
|
||||
showHelp();
|
||||
return -1;
|
||||
|
@ -36,8 +36,8 @@ void ConfigManager::load(json def, bool lock) {
|
||||
file >> conf;
|
||||
file.close();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
flog::error("Config file '{}' is corrupted, resetting it: {}", path, e.what());
|
||||
catch (std::exception e) {
|
||||
flog::error("Config file '{0}' is corrupted, resetting it", path);
|
||||
conf = def;
|
||||
save(false);
|
||||
}
|
||||
|
@ -117,10 +117,6 @@ int sdrpp_main(int argc, char* argv[]) {
|
||||
defConfig["colorMap"] = "Classic";
|
||||
defConfig["fftHold"] = false;
|
||||
defConfig["fftHoldSpeed"] = 60;
|
||||
defConfig["fftSmoothing"] = false;
|
||||
defConfig["fftSmoothingSpeed"] = 100;
|
||||
defConfig["snrSmoothing"] = false;
|
||||
defConfig["snrSmoothingSpeed"] = 20;
|
||||
defConfig["fastFFT"] = false;
|
||||
defConfig["fftHeight"] = 300;
|
||||
defConfig["fftRate"] = 20;
|
||||
@ -181,8 +177,6 @@ int sdrpp_main(int argc, char* argv[]) {
|
||||
defConfig["moduleInstances"]["LimeSDR Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["PlutoSDR Source"]["module"] = "plutosdr_source";
|
||||
defConfig["moduleInstances"]["PlutoSDR Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["PerseusSDR Source"]["module"] = "perseus_source";
|
||||
defConfig["moduleInstances"]["PerseusSDR Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["RFspace Source"]["module"] = "rfspace_source";
|
||||
defConfig["moduleInstances"]["RFspace Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["RTL-SDR Source"]["module"] = "rtl_sdr_source";
|
||||
@ -193,6 +187,8 @@ int sdrpp_main(int argc, char* argv[]) {
|
||||
defConfig["moduleInstances"]["SDRplay Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["SDR++ Server Source"]["module"] = "sdrpp_server_source";
|
||||
defConfig["moduleInstances"]["SDR++ Server Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["SoapySDR Source"]["module"] = "soapy_source";
|
||||
defConfig["moduleInstances"]["SoapySDR Source"]["enabled"] = true;
|
||||
defConfig["moduleInstances"]["SpyServer Source"]["module"] = "spyserver_source";
|
||||
defConfig["moduleInstances"]["SpyServer Source"]["enabled"] = true;
|
||||
|
||||
|
@ -12,7 +12,6 @@ namespace sdrpp_credits {
|
||||
"Howard0su",
|
||||
"John Donkersley",
|
||||
"Joshua Kimsey",
|
||||
"Manawyrm",
|
||||
"Martin Hauke",
|
||||
"Marvin Sinister",
|
||||
"Maxime Biette",
|
||||
@ -22,6 +21,7 @@ namespace sdrpp_credits {
|
||||
"Shuyuan Liu",
|
||||
"Syne Ardwin (WI9SYN)",
|
||||
"Szymon Zakrent",
|
||||
"Tobias Mädel",
|
||||
"Youssef Touil",
|
||||
"Zimm"
|
||||
};
|
||||
@ -41,11 +41,8 @@ namespace sdrpp_credits {
|
||||
"CaribouLabs",
|
||||
"Ettus Research",
|
||||
"Howard Su",
|
||||
"MicroPhase",
|
||||
"Microtelecom",
|
||||
"MyriadRF",
|
||||
"Nuand",
|
||||
"RFNM",
|
||||
"RFspace",
|
||||
"RTL-SDRblog",
|
||||
"SDRplay"
|
||||
@ -57,36 +54,25 @@ namespace sdrpp_credits {
|
||||
"Croccydile",
|
||||
"Dale L Puckett (K0HYD)",
|
||||
"Daniele D'Agnelli",
|
||||
"David Taylor (GM8ARV)",
|
||||
"D. Jones",
|
||||
"Dexruus",
|
||||
"EB3FRN",
|
||||
"Eric Johnson",
|
||||
"Ernest Murphy (NH7L)",
|
||||
"Flinger Films",
|
||||
"Frank Werner (HB9FXQ)",
|
||||
"gringogrigio",
|
||||
"Jeff Moe",
|
||||
"Joe Cupano",
|
||||
"KD1SQ",
|
||||
"Kezza",
|
||||
"Krys Kamieniecki",
|
||||
"Lee Donaghy",
|
||||
"Lee KD1SQ",
|
||||
".lozenge. (Hank Hill)",
|
||||
"Martin Herren (HB9FXX)",
|
||||
"ON4MU",
|
||||
"Passion-Radio.com",
|
||||
"Paul Maine",
|
||||
"Peter Betz",
|
||||
"Scanner School",
|
||||
"Scott Palmer",
|
||||
"SignalsEverywhere",
|
||||
"Syne Ardwin (WI9SYN)",
|
||||
"W4IPA",
|
||||
"William Arcand (W1WRA)",
|
||||
"William Pitchford",
|
||||
"Yves Rougy",
|
||||
"Zipper"
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
namespace dsp {
|
||||
class generic_block {
|
||||
public:
|
||||
virtual ~generic_block() {}
|
||||
virtual void start() {}
|
||||
virtual void stop() {}
|
||||
virtual int run() { return -1; }
|
||||
@ -17,6 +16,8 @@ namespace dsp {
|
||||
|
||||
class block : public generic_block {
|
||||
public:
|
||||
virtual void init() {}
|
||||
|
||||
virtual ~block() {
|
||||
if (!_block_init) { return; }
|
||||
stop();
|
||||
|
@ -67,6 +67,10 @@ namespace dsp::buffer {
|
||||
sizes[writeCur] = count;
|
||||
writeCur++;
|
||||
writeCur = ((writeCur) % TEST_BUFFER_SIZE);
|
||||
|
||||
// if (((writeCur - readCur + TEST_BUFFER_SIZE) % TEST_BUFFER_SIZE) >= (TEST_BUFFER_SIZE-2)) {
|
||||
// flog::warn("Overflow");
|
||||
// }
|
||||
}
|
||||
cnd.notify_all();
|
||||
_in->flush();
|
||||
|
@ -93,7 +93,7 @@ namespace dsp {
|
||||
void disableBlock(Processor<T, T>* block, Func onOutputChange) {
|
||||
// Check that the block is part of the chain
|
||||
if (!blockExists(block)) {
|
||||
throw std::runtime_error("[chain] Tried to disable a block that isn't part of the chain");
|
||||
throw std::runtime_error("[chain] Tried to enable a block that isn't part of the chain");
|
||||
}
|
||||
|
||||
// If already disabled, don't do anything
|
||||
@ -163,12 +163,10 @@ namespace dsp {
|
||||
|
||||
private:
|
||||
Processor<T, T>* blockBefore(Processor<T, T>* block) {
|
||||
// TODO: This is wrong and must be fixed when I get more time
|
||||
for (auto& ln : links) {
|
||||
if (ln == block) { return NULL; }
|
||||
if (states[ln]) { return ln; }
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Processor<T, T>* blockAfter(Processor<T, T>* block) {
|
||||
|
@ -41,11 +41,7 @@ namespace dsp::channel {
|
||||
}
|
||||
|
||||
inline int process(int count, const complex_t* in, complex_t* out) {
|
||||
#if VOLK_VERSION >= 030100
|
||||
volk_32fc_s32fc_x2_rotator2_32fc((lv_32fc_t*)out, (lv_32fc_t*)in, &phaseDelta, &phase, count);
|
||||
#else
|
||||
volk_32fc_s32fc_x2_rotator_32fc((lv_32fc_t*)out, (lv_32fc_t*)in, phaseDelta, &phase, count);
|
||||
#endif
|
||||
return count;
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,6 @@ namespace dsp::compression {
|
||||
|
||||
void init(stream<complex_t>* in, PCMType pcmType) {
|
||||
_pcmType = pcmType;
|
||||
|
||||
// Set the output buffer size to the max size of a complex buffer + 8 bytes for the header
|
||||
out.setBufferSize(STREAM_BUFFER_SIZE*sizeof(complex_t) + 8);
|
||||
|
||||
base_type::init(in);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,6 @@ namespace dsp::demod {
|
||||
audioFirTaps = taps::lowPass(15000.0, 4000.0, _samplerate);
|
||||
alFir.init(NULL, audioFirTaps);
|
||||
arFir.init(NULL, audioFirTaps);
|
||||
xlator.init(NULL, -57000.0, samplerate);
|
||||
rdsResamp.init(NULL, samplerate, 5000.0);
|
||||
|
||||
lmr = buffer::alloc<float>(STREAM_BUFFER_SIZE);
|
||||
@ -57,9 +56,9 @@ namespace dsp::demod {
|
||||
r = buffer::alloc<float>(STREAM_BUFFER_SIZE);
|
||||
|
||||
lprDelay.out.free();
|
||||
lmrDelay.out.free();
|
||||
arFir.out.free();
|
||||
alFir.out.free();
|
||||
xlator.out.free();
|
||||
rdsResamp.out.free();
|
||||
|
||||
base_type::init(in);
|
||||
@ -93,7 +92,6 @@ namespace dsp::demod {
|
||||
alFir.setTaps(audioFirTaps);
|
||||
arFir.setTaps(audioFirTaps);
|
||||
|
||||
xlator.setOffset(-57000.0, samplerate);
|
||||
rdsResamp.setInSamplerate(samplerate);
|
||||
|
||||
reset();
|
||||
@ -141,7 +139,7 @@ namespace dsp::demod {
|
||||
base_type::tempStart();
|
||||
}
|
||||
|
||||
inline int process(int count, complex_t* in, stereo_t* out, int& rdsOutCount, complex_t* rdsout = NULL) {
|
||||
inline int process(int count, complex_t* in, stereo_t* out, int& rdsOutCount, float* rdsout = NULL) {
|
||||
// Demodulate
|
||||
demod.process(count, in, demod.out.writeBuf);
|
||||
if (_stereo) {
|
||||
@ -154,24 +152,24 @@ namespace dsp::demod {
|
||||
|
||||
// Delay
|
||||
lprDelay.process(count, demod.out.writeBuf, demod.out.writeBuf);
|
||||
lmrDelay.process(count, rtoc.out.writeBuf, lmrDelay.out.writeBuf);
|
||||
lmrDelay.process(count, rtoc.out.writeBuf, rtoc.out.writeBuf);
|
||||
|
||||
// conjugate PLL output to down convert twice the L-R signal
|
||||
math::Conjugate::process(count, pilotPLL.out.writeBuf, pilotPLL.out.writeBuf);
|
||||
math::Multiply<dsp::complex_t>::process(count, lmrDelay.out.writeBuf, pilotPLL.out.writeBuf, lmrDelay.out.writeBuf);
|
||||
math::Multiply<dsp::complex_t>::process(count, lmrDelay.out.writeBuf, pilotPLL.out.writeBuf, lmrDelay.out.writeBuf);
|
||||
math::Multiply<dsp::complex_t>::process(count, rtoc.out.writeBuf, pilotPLL.out.writeBuf, rtoc.out.writeBuf);
|
||||
math::Multiply<dsp::complex_t>::process(count, rtoc.out.writeBuf, pilotPLL.out.writeBuf, rtoc.out.writeBuf);
|
||||
|
||||
// Do RDS demod
|
||||
if (_rdsOut) {
|
||||
// Translate to 0Hz
|
||||
xlator.process(count, rtoc.out.writeBuf, rtoc.out.writeBuf);
|
||||
|
||||
// Resample to the output samplerate
|
||||
rdsOutCount = rdsResamp.process(count, rtoc.out.writeBuf, rdsout);
|
||||
// Since the PLL output is no longer needed after this, use it as the output
|
||||
math::Multiply<dsp::complex_t>::process(count, rtoc.out.writeBuf, pilotPLL.out.writeBuf, pilotPLL.out.writeBuf);
|
||||
convert::ComplexToReal::process(count, pilotPLL.out.writeBuf, rdsout);
|
||||
volk_32f_s32f_multiply_32f(rdsout, rdsout, 100.0, count);
|
||||
rdsOutCount = rdsResamp.process(count, rdsout, rdsout);
|
||||
}
|
||||
|
||||
// Convert output back to real for further processing
|
||||
convert::ComplexToReal::process(count, lmrDelay.out.writeBuf, lmr);
|
||||
convert::ComplexToReal::process(count, rtoc.out.writeBuf, lmr);
|
||||
|
||||
// Amplify by 2x
|
||||
volk_32f_s32f_multiply_32f(lmr, lmr, 2.0f, count);
|
||||
@ -195,11 +193,24 @@ namespace dsp::demod {
|
||||
// Convert to complex
|
||||
rtoc.process(count, demod.out.writeBuf, rtoc.out.writeBuf);
|
||||
|
||||
// Translate to 0Hz
|
||||
xlator.process(count, rtoc.out.writeBuf, rtoc.out.writeBuf);
|
||||
// Filter out pilot and run through PLL
|
||||
pilotFir.process(count, rtoc.out.writeBuf, pilotFir.out.writeBuf);
|
||||
pilotPLL.process(count, pilotFir.out.writeBuf, pilotPLL.out.writeBuf);
|
||||
|
||||
// Resample to the output samplerate
|
||||
rdsOutCount = rdsResamp.process(count, rtoc.out.writeBuf, rdsout);
|
||||
// Delay
|
||||
lprDelay.process(count, demod.out.writeBuf, demod.out.writeBuf);
|
||||
lmrDelay.process(count, rtoc.out.writeBuf, rtoc.out.writeBuf);
|
||||
|
||||
// conjugate PLL output to down convert twice the L-R signal
|
||||
math::Conjugate::process(count, pilotPLL.out.writeBuf, pilotPLL.out.writeBuf);
|
||||
math::Multiply<dsp::complex_t>::process(count, rtoc.out.writeBuf, pilotPLL.out.writeBuf, rtoc.out.writeBuf);
|
||||
math::Multiply<dsp::complex_t>::process(count, rtoc.out.writeBuf, pilotPLL.out.writeBuf, rtoc.out.writeBuf);
|
||||
|
||||
// Since the PLL output is no longer needed after this, use it as the output
|
||||
math::Multiply<dsp::complex_t>::process(count, rtoc.out.writeBuf, pilotPLL.out.writeBuf, pilotPLL.out.writeBuf);
|
||||
convert::ComplexToReal::process(count, pilotPLL.out.writeBuf, rdsout);
|
||||
volk_32f_s32f_multiply_32f(rdsout, rdsout, 100.0, count);
|
||||
rdsOutCount = rdsResamp.process(count, rdsout, rdsout);
|
||||
}
|
||||
|
||||
// Filter if needed
|
||||
@ -229,7 +240,7 @@ namespace dsp::demod {
|
||||
return count;
|
||||
}
|
||||
|
||||
stream<complex_t> rdsOut;
|
||||
stream<float> rdsOut;
|
||||
|
||||
protected:
|
||||
double _deviation;
|
||||
@ -242,14 +253,13 @@ namespace dsp::demod {
|
||||
tap<complex_t> pilotFirTaps;
|
||||
filter::FIR<complex_t, complex_t> pilotFir;
|
||||
convert::RealToComplex rtoc;
|
||||
channel::FrequencyXlator xlator;
|
||||
loop::PLL pilotPLL;
|
||||
math::Delay<float> lprDelay;
|
||||
math::Delay<complex_t> lmrDelay;
|
||||
tap<float> audioFirTaps;
|
||||
filter::FIR<float, float> arFir;
|
||||
filter::FIR<float, float> alFir;
|
||||
multirate::RationalResampler<dsp::complex_t> rdsResamp;
|
||||
multirate::RationalResampler<float> rdsResamp;
|
||||
|
||||
float* lmr;
|
||||
float* l;
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include "quadrature.h"
|
||||
#include "../filter/fir.h"
|
||||
#include "../taps/low_pass.h"
|
||||
#include "../taps/high_pass.h"
|
||||
#include "../taps/band_pass.h"
|
||||
#include "../convert/mono_to_stereo.h"
|
||||
|
||||
namespace dsp::demod {
|
||||
@ -19,26 +17,22 @@ namespace dsp::demod {
|
||||
~FM() {
|
||||
if (!base_type::_block_init) { return; }
|
||||
base_type::stop();
|
||||
dsp::taps::free(filterTaps);
|
||||
dsp::taps::free(lpfTaps);
|
||||
}
|
||||
|
||||
void init(dsp::stream<dsp::complex_t>* in, double samplerate, double bandwidth, bool lowPass, bool highPass) {
|
||||
void init(dsp::stream<dsp::complex_t>* in, double samplerate, double bandwidth, bool lowPass) {
|
||||
_samplerate = samplerate;
|
||||
_bandwidth = bandwidth;
|
||||
_lowPass = lowPass;
|
||||
_highPass = highPass;
|
||||
|
||||
demod.init(NULL, bandwidth / 2.0, _samplerate);
|
||||
loadDummyTaps();
|
||||
fir.init(NULL, filterTaps);
|
||||
|
||||
// Initialize taps
|
||||
updateFilter(lowPass, highPass);
|
||||
lpfTaps = dsp::taps::lowPass(_bandwidth / 2.0, (_bandwidth / 2.0) * 0.1, _samplerate);
|
||||
lpf.init(NULL, lpfTaps);
|
||||
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
demod.out.free();
|
||||
}
|
||||
fir.out.free();
|
||||
lpf.out.free();
|
||||
|
||||
base_type::init(in);
|
||||
}
|
||||
@ -49,7 +43,9 @@ namespace dsp::demod {
|
||||
base_type::tempStop();
|
||||
_samplerate = samplerate;
|
||||
demod.setDeviation(_bandwidth / 2.0, _samplerate);
|
||||
updateFilter(_lowPass, _highPass);
|
||||
dsp::taps::free(lpfTaps);
|
||||
lpfTaps = dsp::taps::lowPass(_bandwidth / 2.0, (_bandwidth / 2.0) * 0.1, _samplerate);
|
||||
lpf.setTaps(lpfTaps);
|
||||
base_type::tempStart();
|
||||
}
|
||||
|
||||
@ -58,20 +54,19 @@ namespace dsp::demod {
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
if (bandwidth == _bandwidth) { return; }
|
||||
_bandwidth = bandwidth;
|
||||
std::lock_guard<std::mutex> lck2(lpfMtx);
|
||||
demod.setDeviation(_bandwidth / 2.0, _samplerate);
|
||||
updateFilter(_lowPass, _highPass);
|
||||
dsp::taps::free(lpfTaps);
|
||||
lpfTaps = dsp::taps::lowPass(_bandwidth / 2, (_bandwidth / 2) * 0.1, _samplerate);
|
||||
lpf.setTaps(lpfTaps);
|
||||
}
|
||||
|
||||
void setLowPass(bool lowPass) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
updateFilter(lowPass, _highPass);
|
||||
}
|
||||
|
||||
void setHighPass(bool highPass) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
updateFilter(_lowPass, highPass);
|
||||
std::lock_guard<std::mutex> lck2(lpfMtx);
|
||||
_lowPass = lowPass;
|
||||
lpf.reset();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
@ -79,23 +74,23 @@ namespace dsp::demod {
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
base_type::tempStop();
|
||||
demod.reset();
|
||||
fir.reset();
|
||||
lpf.reset();
|
||||
base_type::tempStart();
|
||||
}
|
||||
|
||||
inline int process(int count, dsp::complex_t* in, T* out) {
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
demod.process(count, in, out);
|
||||
if (filtering) {
|
||||
std::lock_guard<std::mutex> lck(filterMtx);
|
||||
fir.process(count, out, out);
|
||||
if (_lowPass) {
|
||||
std::lock_guard<std::mutex> lck(lpfMtx);
|
||||
lpf.process(count, out, out);
|
||||
}
|
||||
}
|
||||
if constexpr (std::is_same_v<T, stereo_t>) {
|
||||
demod.process(count, in, demod.out.writeBuf);
|
||||
if (filtering) {
|
||||
std::lock_guard<std::mutex> lck(filterMtx);
|
||||
fir.process(count, demod.out.writeBuf, demod.out.writeBuf);
|
||||
if (_lowPass) {
|
||||
std::lock_guard<std::mutex> lck(lpfMtx);
|
||||
lpf.process(count, demod.out.writeBuf, demod.out.writeBuf);
|
||||
}
|
||||
convert::MonoToStereo::process(count, demod.out.writeBuf, out);
|
||||
}
|
||||
@ -114,50 +109,13 @@ namespace dsp::demod {
|
||||
}
|
||||
|
||||
private:
|
||||
void updateFilter(bool lowPass, bool highPass) {
|
||||
std::lock_guard<std::mutex> lck(filterMtx);
|
||||
|
||||
// Update values
|
||||
_lowPass = lowPass;
|
||||
_highPass = highPass;
|
||||
filtering = (lowPass || highPass);
|
||||
|
||||
// Free filter taps
|
||||
dsp::taps::free(filterTaps);
|
||||
|
||||
// Generate filter depending on low and high pass settings
|
||||
if (_lowPass && _highPass) {
|
||||
filterTaps = dsp::taps::bandPass<float>(300.0, _bandwidth / 2.0, 100.0, _samplerate);
|
||||
}
|
||||
else if (_highPass) {
|
||||
filterTaps = dsp::taps::highPass(300.0, 100.0, _samplerate);
|
||||
}
|
||||
else if (_lowPass) {
|
||||
filterTaps = dsp::taps::lowPass(_bandwidth / 2.0, (_bandwidth / 2.0) * 0.1, _samplerate);
|
||||
}
|
||||
else {
|
||||
loadDummyTaps();
|
||||
}
|
||||
|
||||
// Set filter to use new taps
|
||||
fir.setTaps(filterTaps);
|
||||
fir.reset();
|
||||
}
|
||||
|
||||
void loadDummyTaps() {
|
||||
float dummyTap = 1.0f;
|
||||
filterTaps = dsp::taps::fromArray<float>(1, &dummyTap);
|
||||
}
|
||||
|
||||
double _samplerate;
|
||||
double _bandwidth;
|
||||
bool _lowPass;
|
||||
bool _highPass;
|
||||
bool filtering;
|
||||
|
||||
Quadrature demod;
|
||||
tap<float> filterTaps;
|
||||
filter::FIR<float, float> fir;
|
||||
std::mutex filterMtx;
|
||||
tap<float> lpfTaps;
|
||||
filter::FIR<float, float> lpf;
|
||||
std::mutex lpfMtx;
|
||||
};
|
||||
}
|
@ -110,7 +110,7 @@ namespace dsp::demod {
|
||||
else if (_mode == Mode::LSB) {
|
||||
return -_bandwidth / 2.0;
|
||||
}
|
||||
else {
|
||||
else if (_mode == Mode::DSB) {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ namespace dsp::filter {
|
||||
|
||||
// Move existing data to make transition seemless
|
||||
if (_taps.size < oldTC) {
|
||||
memmove(buffer, &buffer[oldTC - _taps.size], (_taps.size - 1) * sizeof(D));
|
||||
memcpy(buffer, &buffer[oldTC - _taps.size], (_taps.size - 1) * sizeof(D));
|
||||
}
|
||||
else if (_taps.size > oldTC) {
|
||||
memmove(&buffer[_taps.size - oldTC], buffer, (oldTC - 1) * sizeof(D));
|
||||
memcpy(&buffer[_taps.size - oldTC], buffer, (oldTC - 1) * sizeof(D));
|
||||
buffer::clear<D>(buffer, _taps.size - oldTC);
|
||||
}
|
||||
|
||||
|
@ -65,11 +65,6 @@ namespace dsp::loop {
|
||||
if constexpr(CLAMP_PHASE) { clampPhase(); }
|
||||
}
|
||||
|
||||
inline void advancePhase() {
|
||||
phase += freq;
|
||||
if constexpr(CLAMP_PHASE) { clampPhase(); }
|
||||
}
|
||||
|
||||
T freq;
|
||||
T phase;
|
||||
|
||||
|
@ -2,6 +2,5 @@
|
||||
#include "../multirate/rrc_interpolator.h"
|
||||
|
||||
namespace dsp::mod {
|
||||
// TODO: Check if resample before RRC is better than using the RRC taps as a filter (bandwidth probably not correct for alias-free resampling)
|
||||
typedef multirate::RRCInterpolator<complex_t> PSK;
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
#include "../math/hz_to_rads.h"
|
||||
|
||||
namespace dsp::mod {
|
||||
class Quadrature : public Processor<float, complex_t> {
|
||||
class Quadrature : Processor<float, complex_t> {
|
||||
using base_type = Processor<float, complex_t>;
|
||||
public:
|
||||
Quadrature() {}
|
||||
|
@ -83,6 +83,8 @@ namespace dsp::multirate {
|
||||
int interp = OutSR / gcd;
|
||||
int decim = InSR / gcd;
|
||||
|
||||
flog::warn("interp: {0}, decim: {1}", interp, decim);
|
||||
|
||||
// Configure resampler
|
||||
double tapSamplerate = _symbolrate * (double)interp;
|
||||
rrcTaps = taps::rootRaisedCosine<float>(_rrcTapCount * interp, _rrcBeta, _symbolrate, tapSamplerate);
|
||||
|
@ -10,8 +10,6 @@ namespace dsp {
|
||||
|
||||
Operator(stream<A>* a, stream<B>* b) { init(a, b); }
|
||||
|
||||
virtual ~Operator() {}
|
||||
|
||||
virtual void init(stream<A>* a, stream<B>* b) {
|
||||
_a = a;
|
||||
_b = b;
|
||||
|
@ -11,7 +11,6 @@
|
||||
namespace dsp {
|
||||
class untyped_stream {
|
||||
public:
|
||||
virtual ~untyped_stream() {}
|
||||
virtual bool swap(int size) { return false; }
|
||||
virtual int read() { return -1; }
|
||||
virtual void flush() {}
|
||||
|
@ -15,7 +15,7 @@ namespace dsp::taps {
|
||||
if (oddTapCount && !(count % 2)) { count++; }
|
||||
return windowedSinc<T>(count, (bandStop - bandStart) / 2.0, sampleRate, [=](double n, double N) {
|
||||
if constexpr (std::is_same_v<T, float>) {
|
||||
return 2.0f * cosf(offsetOmega * (float)n) * window::nuttall(n, N);
|
||||
return cosf(offsetOmega * (float)n) * window::nuttall(n, N);
|
||||
}
|
||||
if constexpr (std::is_same_v<T, complex_t>) {
|
||||
// The offset is negative to flip the taps. Complex bandpass are asymetric
|
||||
|
@ -82,7 +82,7 @@ namespace dsp {
|
||||
|
||||
inline float fastAmplitude() {
|
||||
float re_abs = fabsf(re);
|
||||
float im_abs = fabsf(im);
|
||||
float im_abs = fabsf(re);
|
||||
if (re_abs > im_abs) { return re_abs + 0.4f * im_abs; }
|
||||
return im_abs + 0.4f * re_abs;
|
||||
}
|
||||
@ -125,4 +125,4 @@ namespace dsp {
|
||||
float l;
|
||||
float r;
|
||||
};
|
||||
}
|
||||
}
|
@ -433,9 +433,6 @@ void MainWindow::draw() {
|
||||
showCredits = false;
|
||||
}
|
||||
|
||||
// Reset waterfall lock
|
||||
lockWaterfallControls = showCredits;
|
||||
|
||||
// Handle menu resize
|
||||
ImVec2 winSize = ImGui::GetWindowSize();
|
||||
ImVec2 mousePos = ImGui::GetMousePos();
|
||||
@ -466,10 +463,9 @@ void MainWindow::draw() {
|
||||
}
|
||||
}
|
||||
|
||||
// Process menu keybinds
|
||||
displaymenu::checkKeybinds();
|
||||
|
||||
// Left Column
|
||||
lockWaterfallControls = false;
|
||||
if (showMenu) {
|
||||
ImGui::Columns(3, "WindowColumns", false);
|
||||
ImGui::SetColumnWidth(0, menuWidth);
|
||||
@ -580,20 +576,8 @@ void MainWindow::draw() {
|
||||
if (wheel != 0 && (gui::waterfall.mouseInFFT || gui::waterfall.mouseInWaterfall)) {
|
||||
double nfreq;
|
||||
if (vfo != NULL) {
|
||||
// Select factor depending on modifier keys
|
||||
double interval;
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftShift)) {
|
||||
interval = vfo->snapInterval * 10.0;
|
||||
}
|
||||
else if (ImGui::IsKeyDown(ImGuiKey_LeftAlt)) {
|
||||
interval = vfo->snapInterval * 0.1;
|
||||
}
|
||||
else {
|
||||
interval = vfo->snapInterval;
|
||||
}
|
||||
|
||||
nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + (interval * wheel);
|
||||
nfreq = roundl(nfreq / interval) * interval;
|
||||
nfreq = gui::waterfall.getCenterFrequency() + vfo->generalOffset + (vfo->snapInterval * wheel);
|
||||
nfreq = roundl(nfreq / vfo->snapInterval) * vfo->snapInterval;
|
||||
}
|
||||
else {
|
||||
nfreq = gui::waterfall.getCenterFrequency() - (gui::waterfall.getViewBandwidth() * wheel / 20.0);
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <gui/style.h>
|
||||
#include <utils/optionlist.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace displaymenu {
|
||||
bool showWaterfall;
|
||||
@ -19,44 +18,50 @@ namespace displaymenu {
|
||||
std::string colorMapAuthor = "";
|
||||
int selectedWindow = 0;
|
||||
int fftRate = 20;
|
||||
int fftSizeId = 0;
|
||||
int uiScaleId = 0;
|
||||
bool restartRequired = false;
|
||||
bool fftHold = false;
|
||||
int fftHoldSpeed = 60;
|
||||
bool fftSmoothing = false;
|
||||
int fftSmoothingSpeed = 100;
|
||||
bool snrSmoothing = false;
|
||||
int snrSmoothingSpeed = 20;
|
||||
|
||||
OptionList<int, int> fftSizes;
|
||||
OptionList<float, float> uiScales;
|
||||
|
||||
const int FFTSizes[] = {
|
||||
524288,
|
||||
262144,
|
||||
131072,
|
||||
65536,
|
||||
32768,
|
||||
16384,
|
||||
8192,
|
||||
4096,
|
||||
2048,
|
||||
1024
|
||||
};
|
||||
|
||||
const char* FFTSizesStr = "524288\0"
|
||||
"262144\0"
|
||||
"131072\0"
|
||||
"65536\0"
|
||||
"32768\0"
|
||||
"16384\0"
|
||||
"8192\0"
|
||||
"4096\0"
|
||||
"2048\0"
|
||||
"1024\0";
|
||||
|
||||
int fftSizeId = 0;
|
||||
|
||||
const IQFrontEnd::FFTWindow fftWindowList[] = {
|
||||
IQFrontEnd::FFTWindow::RECTANGULAR,
|
||||
IQFrontEnd::FFTWindow::BLACKMAN,
|
||||
IQFrontEnd::FFTWindow::NUTTALL
|
||||
};
|
||||
|
||||
void updateFFTSpeeds() {
|
||||
gui::waterfall.setFFTHoldSpeed((float)fftHoldSpeed / ((float)fftRate * 10.0f));
|
||||
gui::waterfall.setFFTSmoothingSpeed(std::min<float>((float)fftSmoothingSpeed / (float)(fftRate * 10.0f), 1.0f));
|
||||
gui::waterfall.setSNRSmoothingSpeed(std::min<float>((float)snrSmoothingSpeed / (float)(fftRate * 10.0f), 1.0f));
|
||||
void updateFFTHoldSpeed() {
|
||||
gui::waterfall.setFFTHoldSpeed(fftHoldSpeed / (fftRate * 10.0f));
|
||||
}
|
||||
|
||||
void init() {
|
||||
// Define FFT sizes
|
||||
fftSizes.define(524288, "524288", 524288);
|
||||
fftSizes.define(262144, "262144", 262144);
|
||||
fftSizes.define(131072, "131072", 131072);
|
||||
fftSizes.define(65536, "65536", 65536);
|
||||
fftSizes.define(32768, "32768", 32768);
|
||||
fftSizes.define(16384, "16384", 16384);
|
||||
fftSizes.define(8192, "8192", 8192);
|
||||
fftSizes.define(4096, "4096", 4096);
|
||||
fftSizes.define(2048, "2048", 2048);
|
||||
fftSizes.define(1024, "1024", 1024);
|
||||
|
||||
showWaterfall = core::configManager.conf["showWaterfall"];
|
||||
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
||||
std::string colormapName = core::configManager.conf["colorMap"];
|
||||
@ -78,12 +83,15 @@ namespace displaymenu {
|
||||
fullWaterfallUpdate = core::configManager.conf["fullWaterfallUpdate"];
|
||||
gui::waterfall.setFullWaterfallUpdate(fullWaterfallUpdate);
|
||||
|
||||
fftSizeId = fftSizes.valueId(65536);
|
||||
int size = core::configManager.conf["fftSize"];
|
||||
if (fftSizes.keyExists(size)) {
|
||||
fftSizeId = fftSizes.keyId(size);
|
||||
fftSizeId = 3;
|
||||
int fftSize = core::configManager.conf["fftSize"];
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (fftSize == FFTSizes[i]) {
|
||||
fftSizeId = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
sigpath::iqFrontEnd.setFFTSize(fftSizes.value(fftSizeId));
|
||||
sigpath::iqFrontEnd.setFFTSize(FFTSizes[fftSizeId]);
|
||||
|
||||
fftRate = core::configManager.conf["fftRate"];
|
||||
sigpath::iqFrontEnd.setFFTRate(fftRate);
|
||||
@ -96,13 +104,7 @@ namespace displaymenu {
|
||||
fftHold = core::configManager.conf["fftHold"];
|
||||
fftHoldSpeed = core::configManager.conf["fftHoldSpeed"];
|
||||
gui::waterfall.setFFTHold(fftHold);
|
||||
fftSmoothing = core::configManager.conf["fftSmoothing"];
|
||||
fftSmoothingSpeed = core::configManager.conf["fftSmoothingSpeed"];
|
||||
gui::waterfall.setFFTSmoothing(fftSmoothing);
|
||||
snrSmoothing = core::configManager.conf["snrSmoothing"];
|
||||
snrSmoothingSpeed = core::configManager.conf["snrSmoothingSpeed"];
|
||||
gui::waterfall.setSNRSmoothing(snrSmoothing);
|
||||
updateFFTSpeeds();
|
||||
updateFFTHoldSpeed();
|
||||
|
||||
// Define and load UI scales
|
||||
uiScales.define(1.0f, "100%", 1.0f);
|
||||
@ -112,24 +114,15 @@ namespace displaymenu {
|
||||
uiScaleId = uiScales.valueId(style::uiScale);
|
||||
}
|
||||
|
||||
void setWaterfallShown(bool shown) {
|
||||
showWaterfall = shown;
|
||||
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["showWaterfall"] = showWaterfall;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
void checkKeybinds() {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_Home, false)) {
|
||||
setWaterfallShown(!showWaterfall);
|
||||
}
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
float menuWidth = ImGui::GetContentRegionAvail().x;
|
||||
if (ImGui::Checkbox("Show Waterfall##_sdrpp", &showWaterfall)) {
|
||||
setWaterfallShown(showWaterfall);
|
||||
bool homePressed = ImGui::IsKeyPressed(ImGuiKey_Home, false);
|
||||
if (ImGui::Checkbox("Show Waterfall##_sdrpp", &showWaterfall) || homePressed) {
|
||||
if (homePressed) { showWaterfall = !showWaterfall; }
|
||||
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["showWaterfall"] = showWaterfall;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Full Waterfall Update##_sdrpp", &fullWaterfallUpdate)) {
|
||||
@ -151,47 +144,16 @@ namespace displaymenu {
|
||||
core::configManager.conf["fftHold"] = fftHold;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::LeftLabel("FFT Hold Speed");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::InputInt("##sdrpp_fft_hold_speed", &fftHoldSpeed)) {
|
||||
updateFFTSpeeds();
|
||||
updateFFTHoldSpeed();
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftHoldSpeed"] = fftHoldSpeed;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("FFT Smoothing##_sdrpp", &fftSmoothing)) {
|
||||
gui::waterfall.setFFTSmoothing(fftSmoothing);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftSmoothing"] = fftSmoothing;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::InputInt("##sdrpp_fft_smoothing_speed", &fftSmoothingSpeed)) {
|
||||
fftSmoothingSpeed = std::max<int>(fftSmoothingSpeed, 1);
|
||||
updateFFTSpeeds();
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftSmoothingSpeed"] = fftSmoothingSpeed;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("SNR Smoothing##_sdrpp", &snrSmoothing)) {
|
||||
gui::waterfall.setSNRSmoothing(snrSmoothing);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["snrSmoothing"] = snrSmoothing;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::InputInt("##sdrpp_snr_smoothing_speed", &snrSmoothingSpeed)) {
|
||||
snrSmoothingSpeed = std::max<int>(snrSmoothingSpeed, 1);
|
||||
updateFFTSpeeds();
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["snrSmoothingSpeed"] = snrSmoothingSpeed;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
ImGui::LeftLabel("High-DPI Scaling");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo("##sdrpp_ui_scale", &uiScaleId, uiScales.txt)) {
|
||||
@ -206,7 +168,7 @@ namespace displaymenu {
|
||||
if (ImGui::InputInt("##sdrpp_fft_rate", &fftRate, 1, 10)) {
|
||||
fftRate = std::max<int>(1, fftRate);
|
||||
sigpath::iqFrontEnd.setFFTRate(fftRate);
|
||||
updateFFTSpeeds();
|
||||
updateFFTHoldSpeed();
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftRate"] = fftRate;
|
||||
core::configManager.release(true);
|
||||
@ -214,10 +176,10 @@ namespace displaymenu {
|
||||
|
||||
ImGui::LeftLabel("FFT Size");
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo("##sdrpp_fft_size", &fftSizeId, fftSizes.txt)) {
|
||||
sigpath::iqFrontEnd.setFFTSize(fftSizes.value(fftSizeId));
|
||||
if (ImGui::Combo("##sdrpp_fft_size", &fftSizeId, FFTSizesStr)) {
|
||||
sigpath::iqFrontEnd.setFFTSize(FFTSizes[fftSizeId]);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftSize"] = fftSizes.key(fftSizeId);
|
||||
core::configManager.conf["fftSize"] = FFTSizes[fftSizeId];
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
@ -248,4 +210,4 @@ namespace displaymenu {
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Restart required.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,5 @@
|
||||
|
||||
namespace displaymenu {
|
||||
void init();
|
||||
void checkKeybinds();
|
||||
void draw(void* ctx);
|
||||
}
|
@ -39,7 +39,7 @@ namespace module_manager_menu {
|
||||
ImVec2 btnSize = ImVec2(lheight, lheight - 1);
|
||||
ImVec2 textOff = ImVec2(3.0f * style::uiScale, -5.0f * style::uiScale);
|
||||
|
||||
if (ImGui::BeginTable("Module Manager Table", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 200.0f * style::uiScale))) {
|
||||
if (ImGui::BeginTable("Module Manager Table", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 200))) {
|
||||
ImGui::TableSetupColumn("Name");
|
||||
ImGui::TableSetupColumn("Type");
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, cellWidth);
|
||||
|
@ -15,10 +15,6 @@ namespace sourcemenu {
|
||||
bool iqCorrection = false;
|
||||
bool invertIQ = false;
|
||||
|
||||
EventHandler<std::string> sourceRegisteredHandler;
|
||||
EventHandler<std::string> sourceUnregisterHandler;
|
||||
EventHandler<std::string> sourceUnregisteredHandler;
|
||||
|
||||
std::vector<std::string> sourceNames;
|
||||
std::string sourceNamesTxt;
|
||||
std::string selectedSource;
|
||||
@ -99,10 +95,10 @@ namespace sourcemenu {
|
||||
}
|
||||
sourceId = std::distance(sourceNames.begin(), it);
|
||||
selectedSource = sourceNames[sourceId];
|
||||
sigpath::sourceManager.selectSource(sourceNames[sourceId]);
|
||||
sigpath::sourceManager.select(sourceNames[sourceId]);
|
||||
}
|
||||
|
||||
void onSourceRegistered(std::string name, void* ctx) {
|
||||
void onSourceRegistered(std::string name) {
|
||||
refreshSources();
|
||||
|
||||
if (selectedSource.empty()) {
|
||||
@ -114,13 +110,13 @@ namespace sourcemenu {
|
||||
sourceId = std::distance(sourceNames.begin(), std::find(sourceNames.begin(), sourceNames.end(), selectedSource));
|
||||
}
|
||||
|
||||
void onSourceUnregister(std::string name, void* ctx) {
|
||||
void onSourceUnregister(std::string name) {
|
||||
if (name != selectedSource) { return; }
|
||||
|
||||
// TODO: Stop everything
|
||||
}
|
||||
|
||||
void onSourceUnregistered(std::string name, void* ctx) {
|
||||
void onSourceUnregistered(std::string name) {
|
||||
refreshSources();
|
||||
|
||||
if (sourceNames.empty()) {
|
||||
@ -153,12 +149,9 @@ namespace sourcemenu {
|
||||
selectSource(selected);
|
||||
sigpath::iqFrontEnd.setDecimation(1 << decimationPower);
|
||||
|
||||
sourceRegisteredHandler.handler = onSourceRegistered;
|
||||
sourceUnregisterHandler.handler = onSourceUnregister;
|
||||
sourceUnregisteredHandler.handler = onSourceUnregistered;
|
||||
sigpath::sourceManager.onSourceRegistered.bindHandler(&sourceRegisteredHandler);
|
||||
sigpath::sourceManager.onSourceUnregister.bindHandler(&sourceUnregisterHandler);
|
||||
sigpath::sourceManager.onSourceUnregistered.bindHandler(&sourceUnregisteredHandler);
|
||||
sigpath::sourceManager.onSourceRegistered.bind(onSourceRegistered);
|
||||
sigpath::sourceManager.onSourceUnregister.bind(onSourceUnregister);
|
||||
sigpath::sourceManager.onSourceUnregistered.bind(onSourceUnregistered);
|
||||
|
||||
core::configManager.release();
|
||||
}
|
||||
@ -179,7 +172,7 @@ namespace sourcemenu {
|
||||
|
||||
if (running) { style::endDisabled(); }
|
||||
|
||||
sigpath::sourceManager.showSelectedMenu();
|
||||
sigpath::sourceManager.showMenu();
|
||||
|
||||
if (ImGui::Checkbox("IQ Correction##_sdrpp_iq_corr", &iqCorrection)) {
|
||||
sigpath::iqFrontEnd.setDCBlocking(iqCorrection);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -145,4 +144,4 @@ namespace SmGui {
|
||||
// Config configs
|
||||
void ForceSyncForNext();
|
||||
|
||||
}
|
||||
}
|
@ -52,15 +52,4 @@ namespace ImGui {
|
||||
bufferMtx.unlock();
|
||||
}
|
||||
|
||||
void SymbolDiagram::setCount(int count) {
|
||||
std::lock_guard<std::mutex> lck(bufferMtx);
|
||||
delete[] buffer;
|
||||
buffer = new float[count];
|
||||
sampleCount = count;
|
||||
memset(buffer, 0, sampleCount * sizeof(float));
|
||||
}
|
||||
|
||||
int SymbolDiagram::getCount() {
|
||||
return sampleCount;
|
||||
}
|
||||
}
|
@ -18,10 +18,6 @@ namespace ImGui {
|
||||
|
||||
void releaseBuffer();
|
||||
|
||||
void setCount(int count);
|
||||
|
||||
int getCount();
|
||||
|
||||
std::vector<float> lines;
|
||||
|
||||
private:
|
||||
|
@ -62,33 +62,6 @@ inline void printAndScale(double freq, char* buf) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void doZoom(int offset, int width, int inSize, int outSize, float* in, float* out) {
|
||||
// NOTE: REMOVE THAT SHIT, IT'S JUST A HACKY FIX
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
}
|
||||
if (width > 524288) {
|
||||
width = 524288;
|
||||
}
|
||||
|
||||
float factor = (float)width / (float)outSize;
|
||||
float sFactor = ceilf(factor);
|
||||
float uFactor;
|
||||
float id = offset;
|
||||
float maxVal;
|
||||
int sId;
|
||||
for (int i = 0; i < outSize; i++) {
|
||||
maxVal = -INFINITY;
|
||||
sId = (int)id;
|
||||
uFactor = (sId + sFactor > inSize) ? sFactor - ((sId + sFactor) - inSize) : sFactor;
|
||||
for (int j = 0; j < uFactor; j++) {
|
||||
if (in[sId + j] > maxVal) { maxVal = in[sId + j]; }
|
||||
}
|
||||
out[i] = maxVal;
|
||||
id += factor;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ImGui {
|
||||
WaterFall::WaterFall() {
|
||||
fftMin = -70.0;
|
||||
@ -110,7 +83,7 @@ namespace ImGui {
|
||||
viewBandwidth = 1.0;
|
||||
wholeBandwidth = 1.0;
|
||||
|
||||
//updatePallette(DEFAULT_COLOR_MAP, 13);
|
||||
updatePallette(DEFAULT_COLOR_MAP, 13);
|
||||
}
|
||||
|
||||
void WaterFall::init() {
|
||||
@ -613,7 +586,7 @@ namespace ImGui {
|
||||
for (int i = 0; i < count; i++) {
|
||||
drawDataSize = (viewBandwidth / wholeBandwidth) * rawFFTSize;
|
||||
drawDataStart = (((double)rawFFTSize / 2.0) * (offsetRatio + 1)) - (drawDataSize / 2);
|
||||
doZoom(drawDataStart, drawDataSize, rawFFTSize, dataWidth, &rawFFTs[((i + currentFFTLine) % waterfallHeight) * rawFFTSize], tempData);
|
||||
doZoom(drawDataStart, drawDataSize, dataWidth, &rawFFTs[((i + currentFFTLine) % waterfallHeight) * rawFFTSize], tempData);
|
||||
for (int j = 0; j < dataWidth; j++) {
|
||||
pixel = (std::clamp<float>(tempData[j], waterfallMin, waterfallMax) - waterfallMin) / dataRange;
|
||||
waterfallFb[(i * dataWidth) + j] = waterfallPallet[(int)(pixel * (WATERFALL_RESOLUTION - 1))];
|
||||
@ -716,7 +689,6 @@ namespace ImGui {
|
||||
|
||||
void WaterFall::onResize() {
|
||||
std::lock_guard<std::recursive_mutex> lck(latestFFTMtx);
|
||||
std::lock_guard<std::mutex> lck2(smoothingBufMtx);
|
||||
// return if widget is too small
|
||||
if (widgetSize.x < 100 || widgetSize.y < 100) {
|
||||
return;
|
||||
@ -768,23 +740,14 @@ namespace ImGui {
|
||||
}
|
||||
latestFFTHold = new float[dataWidth];
|
||||
|
||||
// Reallocate smoothing buffer
|
||||
if (fftSmoothing) {
|
||||
if (smoothingBuf) { delete[] smoothingBuf; }
|
||||
smoothingBuf = new float[dataWidth];
|
||||
for (int i = 0; i < dataWidth; i++) {
|
||||
smoothingBuf[i] = -1000.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (waterfallVisible) {
|
||||
delete[] waterfallFb;
|
||||
waterfallFb = new uint32_t[dataWidth * waterfallHeight];
|
||||
memset(waterfallFb, 0, dataWidth * waterfallHeight * sizeof(uint32_t));
|
||||
}
|
||||
for (int i = 0; i < dataWidth; i++) {
|
||||
latestFFT[i] = -1000.0f; // Hide everything
|
||||
latestFFTHold[i] = -1000.0f;
|
||||
latestFFT[i] = -1000.0; // Hide everything
|
||||
latestFFTHold[i] = -1000.0;
|
||||
}
|
||||
|
||||
fftAreaMin = ImVec2(widgetPos.x + (50.0f * style::uiScale), widgetPos.y + (9.0f * style::uiScale));
|
||||
@ -894,7 +857,7 @@ namespace ImGui {
|
||||
int drawDataStart = (((double)rawFFTSize / 2.0) * (offsetRatio + 1)) - (drawDataSize / 2);
|
||||
|
||||
if (waterfallVisible) {
|
||||
doZoom(drawDataStart, drawDataSize, rawFFTSize, dataWidth, &rawFFTs[currentFFTLine * rawFFTSize], latestFFT);
|
||||
doZoom(drawDataStart, drawDataSize, dataWidth, &rawFFTs[currentFFTLine * rawFFTSize], latestFFT);
|
||||
memmove(&waterfallFb[dataWidth], waterfallFb, dataWidth * (waterfallHeight - 1) * sizeof(uint32_t));
|
||||
float pixel;
|
||||
float dataRange = waterfallMax - waterfallMin;
|
||||
@ -906,29 +869,13 @@ namespace ImGui {
|
||||
waterfallUpdate = true;
|
||||
}
|
||||
else {
|
||||
doZoom(drawDataStart, drawDataSize, rawFFTSize, dataWidth, rawFFTs, latestFFT);
|
||||
doZoom(drawDataStart, drawDataSize, dataWidth, rawFFTs, latestFFT);
|
||||
fftLines = 1;
|
||||
}
|
||||
|
||||
// Apply smoothing if enabled
|
||||
if (fftSmoothing && latestFFT != NULL && smoothingBuf != NULL && fftLines != 0) {
|
||||
std::lock_guard<std::mutex> lck2(smoothingBufMtx);
|
||||
volk_32f_s32f_multiply_32f(latestFFT, latestFFT, fftSmoothingAlpha, dataWidth);
|
||||
volk_32f_s32f_multiply_32f(smoothingBuf, smoothingBuf, fftSmoothingBeta, dataWidth);
|
||||
volk_32f_x2_add_32f(smoothingBuf, latestFFT, smoothingBuf, dataWidth);
|
||||
memcpy(latestFFT, smoothingBuf, dataWidth * sizeof(float));
|
||||
}
|
||||
|
||||
if (selectedVFO != "" && vfos.size() > 0) {
|
||||
float dummy;
|
||||
if (snrSmoothing) {
|
||||
float newSNR = 0.0f;
|
||||
calculateVFOSignalInfo(waterfallVisible ? &rawFFTs[currentFFTLine * rawFFTSize] : rawFFTs, vfos[selectedVFO], dummy, newSNR);
|
||||
selectedVFOSNR = (snrSmoothingBeta*selectedVFOSNR) + (snrSmoothingAlpha*newSNR);
|
||||
}
|
||||
else {
|
||||
calculateVFOSignalInfo(waterfallVisible ? &rawFFTs[currentFFTLine * rawFFTSize] : rawFFTs, vfos[selectedVFO], dummy, selectedVFOSNR);
|
||||
}
|
||||
calculateVFOSignalInfo(waterfallVisible ? &rawFFTs[currentFFTLine * rawFFTSize] : rawFFTs, vfos[selectedVFO], dummy, selectedVFOSNR);
|
||||
}
|
||||
|
||||
// If FFT hold is enabled, update it
|
||||
@ -1163,45 +1110,6 @@ namespace ImGui {
|
||||
fftHoldSpeed = speed;
|
||||
}
|
||||
|
||||
void WaterFall::setFFTSmoothing(bool enabled) {
|
||||
std::lock_guard<std::mutex> lck(smoothingBufMtx);
|
||||
fftSmoothing = enabled;
|
||||
|
||||
// Free buffer if not null
|
||||
if (smoothingBuf) {delete[] smoothingBuf; }
|
||||
|
||||
// If disabled, stop here
|
||||
if (!enabled) {
|
||||
smoothingBuf = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate and copy existing FFT into it
|
||||
smoothingBuf = new float[dataWidth];
|
||||
if (latestFFT) {
|
||||
std::lock_guard<std::recursive_mutex> lck2(latestFFTMtx);
|
||||
memcpy(smoothingBuf, latestFFT, dataWidth * sizeof(float));
|
||||
}
|
||||
else {
|
||||
memset(smoothingBuf, 0, dataWidth * sizeof(float));
|
||||
}
|
||||
}
|
||||
|
||||
void WaterFall::setFFTSmoothingSpeed(float speed) {
|
||||
std::lock_guard<std::mutex> lck(smoothingBufMtx);
|
||||
fftSmoothingAlpha = speed;
|
||||
fftSmoothingBeta = 1.0f - speed;
|
||||
}
|
||||
|
||||
void WaterFall::setSNRSmoothing(bool enabled) {
|
||||
snrSmoothing = enabled;
|
||||
}
|
||||
|
||||
void WaterFall::setSNRSmoothingSpeed(float speed) {
|
||||
snrSmoothingAlpha = speed;
|
||||
snrSmoothingBeta = 1.0f - speed;
|
||||
}
|
||||
|
||||
float* WaterFall::acquireLatestFFT(int& width) {
|
||||
latestFFTMtx.lock();
|
||||
if (!latestFFT) {
|
||||
|
@ -90,6 +90,33 @@ namespace ImGui {
|
||||
float* getFFTBuffer();
|
||||
void pushFFT();
|
||||
|
||||
inline void doZoom(int offset, int width, int outWidth, float* data, float* out) {
|
||||
// NOTE: REMOVE THAT SHIT, IT'S JUST A HACKY FIX
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
}
|
||||
if (width > 524288) {
|
||||
width = 524288;
|
||||
}
|
||||
|
||||
float factor = (float)width / (float)outWidth;
|
||||
float sFactor = ceilf(factor);
|
||||
float uFactor;
|
||||
float id = offset;
|
||||
float maxVal;
|
||||
int sId;
|
||||
for (int i = 0; i < outWidth; i++) {
|
||||
maxVal = -INFINITY;
|
||||
sId = (int)id;
|
||||
uFactor = (sId + sFactor > rawFFTSize) ? sFactor - ((sId + sFactor) - rawFFTSize) : sFactor;
|
||||
for (int j = 0; j < uFactor; j++) {
|
||||
if (data[sId + j] > maxVal) { maxVal = data[sId + j]; }
|
||||
}
|
||||
out[i] = maxVal;
|
||||
id += factor;
|
||||
}
|
||||
}
|
||||
|
||||
void updatePallette(float colors[][3], int colorCount);
|
||||
void updatePalletteFromArray(float* colors, int colorCount);
|
||||
|
||||
@ -142,12 +169,6 @@ namespace ImGui {
|
||||
void setFFTHold(bool hold);
|
||||
void setFFTHoldSpeed(float speed);
|
||||
|
||||
void setFFTSmoothing(bool enabled);
|
||||
void setFFTSmoothingSpeed(float speed);
|
||||
|
||||
void setSNRSmoothing(bool enabled);
|
||||
void setSNRSmoothingSpeed(float speed);
|
||||
|
||||
float* acquireLatestFFT(int& width);
|
||||
void releaseLatestFFT();
|
||||
|
||||
@ -161,7 +182,7 @@ namespace ImGui {
|
||||
bool mouseInFFT = false;
|
||||
bool mouseInWaterfall = false;
|
||||
|
||||
float selectedVFOSNR = 0.0f;
|
||||
float selectedVFOSNR = NAN;
|
||||
|
||||
bool centerFrequencyLocked = false;
|
||||
|
||||
@ -249,7 +270,6 @@ namespace ImGui {
|
||||
std::recursive_mutex buf_mtx;
|
||||
std::recursive_mutex latestFFTMtx;
|
||||
std::mutex texMtx;
|
||||
std::mutex smoothingBufMtx;
|
||||
|
||||
float vRange;
|
||||
|
||||
@ -284,9 +304,8 @@ namespace ImGui {
|
||||
//std::vector<std::vector<float>> rawFFTs;
|
||||
int rawFFTSize;
|
||||
float* rawFFTs = NULL;
|
||||
float* latestFFT = NULL;
|
||||
float* latestFFTHold = NULL;
|
||||
float* smoothingBuf = NULL;
|
||||
float* latestFFT;
|
||||
float* latestFFTHold;
|
||||
int currentFFTLine = 0;
|
||||
int fftLines = 0;
|
||||
|
||||
@ -306,14 +325,6 @@ namespace ImGui {
|
||||
bool fftHold = false;
|
||||
float fftHoldSpeed = 0.3f;
|
||||
|
||||
bool fftSmoothing = false;
|
||||
float fftSmoothingAlpha = 0.5;
|
||||
float fftSmoothingBeta = 0.5;
|
||||
|
||||
bool snrSmoothing = false;
|
||||
float snrSmoothingAlpha = 0.5;
|
||||
float snrSmoothingBeta = 0.5;
|
||||
|
||||
// UI Select elements
|
||||
bool fftResizeSelect = false;
|
||||
bool freqScaleSelect = false;
|
||||
|
@ -33,7 +33,7 @@ ModuleManager::Module_t ModuleManager::loadModule(std::string path) {
|
||||
#else
|
||||
mod.handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_LOCAL);
|
||||
if (mod.handle == NULL) {
|
||||
flog::error("Couldn't load {0}: {1}", path, dlerror());
|
||||
flog::error("Couldn't load {0}.", path);
|
||||
mod.handle = NULL;
|
||||
return mod;
|
||||
}
|
||||
@ -183,4 +183,4 @@ void ModuleManager::doPostInitAll() {
|
||||
flog::info("Running post-init for {0}", name);
|
||||
inst.instance->postInit();
|
||||
}
|
||||
}
|
||||
}
|
@ -42,7 +42,6 @@ public:
|
||||
|
||||
class Instance {
|
||||
public:
|
||||
virtual ~Instance() {}
|
||||
virtual void postInit() = 0;
|
||||
virtual void enable() = 0;
|
||||
virtual void disable() = 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <utils/flog.h>
|
||||
|
||||
bool ModuleComManager::registerInterface(std::string moduleName, std::string name, void (*handler)(int code, void* in, void* out, void* ctx), void* ctx) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
if (interfaces.find(name) != interfaces.end()) {
|
||||
flog::error("Tried creating module interface with an existing name: {0}", name);
|
||||
return false;
|
||||
@ -16,7 +16,7 @@ bool ModuleComManager::registerInterface(std::string moduleName, std::string nam
|
||||
}
|
||||
|
||||
bool ModuleComManager::unregisterInterface(std::string name) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
if (interfaces.find(name) == interfaces.end()) {
|
||||
flog::error("Tried to erase module interface with unknown name: {0}", name);
|
||||
return false;
|
||||
@ -26,13 +26,13 @@ bool ModuleComManager::unregisterInterface(std::string name) {
|
||||
}
|
||||
|
||||
bool ModuleComManager::interfaceExists(std::string name) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
if (interfaces.find(name) == interfaces.end()) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ModuleComManager::getModuleName(std::string name) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
if (interfaces.find(name) == interfaces.end()) {
|
||||
flog::error("Tried to call unknown module interface: {0}", name);
|
||||
return "";
|
||||
@ -41,7 +41,7 @@ std::string ModuleComManager::getModuleName(std::string name) {
|
||||
}
|
||||
|
||||
bool ModuleComManager::callInterface(std::string name, int code, void* in, void* out) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
if (interfaces.find(name) == interfaces.end()) {
|
||||
flog::error("Tried to call unknown module interface: {0}", name);
|
||||
return false;
|
||||
|
@ -18,6 +18,6 @@ public:
|
||||
bool callInterface(std::string name, int code, void* in, void* out);
|
||||
|
||||
private:
|
||||
std::recursive_mutex mtx;
|
||||
std::mutex mtx;
|
||||
std::map<std::string, ModuleComInterface> interfaces;
|
||||
};
|
@ -146,7 +146,7 @@ namespace server {
|
||||
// Load sourceId from config
|
||||
sourceId = 0;
|
||||
if (sourceList.keyExists(sourceName)) { sourceId = sourceList.keyId(sourceName); }
|
||||
sigpath::sourceManager.selectSource(sourceList[sourceId]);
|
||||
sigpath::sourceManager.select(sourceList[sourceId]);
|
||||
|
||||
// TODO: Use command line option
|
||||
std::string host = (std::string)core::args["addr"];
|
||||
@ -230,7 +230,7 @@ namespace server {
|
||||
// Compress data if needed and fill out header fields
|
||||
if (compression) {
|
||||
bb_pkt_hdr->type = PACKET_TYPE_BASEBAND_COMPRESSED;
|
||||
bb_pkt_hdr->size = sizeof(PacketHeader) + (uint32_t)ZSTD_compressCCtx(cctx, &bbuf[sizeof(PacketHeader)], SERVER_MAX_PACKET_SIZE-sizeof(PacketHeader), data, count, 1);
|
||||
bb_pkt_hdr->size = sizeof(PacketHeader) + (uint32_t)ZSTD_compressCCtx(cctx, &bbuf[sizeof(PacketHeader)], SERVER_MAX_PACKET_SIZE, data, count, 1);
|
||||
}
|
||||
else {
|
||||
bb_pkt_hdr->type = PACKET_TYPE_BASEBAND;
|
||||
@ -280,8 +280,7 @@ namespace server {
|
||||
}
|
||||
}
|
||||
else if (cmd == COMMAND_START) {
|
||||
sigpath::sourceManager.start();
|
||||
running = true;
|
||||
running = sigpath::sourceManager.start();
|
||||
}
|
||||
else if (cmd == COMMAND_STOP) {
|
||||
sigpath::sourceManager.stop();
|
||||
@ -309,14 +308,14 @@ namespace server {
|
||||
SmGui::FillWidth();
|
||||
SmGui::ForceSync();
|
||||
if (SmGui::Combo("##sdrpp_server_src_sel", &sourceId, sourceList.txt)) {
|
||||
sigpath::sourceManager.selectSource(sourceList[sourceId]);
|
||||
sigpath::sourceManager.select(sourceList[sourceId]);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["source"] = sourceList.key(sourceId);
|
||||
core::configManager.release(true);
|
||||
}
|
||||
if (running) { SmGui::EndDisabled(); }
|
||||
|
||||
sigpath::sourceManager.showSelectedMenu();
|
||||
sigpath::sourceManager.showMenu();
|
||||
}
|
||||
|
||||
void renderUI(SmGui::DrawList* dl, std::string diffId, SmGui::DrawListElem diffValue) {
|
||||
|
@ -1,106 +1,186 @@
|
||||
#include <server.h>
|
||||
#include <signal_path/source.h>
|
||||
#include "source.h"
|
||||
#include <utils/flog.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <core.h>
|
||||
|
||||
SourceManager::SourceManager() {
|
||||
}
|
||||
void SourceManager::registerSource(const std::string& name, Source* source) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
void SourceManager::registerSource(std::string name, SourceHandler* handler) {
|
||||
// Check arguments
|
||||
if (source || name.empty()) {
|
||||
flog::error("Invalid argument to register source", name);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that a source with that name doesn't already exist
|
||||
if (sources.find(name) != sources.end()) {
|
||||
flog::error("Tried to register new source with existing name: {0}", name);
|
||||
flog::error("Tried to register source with existing name: {}", name);
|
||||
return;
|
||||
}
|
||||
sources[name] = handler;
|
||||
onSourceRegistered.emit(name);
|
||||
|
||||
// Add source to map
|
||||
sources[name] = source;
|
||||
|
||||
// Add source to lists
|
||||
sourceNames.push_back(name);
|
||||
onSourceRegistered(name);
|
||||
}
|
||||
|
||||
void SourceManager::unregisterSource(std::string name) {
|
||||
void SourceManager::unregisterSource(const std::string& name) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Check that a source with that name exists
|
||||
if (sources.find(name) == sources.end()) {
|
||||
flog::error("Tried to unregister non existent source: {0}", name);
|
||||
flog::error("Tried to unregister a non-existent source: {}", name);
|
||||
return;
|
||||
}
|
||||
onSourceUnregister.emit(name);
|
||||
if (name == selectedName) {
|
||||
if (selectedHandler != NULL) {
|
||||
sources[selectedName]->deselectHandler(sources[selectedName]->ctx);
|
||||
}
|
||||
sigpath::iqFrontEnd.setInput(&nullSource);
|
||||
selectedHandler = NULL;
|
||||
}
|
||||
|
||||
// Notify event listeners of the imminent deletion
|
||||
onSourceUnregister(name);
|
||||
|
||||
// Delete from lists
|
||||
sourceNames.erase(std::find(sourceNames.begin(), sourceNames.end(), name));
|
||||
sources.erase(name);
|
||||
onSourceUnregistered.emit(name);
|
||||
|
||||
// Notify event listeners of the deletion
|
||||
onSourceUnregistered(name);
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceManager::getSourceNames() {
|
||||
std::vector<std::string> names;
|
||||
for (auto const& [name, src] : sources) { names.push_back(name); }
|
||||
return names;
|
||||
const std::vector<std::string>& SourceManager::getSourceNames() {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
return sourceNames;
|
||||
}
|
||||
|
||||
void SourceManager::selectSource(std::string name) {
|
||||
void SourceManager::select(const std::string& name) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// make sure that source isn't currently selected
|
||||
if (selectedSourceName == name) { return; }
|
||||
|
||||
// Deselect current source
|
||||
deselect();
|
||||
|
||||
// Check that a source with that name exists
|
||||
if (sources.find(name) == sources.end()) {
|
||||
flog::error("Tried to select non existent source: {0}", name);
|
||||
flog::error("Tried to select a non-existent source: {}", name);
|
||||
return;
|
||||
}
|
||||
if (selectedHandler != NULL) {
|
||||
sources[selectedName]->deselectHandler(sources[selectedName]->ctx);
|
||||
}
|
||||
selectedHandler = sources[name];
|
||||
selectedHandler->selectHandler(selectedHandler->ctx);
|
||||
selectedName = name;
|
||||
if (core::args["server"].b()) {
|
||||
server::setInput(selectedHandler->stream);
|
||||
}
|
||||
else {
|
||||
sigpath::iqFrontEnd.setInput(selectedHandler->stream);
|
||||
}
|
||||
// Set server input here
|
||||
|
||||
// Select the source
|
||||
selectedSourceName = name;
|
||||
selectedSource = sources[name];
|
||||
|
||||
// Call the selected source
|
||||
selectedSource->select();
|
||||
|
||||
// Retune to make sure the source has the latest frequency
|
||||
tune(frequency);
|
||||
}
|
||||
|
||||
void SourceManager::showSelectedMenu() {
|
||||
if (selectedHandler == NULL) {
|
||||
return;
|
||||
}
|
||||
selectedHandler->menuHandler(selectedHandler->ctx);
|
||||
const std::string& SourceManager::getSelected() {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
return selectedSourceName;
|
||||
}
|
||||
|
||||
void SourceManager::start() {
|
||||
if (selectedHandler == NULL) {
|
||||
return;
|
||||
}
|
||||
selectedHandler->startHandler(selectedHandler->ctx);
|
||||
bool SourceManager::start() {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Check if not already running
|
||||
if (running) { return true; }
|
||||
|
||||
// Call source if selected and save if started
|
||||
running = (!selectedSource) ? false : selectedSource->start();
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
void SourceManager::stop() {
|
||||
if (selectedHandler == NULL) {
|
||||
return;
|
||||
}
|
||||
selectedHandler->stopHandler(selectedHandler->ctx);
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Check if running
|
||||
if (!running) { return; }
|
||||
|
||||
// Call source if selected and save state
|
||||
if (selectedSource) { selectedSource->stop(); }
|
||||
running = false;
|
||||
}
|
||||
|
||||
bool SourceManager::isRunning() {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
return running;
|
||||
}
|
||||
|
||||
void SourceManager::tune(double freq) {
|
||||
if (selectedHandler == NULL) {
|
||||
return;
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Save frequency
|
||||
frequency = freq;
|
||||
|
||||
// Call source if selected
|
||||
if (selectedSource) {
|
||||
selectedSource->tune(((mode == TUNING_MODE_NORMAL) ? freq : ifFrequency) + offset);
|
||||
}
|
||||
// TODO: No need to always retune the hardware in Panadapter mode
|
||||
selectedHandler->tuneHandler(((tuneMode == TuningMode::NORMAL) ? freq : ifFreq) + tuneOffset, selectedHandler->ctx);
|
||||
onRetune.emit(freq);
|
||||
currentFreq = freq;
|
||||
}
|
||||
|
||||
void SourceManager::showMenu() {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Call source if selected
|
||||
if (selectedSource) { selectedSource->showMenu(); }
|
||||
}
|
||||
|
||||
double SourceManager::getSamplerate() {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
return samplerate;
|
||||
}
|
||||
|
||||
// =========== TODO: These functions should not happen in this class ===========
|
||||
|
||||
void SourceManager::setTuningOffset(double offset) {
|
||||
tuneOffset = offset;
|
||||
tune(currentFreq);
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Update offset
|
||||
this->offset = offset;
|
||||
|
||||
// Retune to take affect
|
||||
tune(frequency);
|
||||
}
|
||||
|
||||
void SourceManager::setTuningMode(TuningMode mode) {
|
||||
tuneMode = mode;
|
||||
tune(currentFreq);
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Update mode
|
||||
this->mode = mode;
|
||||
|
||||
// Retune to take affect
|
||||
tune(frequency);
|
||||
}
|
||||
|
||||
void SourceManager::setPanadapterIF(double freq) {
|
||||
ifFreq = freq;
|
||||
tune(currentFreq);
|
||||
void SourceManager::setPanadpterIF(double freq) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Update offset
|
||||
ifFrequency = freq;
|
||||
|
||||
// Return to take affect if in panadapter mode
|
||||
if (mode == TUNING_MODE_PANADAPTER) { tune(frequency); }
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
void SourceManager::deselect() {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Call source if selected
|
||||
if (selectedSource) { selectedSource->deselect(); }
|
||||
|
||||
// Mark as deselected
|
||||
selectedSourceName.clear();
|
||||
selectedSource = NULL;
|
||||
}
|
||||
|
||||
void SourceManager::setSamplerate(double samplerate) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
// Save samplerate and emit event
|
||||
this->samplerate = samplerate;
|
||||
onSamplerateChanged(samplerate);
|
||||
}
|
@ -1,56 +1,153 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <dsp/stream.h>
|
||||
#include <mutex>
|
||||
#include <dsp/types.h>
|
||||
#include <dsp/stream.h>
|
||||
#include <utils/event.h>
|
||||
|
||||
enum TuningMode {
|
||||
TUNING_MODE_NORMAL,
|
||||
TUNING_MODE_PANADAPTER
|
||||
};
|
||||
|
||||
class Source;
|
||||
|
||||
class SourceManager {
|
||||
friend Source;
|
||||
public:
|
||||
SourceManager();
|
||||
/**
|
||||
* Register a source.
|
||||
* @param name Name of the source.
|
||||
* @param source Pointer to the source instance.
|
||||
*/
|
||||
void registerSource(const std::string& name, Source* source);
|
||||
|
||||
struct SourceHandler {
|
||||
dsp::stream<dsp::complex_t>* stream;
|
||||
void (*menuHandler)(void* ctx);
|
||||
void (*selectHandler)(void* ctx);
|
||||
void (*deselectHandler)(void* ctx);
|
||||
void (*startHandler)(void* ctx);
|
||||
void (*stopHandler)(void* ctx);
|
||||
void (*tuneHandler)(double freq, void* ctx);
|
||||
void* ctx;
|
||||
};
|
||||
/**
|
||||
* Unregister a source.
|
||||
* @param name Name of the source.
|
||||
*/
|
||||
void unregisterSource(const std::string& name);
|
||||
|
||||
enum TuningMode {
|
||||
NORMAL,
|
||||
PANADAPTER
|
||||
};
|
||||
/**
|
||||
* Get a list of source names.
|
||||
* @return List of source names.
|
||||
*/
|
||||
const std::vector<std::string>& getSourceNames();
|
||||
|
||||
void registerSource(std::string name, SourceHandler* handler);
|
||||
void unregisterSource(std::string name);
|
||||
void selectSource(std::string name);
|
||||
void showSelectedMenu();
|
||||
void start();
|
||||
/**
|
||||
* Select a source.
|
||||
* @param name Name of the source.
|
||||
*/
|
||||
void select(const std::string& name);
|
||||
|
||||
/**
|
||||
* Get the name of the currently selected source.
|
||||
* @return Name of the source or empty if no source is selected.
|
||||
*/
|
||||
const std::string& getSelected();
|
||||
|
||||
/**
|
||||
* Start the radio.
|
||||
* @return True if the radio started successfully, false if not.
|
||||
*/
|
||||
bool start();
|
||||
|
||||
/**
|
||||
* Stop the radio.
|
||||
*/
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Check if the radio is running.
|
||||
* @return True if the radio is running, false if not.
|
||||
*/
|
||||
bool isRunning();
|
||||
|
||||
/**
|
||||
* Tune the radio.
|
||||
* @param freq Frequency in Hz.
|
||||
*/
|
||||
void tune(double freq);
|
||||
|
||||
/**
|
||||
* Tune the radio.
|
||||
* @param freq Frequency to tune the radio to.
|
||||
*/
|
||||
void showMenu();
|
||||
|
||||
/**
|
||||
* Get the current samplerate of the radio.
|
||||
* @return Samplerate in Hz.
|
||||
*/
|
||||
double getSamplerate();
|
||||
|
||||
// =========== TODO: These functions should not happen in this class ===========
|
||||
|
||||
/**
|
||||
* Set offset to add to the tuned frequency.
|
||||
* @param offset Offset in Hz.
|
||||
*/
|
||||
void setTuningOffset(double offset);
|
||||
|
||||
/**
|
||||
* Set tuning mode.
|
||||
* @param mode Tuning mode.
|
||||
*/
|
||||
void setTuningMode(TuningMode mode);
|
||||
void setPanadapterIF(double freq);
|
||||
|
||||
std::vector<std::string> getSourceNames();
|
||||
/**
|
||||
* Set panadapter mode IF frequency.
|
||||
* @param freq IF frequency in Hz.
|
||||
*/
|
||||
void setPanadpterIF(double freq);
|
||||
|
||||
// =============================================================================
|
||||
|
||||
// Emitted after a new source has been registered.
|
||||
Event<std::string> onSourceRegistered;
|
||||
|
||||
// Emitted when a source is about to be unregistered.
|
||||
Event<std::string> onSourceUnregister;
|
||||
|
||||
// Emitted after a source has been unregistered.
|
||||
Event<std::string> onSourceUnregistered;
|
||||
|
||||
// Emitted when the samplerate of the incoming IQ has changed.
|
||||
Event<double> onSamplerateChanged;
|
||||
|
||||
// Emitted when the source manager is instructed to tune the radio.
|
||||
Event<double> onRetune;
|
||||
|
||||
private:
|
||||
std::map<std::string, SourceHandler*> sources;
|
||||
std::string selectedName;
|
||||
SourceHandler* selectedHandler = NULL;
|
||||
double tuneOffset;
|
||||
double currentFreq;
|
||||
double ifFreq = 0.0;
|
||||
TuningMode tuneMode = TuningMode::NORMAL;
|
||||
dsp::stream<dsp::complex_t> nullSource;
|
||||
void deselect();
|
||||
void setSamplerate(double samplerate);
|
||||
|
||||
std::vector<std::string> sourceNames;
|
||||
std::map<std::string, Source*> sources;
|
||||
|
||||
std::string selectedSourceName = "";
|
||||
Source* selectedSource = NULL;
|
||||
|
||||
bool running = false;
|
||||
double samplerate = 1e6;
|
||||
double frequency = 100e6;
|
||||
double offset = 0;
|
||||
double ifFrequency = 8.830e6;
|
||||
TuningMode mode = TUNING_MODE_NORMAL;
|
||||
|
||||
std::recursive_mutex mtx;
|
||||
};
|
||||
|
||||
class Source {
|
||||
public:
|
||||
virtual void showMenu() {}
|
||||
virtual void select() = 0;
|
||||
virtual void deselect() {}
|
||||
virtual bool start() = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual void tune(double freq) {}
|
||||
|
||||
dsp::stream<dsp::complex_t> stream;
|
||||
};
|
@ -1,43 +1,51 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <utils/flog.h>
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
|
||||
template <class T>
|
||||
struct EventHandler {
|
||||
EventHandler() {}
|
||||
EventHandler(void (*handler)(T, void*), void* ctx) {
|
||||
this->handler = handler;
|
||||
this->ctx = ctx;
|
||||
}
|
||||
typedef int HandlerID;
|
||||
|
||||
void (*handler)(T, void*);
|
||||
void* ctx;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
template <typename... Args>
|
||||
class Event {
|
||||
using Handler = std::function<void(Args...)>;
|
||||
public:
|
||||
Event() {}
|
||||
~Event() {}
|
||||
|
||||
void emit(T value) {
|
||||
for (auto const& handler : handlers) {
|
||||
handler->handler(value, handler->ctx);
|
||||
}
|
||||
HandlerID bind(Handler handler) {
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
HandlerID id = genID();
|
||||
handlers[id] = handler;
|
||||
return id;
|
||||
}
|
||||
|
||||
void bindHandler(EventHandler<T>* handler) {
|
||||
handlers.push_back(handler);
|
||||
template<typename MHandler, class T>
|
||||
HandlerID bind(MHandler handler, T* ctx) {
|
||||
return bind([=](Args... args){
|
||||
(ctx->*handler)(args...);
|
||||
});
|
||||
}
|
||||
|
||||
void unbindHandler(EventHandler<T>* handler) {
|
||||
if (std::find(handlers.begin(), handlers.end(), handler) == handlers.end()) {
|
||||
flog::error("Tried to remove a non-existent event handler");
|
||||
return;
|
||||
void unbind(HandlerID id) {
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
if (handlers.find(id) == handlers.end()) {
|
||||
throw std::runtime_error("Could not unbind handler, unknown ID");
|
||||
}
|
||||
handlers.erase(id);
|
||||
}
|
||||
|
||||
void operator()(Args... args) {
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
for (const auto& [desc, handler] : handlers) {
|
||||
handler(args...);
|
||||
}
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), handler), handlers.end());
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<EventHandler<T>*> handlers;
|
||||
HandlerID genID() {
|
||||
int id;
|
||||
for (id = 1; handlers.find(id) != handlers.end(); id++);
|
||||
return id;
|
||||
}
|
||||
|
||||
std::map<HandlerID, Handler> handlers;
|
||||
std::mutex mtx;
|
||||
};
|
@ -169,7 +169,7 @@ namespace flog {
|
||||
fprintf(outStream, "] %s\n", out.c_str());
|
||||
#elif defined(__ANDROID__)
|
||||
// Print format string
|
||||
__android_log_print(TYPE_PRIORITIES[type], FLOG_ANDROID_TAG, COLOR_WHITE "[%02d/%02d/%02d %02d:%02d:%02d.%03d] [%s%s" COLOR_WHITE "] %s\n",
|
||||
__android_log_buf_print(LOG_ID_DEFAULT, TYPE_PRIORITIES[type], FLOG_ANDROID_TAG, COLOR_WHITE "[%02d/%02d/%02d %02d:%02d:%02d.%03d] [%s%s" COLOR_WHITE "] %s\n",
|
||||
nowc->tm_mday, nowc->tm_mon + 1, nowc->tm_year + 1900, nowc->tm_hour, nowc->tm_min, nowc->tm_sec, 0, TYPE_COLORS[type], TYPE_STR[type], out.c_str());
|
||||
#else
|
||||
// Print format string
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "net.h"
|
||||
#include <string.h>
|
||||
#include <codecvt>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WOULD_BLOCK (WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
@ -86,14 +85,14 @@ namespace net {
|
||||
addr.sin_port = htons(port);
|
||||
}
|
||||
|
||||
std::string Address::getIPStr() const {
|
||||
std::string Address::getIPStr() {
|
||||
char buf[128];
|
||||
IP_t ip = getIP();
|
||||
sprintf(buf, "%d.%d.%d.%d", (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF);
|
||||
return buf;
|
||||
}
|
||||
|
||||
IP_t Address::getIP() const {
|
||||
IP_t Address::getIP() {
|
||||
return htonl(addr.sin_addr.s_addr);
|
||||
}
|
||||
|
||||
@ -101,7 +100,7 @@ namespace net {
|
||||
addr.sin_addr.s_addr = htonl(ip);
|
||||
}
|
||||
|
||||
int Address::getPort() const {
|
||||
int Address::getPort() {
|
||||
return htons(addr.sin_port);
|
||||
}
|
||||
|
||||
@ -138,16 +137,7 @@ namespace net {
|
||||
}
|
||||
|
||||
int Socket::send(const uint8_t* data, size_t len, const Address* dest) {
|
||||
// Send data
|
||||
int err = sendto(sock, (const char*)data, len, 0, (sockaddr*)(dest ? &dest->addr : (raddr ? &raddr->addr : NULL)), sizeof(sockaddr_in));
|
||||
|
||||
// On error, close socket
|
||||
if (err <= 0 && !WOULD_BLOCK) {
|
||||
close();
|
||||
return err;
|
||||
}
|
||||
|
||||
return err;
|
||||
return sendto(sock, (const char*)data, len, 0, (sockaddr*)(dest ? &dest->addr : (raddr ? &raddr->addr : NULL)), sizeof(sockaddr_in));
|
||||
}
|
||||
|
||||
int Socket::sendstr(const std::string& str, const Address* dest) {
|
||||
@ -169,8 +159,8 @@ namespace net {
|
||||
|
||||
// Set timeout
|
||||
timeval tv;
|
||||
tv.tv_sec = timeout / 1000;
|
||||
tv.tv_usec = (timeout - tv.tv_sec*1000) * 1000;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = timeout * 1000;
|
||||
|
||||
// Wait for data
|
||||
int err = select(sock+1, &set, NULL, &set, (timeout > 0) ? &tv : NULL);
|
||||
@ -234,8 +224,8 @@ namespace net {
|
||||
|
||||
// Define timeout
|
||||
timeval tv;
|
||||
tv.tv_sec = timeout / 1000;
|
||||
tv.tv_usec = (timeout - tv.tv_sec*1000) * 1000;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = timeout * 1000;
|
||||
|
||||
// Wait for data or error
|
||||
if (timeout != NONBLOCKING) {
|
||||
@ -298,7 +288,6 @@ namespace net {
|
||||
|
||||
// Save data
|
||||
for (auto iface = addresses; iface; iface = iface->ifa_next) {
|
||||
if (!iface->ifa_addr || !iface->ifa_netmask) { continue; }
|
||||
if (iface->ifa_addr->sa_family != AF_INET) { continue; }
|
||||
InterfaceInfo info;
|
||||
info.address = ntohl(*(uint32_t*)&iface->ifa_addr->sa_data[2]);
|
||||
@ -384,25 +373,13 @@ namespace net {
|
||||
return connect(Address(host, port));
|
||||
}
|
||||
|
||||
std::shared_ptr<Socket> openudp(const Address& raddr, const Address& laddr, bool allowBroadcast) {
|
||||
std::shared_ptr<Socket> openudp(const Address& raddr, const Address& laddr) {
|
||||
// Init library if needed
|
||||
init();
|
||||
|
||||
// Create socket
|
||||
SockHandle_t s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
|
||||
// If the remote address is multicast, allow multicast connections
|
||||
#ifdef _WIN32
|
||||
const char enable = allowBroadcast;
|
||||
#else
|
||||
int enable = allowBroadcast;
|
||||
#endif
|
||||
if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &enable, sizeof(int)) < 0) {
|
||||
closeSocket(s);
|
||||
throw std::runtime_error("Could not enable broadcast on socket");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Bind socket to local port
|
||||
if (bind(s, (sockaddr*)&laddr.addr, sizeof(sockaddr_in))) {
|
||||
closeSocket(s);
|
||||
@ -414,15 +391,15 @@ namespace net {
|
||||
return std::make_shared<Socket>(s, &raddr);
|
||||
}
|
||||
|
||||
std::shared_ptr<Socket> openudp(std::string rhost, int rport, const Address& laddr, bool allowBroadcast) {
|
||||
return openudp(Address(rhost, rport), laddr, allowBroadcast);
|
||||
std::shared_ptr<Socket> openudp(std::string rhost, int rport, const Address& laddr) {
|
||||
return openudp(Address(rhost, rport), laddr);
|
||||
}
|
||||
|
||||
std::shared_ptr<Socket> openudp(const Address& raddr, std::string lhost, int lport, bool allowBroadcast) {
|
||||
return openudp(raddr, Address(lhost, lport), allowBroadcast);
|
||||
std::shared_ptr<Socket> openudp(const Address& raddr, std::string lhost, int lport) {
|
||||
return openudp(raddr, Address(lhost, lport));
|
||||
}
|
||||
|
||||
std::shared_ptr<Socket> openudp(std::string rhost, int rport, std::string lhost, int lport, bool allowBroadcast) {
|
||||
return openudp(Address(rhost, rport), Address(lhost, lport), allowBroadcast);
|
||||
std::shared_ptr<Socket> openudp(std::string rhost, int rport, std::string lhost, int lport) {
|
||||
return openudp(Address(rhost, rport), Address(lhost, lport));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
@ -67,13 +66,13 @@ namespace net {
|
||||
* Get the IP address.
|
||||
* @return IP address in standard string format.
|
||||
*/
|
||||
std::string getIPStr() const;
|
||||
std::string getIPStr();
|
||||
|
||||
/**
|
||||
* Get the IP address.
|
||||
* @return IP address in host byte order.
|
||||
*/
|
||||
IP_t getIP() const;
|
||||
IP_t getIP();
|
||||
|
||||
/**
|
||||
* Set the IP address.
|
||||
@ -85,7 +84,7 @@ namespace net {
|
||||
* Get the TCP/UDP port.
|
||||
* @return TCP/UDP port number.
|
||||
*/
|
||||
int getPort() const;
|
||||
int getPort();
|
||||
|
||||
/**
|
||||
* Set the TCP/UDP port.
|
||||
@ -246,37 +245,37 @@ namespace net {
|
||||
|
||||
/**
|
||||
* Create UDP socket.
|
||||
* @param raddr Remote address. Set to a multicast address to allow multicast.
|
||||
* @param raddr Remote address.
|
||||
* @param laddr Local address to bind the socket to.
|
||||
* @return Socket instance on success, Throws runtime_error otherwise.
|
||||
*/
|
||||
std::shared_ptr<Socket> openudp(const Address& raddr, const Address& laddr, bool allowBroadcast = false);
|
||||
std::shared_ptr<Socket> openudp(const Address& raddr, const Address& laddr);
|
||||
|
||||
/**
|
||||
* Create UDP socket.
|
||||
* @param rhost Remote hostname or IP address. Set to a multicast address to allow multicast.
|
||||
* @param rhost Remote hostname or IP address.
|
||||
* @param rport Remote port.
|
||||
* @param laddr Local address to bind the socket to.
|
||||
* @return Socket instance on success, Throws runtime_error otherwise.
|
||||
*/
|
||||
std::shared_ptr<Socket> openudp(std::string rhost, int rport, const Address& laddr, bool allowBroadcast = false);
|
||||
std::shared_ptr<Socket> openudp(std::string rhost, int rport, const Address& laddr);
|
||||
|
||||
/**
|
||||
* Create UDP socket.
|
||||
* @param raddr Remote address. Set to a multicast or broadcast address to allow multicast.
|
||||
* @param raddr Remote address.
|
||||
* @param lhost Local hostname or IP used to bind the socket (optional, "0.0.0.0" for Any).
|
||||
* @param lpost Local port used to bind the socket to (optional, 0 to allocate automatically).
|
||||
* @return Socket instance on success, Throws runtime_error otherwise.
|
||||
*/
|
||||
std::shared_ptr<Socket> openudp(const Address& raddr, std::string lhost = "0.0.0.0", int lport = 0, bool allowBroadcast = false);
|
||||
std::shared_ptr<Socket> openudp(const Address& raddr, std::string lhost = "0.0.0.0", int lport = 0);
|
||||
|
||||
/**
|
||||
* Create UDP socket.
|
||||
* @param rhost Remote hostname or IP address. Set to a multicast or broadcast address to allow multicast.
|
||||
* @param rhost Remote hostname or IP address.
|
||||
* @param rport Remote port.
|
||||
* @param lhost Local hostname or IP used to bind the socket (optional, "0.0.0.0" for Any).
|
||||
* @param lpost Local port used to bind the socket to (optional, 0 to allocate automatically).
|
||||
* @return Socket instance on success, Throws runtime_error otherwise.
|
||||
*/
|
||||
std::shared_ptr<Socket> openudp(std::string rhost, int rport, std::string lhost = "0.0.0.0", int lport = 0, bool allowBroadcast = false);
|
||||
std::shared_ptr<Socket> openudp(std::string rhost, int rport, std::string lhost = "0.0.0.0", int lport = 0);
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
#include <utils/networking.h>
|
||||
#include <assert.h>
|
||||
#include <utils/flog.h>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace net {
|
||||
|
||||
@ -320,7 +319,7 @@ namespace net {
|
||||
}
|
||||
entry.handler(std::move(client), entry.ctx);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
catch (std::exception e) {
|
||||
listening = false;
|
||||
return;
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
|
||||
typedef int HandlerID;
|
||||
|
||||
template <typename... Args>
|
||||
class NewEvent {
|
||||
public:
|
||||
using Handler = std::function<void(Args...)>;
|
||||
|
||||
HandlerID bind(const Handler& handler) {
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
HandlerID id = genID();
|
||||
handlers[id] = handler;
|
||||
return id;
|
||||
}
|
||||
|
||||
template<typename MHandler, class T>
|
||||
HandlerID bind(MHandler handler, T* ctx) {
|
||||
return bind([=](Args... args){
|
||||
(ctx->*handler)(args...);
|
||||
});
|
||||
}
|
||||
|
||||
void unbind(HandlerID id) {
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
if (handlers.find(id) == handlers.end()) {
|
||||
throw std::runtime_error("Could not unbind handler, unknown ID");
|
||||
}
|
||||
handlers.erase(id);
|
||||
}
|
||||
|
||||
void operator()(Args... args) {
|
||||
std::lock_guard<std::mutex> lck(mtx);
|
||||
for (const auto& [desc, handler] : handlers) {
|
||||
handler(args...);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
HandlerID genID() {
|
||||
int id;
|
||||
for (id = 1; handlers.find(id) != handlers.end(); id++);
|
||||
return id;
|
||||
}
|
||||
|
||||
std::map<HandlerID, Handler> handlers;
|
||||
std::mutex mtx;
|
||||
};
|
@ -8,7 +8,7 @@ class OptionList {
|
||||
public:
|
||||
OptionList() { updateText(); }
|
||||
|
||||
void define(const K& key, const std::string& name, const T& value) {
|
||||
void define(K key, std::string name, T value) {
|
||||
if (keyExists(key)) { throw std::runtime_error("Key already exists"); }
|
||||
if (nameExists(name)) { throw std::runtime_error("Name already exists"); }
|
||||
if (valueExists(value)) { throw std::runtime_error("Value already exists"); }
|
||||
@ -18,27 +18,27 @@ public:
|
||||
updateText();
|
||||
}
|
||||
|
||||
void define(const std::string& name, const T& value) {
|
||||
void define(std::string name, T value) {
|
||||
define(name, name, value);
|
||||
}
|
||||
|
||||
void undefine(int id) {
|
||||
void undefined(int id) {
|
||||
keys.erase(keys.begin() + id);
|
||||
names.erase(names.begin() + id);
|
||||
values.erase(values.begin() + id);
|
||||
updateText();
|
||||
}
|
||||
|
||||
void undefineKey(const K& key) {
|
||||
undefine(keyId(key));
|
||||
void undefineKey(K key) {
|
||||
undefined(keyId(key));
|
||||
}
|
||||
|
||||
void undefineName(const std::string& name) {
|
||||
undefine(nameId(name));
|
||||
void undefineName(std::string name) {
|
||||
undefined(nameId(name));
|
||||
}
|
||||
|
||||
void undefineValue(const T& value) {
|
||||
undefine(valueId(value));
|
||||
void undefineValue(T value) {
|
||||
undefined(valueId(value));
|
||||
}
|
||||
|
||||
void clear() {
|
||||
@ -48,61 +48,61 @@ public:
|
||||
updateText();
|
||||
}
|
||||
|
||||
int size() const {
|
||||
int size() {
|
||||
return keys.size();
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
bool empty() {
|
||||
return keys.empty();
|
||||
}
|
||||
|
||||
bool keyExists(const K& key) const {
|
||||
bool keyExists(K key) {
|
||||
if (std::find(keys.begin(), keys.end(), key) != keys.end()) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nameExists(const std::string& name) const {
|
||||
bool nameExists(std::string name) {
|
||||
if (std::find(names.begin(), names.end(), name) != names.end()) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
bool valueExists(const T& value) const {
|
||||
bool valueExists(T value) {
|
||||
if (std::find(values.begin(), values.end(), value) != values.end()) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
int keyId(const K& key) const {
|
||||
int keyId(K key) {
|
||||
auto it = std::find(keys.begin(), keys.end(), key);
|
||||
if (it == keys.end()) { throw std::runtime_error("Key doesn't exists"); }
|
||||
return std::distance(keys.begin(), it);
|
||||
}
|
||||
|
||||
int nameId(const std::string& name) const {
|
||||
int nameId(std::string name) {
|
||||
auto it = std::find(names.begin(), names.end(), name);
|
||||
if (it == names.end()) { throw std::runtime_error("Name doesn't exists"); }
|
||||
return std::distance(names.begin(), it);
|
||||
}
|
||||
|
||||
int valueId(const T& value) const {
|
||||
int valueId(T value) {
|
||||
auto it = std::find(values.begin(), values.end(), value);
|
||||
if (it == values.end()) { throw std::runtime_error("Value doesn't exists"); }
|
||||
return std::distance(values.begin(), it);
|
||||
}
|
||||
|
||||
inline const K& key(int id) const {
|
||||
K key(int id) {
|
||||
return keys[id];
|
||||
}
|
||||
|
||||
inline const std::string& name(int id) const {
|
||||
std::string name(int id) {
|
||||
return names[id];
|
||||
}
|
||||
|
||||
inline const T& value(int id) const {
|
||||
T value(int id) {
|
||||
return values[id];
|
||||
}
|
||||
|
||||
inline const T& operator[](int& id) const {
|
||||
return values[id];
|
||||
T operator[](int& id) {
|
||||
return value(id);
|
||||
}
|
||||
|
||||
const char* txt = NULL;
|
||||
|
@ -257,7 +257,6 @@ namespace net::http {
|
||||
|
||||
// Deserialize
|
||||
req.deserialize(respData);
|
||||
return 0; // Might wanna return size instead
|
||||
}
|
||||
|
||||
int Client::sendResponseHeader(ResponseHeader& resp) {
|
||||
@ -275,7 +274,6 @@ namespace net::http {
|
||||
|
||||
// Deserialize
|
||||
resp.deserialize(respData);
|
||||
return 0; // Might wanna return size instead
|
||||
}
|
||||
|
||||
int Client::sendChunkHeader(ChunkHeader& chdr) {
|
||||
|
@ -7,14 +7,6 @@ namespace riff {
|
||||
const char* LIST_SIGNATURE = "LIST";
|
||||
const size_t RIFF_LABEL_SIZE = 4;
|
||||
|
||||
// Writer::Writer(const Writer&& b) {
|
||||
// //file = std::move(b.file);
|
||||
// }
|
||||
|
||||
Writer::~Writer() {
|
||||
close();
|
||||
}
|
||||
|
||||
bool Writer::open(std::string path, const char form[4]) {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
@ -99,9 +91,9 @@ namespace riff {
|
||||
file.write((char*)&desc.hdr.size, sizeof(desc.hdr.size));
|
||||
file.seekp(pos);
|
||||
|
||||
// If parent chunk, increment its size by the size of the sub-chunk plus the size of its header)
|
||||
// If parent chunk, increment its size
|
||||
if (!chunks.empty()) {
|
||||
chunks.top().hdr.size += desc.hdr.size + sizeof(ChunkHeader);
|
||||
chunks.top().hdr.size += desc.hdr.size;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,10 +20,6 @@ namespace riff {
|
||||
|
||||
class Writer {
|
||||
public:
|
||||
Writer() {}
|
||||
// Writer(const Writer&& b);
|
||||
~Writer();
|
||||
|
||||
bool open(std::string path, const char form[4]);
|
||||
bool isOpen();
|
||||
void close();
|
||||
@ -44,23 +40,4 @@ namespace riff {
|
||||
std::ofstream file;
|
||||
std::stack<ChunkDesc> chunks;
|
||||
};
|
||||
|
||||
// class Reader {
|
||||
// public:
|
||||
// Reader();
|
||||
// Reader(const Reader&& b);
|
||||
// ~Reader();
|
||||
|
||||
// bool open(std::string path);
|
||||
// bool isOpen();
|
||||
// void close();
|
||||
|
||||
// const std::string& form();
|
||||
|
||||
// private:
|
||||
|
||||
// std::string _form;
|
||||
// std::recursive_mutex mtx;
|
||||
// std::ofstream file;
|
||||
// };
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_STR "1.2.0"
|
||||
#define VERSION_STR "1.1.0"
|
@ -1,63 +0,0 @@
|
||||
#pragma once
|
||||
#include <dsp/loop/pll.h>
|
||||
#include "chrominance_filter.h"
|
||||
|
||||
// TODO: Should be 60 but had to try something
|
||||
#define BURST_START (63+CHROMA_FIR_DELAY)
|
||||
#define BURST_END (BURST_START+28)
|
||||
|
||||
#define A_PHASE ((135.0/180.0)*FL_M_PI)
|
||||
#define B_PHASE ((-135.0/180.0)*FL_M_PI)
|
||||
|
||||
namespace dsp::loop {
|
||||
class ChromaPLL : public PLL {
|
||||
using base_type = PLL;
|
||||
public:
|
||||
ChromaPLL() {}
|
||||
|
||||
ChromaPLL(stream<complex_t>* in, double bandwidth, double initPhase = 0.0, double initFreq = 0.0, double minFreq = -FL_M_PI, double maxFreq = FL_M_PI) {
|
||||
base_type::init(in, bandwidth, initFreq, initPhase, minFreq, maxFreq);
|
||||
}
|
||||
|
||||
inline int process(int count, complex_t* in, complex_t* out, bool aphase = false) {
|
||||
// Process the pre-burst section
|
||||
for (int i = 0; i < BURST_START; i++) {
|
||||
out[i] = in[i] * math::phasor(-pcl.phase);
|
||||
pcl.advancePhase();
|
||||
}
|
||||
|
||||
// Process the burst itself
|
||||
if (aphase) {
|
||||
for (int i = BURST_START; i < BURST_END; i++) {
|
||||
complex_t outVal = in[i] * math::phasor(-pcl.phase);
|
||||
out[i] = outVal;
|
||||
pcl.advance(math::normalizePhase(outVal.phase() - A_PHASE));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = BURST_START; i < BURST_END; i++) {
|
||||
complex_t outVal = in[i] * math::phasor(-pcl.phase);
|
||||
out[i] = outVal;
|
||||
pcl.advance(math::normalizePhase(outVal.phase() - B_PHASE));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process the post-burst section
|
||||
for (int i = BURST_END; i < count; i++) {
|
||||
out[i] = in[i] * math::phasor(-pcl.phase);
|
||||
pcl.advancePhase();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
inline int processBlank(int count, complex_t* in, complex_t* out) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
out[i] = in[i] * math::phasor(-pcl.phase);
|
||||
pcl.advancePhase();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
}
|
@ -1,239 +0,0 @@
|
||||
#pragma once
|
||||
#include <dsp/types.h>
|
||||
|
||||
inline const dsp::complex_t CHROMA_FIR[] = {
|
||||
{-0.000005461290583903, -0.000011336784355655},
|
||||
{ 0.000020060944485414, 0.000009851315045203},
|
||||
{-0.000034177222729438, 0.000007245841504981},
|
||||
{ 0.000027694034878705, -0.000033114740542635},
|
||||
{-0.000001217597841648, 0.000039141482370942},
|
||||
{-0.000008324593371228, -0.000011315001355976},
|
||||
{-0.000038085228233509, -0.000010585909953738},
|
||||
{ 0.000114833396071141, -0.000047778708840608},
|
||||
{-0.000115428390169113, 0.000205816198882814},
|
||||
{-0.000055467806072871, -0.000356692479491626},
|
||||
{ 0.000349316846854190, 0.000326162940234916},
|
||||
{-0.000558465829929114, -0.000048001521408724},
|
||||
{ 0.000488176200631416, -0.000319593757302922},
|
||||
{-0.000169437838021935, 0.000501610900725908},
|
||||
{-0.000131793335799502, -0.000373003580727547},
|
||||
{ 0.000166817395492786, 0.000105930895534474},
|
||||
{ 0.000030499908326112, -0.000003048682668943},
|
||||
{-0.000174999505027919, 0.000168008090089458},
|
||||
{ 0.000054431163395030, -0.000385174790951272},
|
||||
{ 0.000215876012859739, 0.000372695852521209},
|
||||
{-0.000325534912280750, -0.000130173041693966},
|
||||
{ 0.000154951430569290, -0.000045395998708328},
|
||||
{ 0.000054324657659002, -0.000076028700470037},
|
||||
{ 0.000015664427565764, 0.000348002612845696},
|
||||
{-0.000345943017888332, -0.000402175417043307},
|
||||
{ 0.000568731727879741, 0.000112347863435682},
|
||||
{-0.000416485880859085, 0.000211750352828909},
|
||||
{ 0.000087462353623011, -0.000188197153014309},
|
||||
{-0.000032082305030264, -0.000136804226080664},
|
||||
{ 0.000379089999045955, 0.000303466839685362},
|
||||
{-0.000726760198519770, -0.000007022279302816},
|
||||
{ 0.000619888661818195, -0.000476871323359809},
|
||||
{-0.000151885493742993, 0.000595641190573181},
|
||||
{-0.000100626407015494, -0.000227947144491108},
|
||||
{-0.000201935458823941, -0.000107628631934340},
|
||||
{ 0.000680260922139900, -0.000120771182888852},
|
||||
{-0.000666108629277491, 0.000744775901128973},
|
||||
{ 0.000067236591919755, -0.001044125966364420},
|
||||
{ 0.000447037274751822, 0.000651912509450913},
|
||||
{-0.000262675893448686, -0.000082499729563337},
|
||||
{-0.000349821460486320, 0.000132102793530818},
|
||||
{ 0.000507024815168287, -0.000837598610490618},
|
||||
{ 0.000163814255478652, 0.001346530693477834},
|
||||
{-0.000970457632383793, -0.000968411010101160},
|
||||
{ 0.000974834882891140, 0.000116507082762032},
|
||||
{-0.000225464280571542, 0.000137131865995708},
|
||||
{-0.000211542240694642, 0.000563783548428947},
|
||||
{-0.000414412310798766, -0.001309793399193736},
|
||||
{ 0.001497010004594478, 0.001021907858926259},
|
||||
{-0.001752019159639658, 0.000116536066154131},
|
||||
{ 0.000872822027879430, -0.000783952720205569},
|
||||
{-0.000032439446797970, 0.000184988059956734},
|
||||
{ 0.000446259382722895, 0.000833040920509238},
|
||||
{-0.001741577737284306, -0.000764423771425237},
|
||||
{ 0.002306569133792772, -0.000593352416441601},
|
||||
{-0.001336084746214192, 0.001744394557524181},
|
||||
{-0.000015810020735495, -0.001342809547658260},
|
||||
{ 0.000007636494885364, 0.000009498318627546},
|
||||
{ 0.001403876768349702, 0.000326101441888391},
|
||||
{-0.002351020828600226, 0.001098649819278302},
|
||||
{ 0.001389314639579544, -0.002746943712072884},
|
||||
{ 0.000526319899588909, 0.002635084366837732},
|
||||
{-0.001109526585744687, -0.000950323796527721},
|
||||
{-0.000307792427984886, -0.000013203419520794},
|
||||
{ 0.001737955094951111, -0.001247368808692850},
|
||||
{-0.000974502437588420, 0.003352512117661680},
|
||||
{-0.001462571137390936, -0.003635296917435679},
|
||||
{ 0.002783459090201693, 0.001604420226187745},
|
||||
{-0.001471518558760170, 0.000211117948702137},
|
||||
{-0.000575340825070194, 0.000601820846100026},
|
||||
{ 0.000302090333345692, -0.003088058972305493},
|
||||
{ 0.002496092353182990, 0.003912508340989065},
|
||||
{-0.004645661091012423, -0.001630427298020200},
|
||||
{ 0.003556824805628799, -0.001209822327859352},
|
||||
{-0.000744999556260706, 0.001143238699138109},
|
||||
{ 0.000144278726929409, 0.001638049051599065},
|
||||
{-0.003025291044450178, -0.003226370992887968},
|
||||
{ 0.006047866290490120, 0.000927406808799887},
|
||||
{-0.005338456415106141, 0.003008811999350399},
|
||||
{ 0.001642959659014839, -0.003972384205231079},
|
||||
{ 0.000273874932822212, 0.000977326273749033},
|
||||
{ 0.002315022846573390, 0.001695671268241410},
|
||||
{-0.006240953957978884, 0.000207330368698293},
|
||||
{ 0.006164252120861735, -0.005177351717451013},
|
||||
{-0.001560310257561104, 0.007437030759707700},
|
||||
{-0.002131333814462852, -0.004317129694157112},
|
||||
{ 0.000280518918541908, 0.000134405998842553},
|
||||
{ 0.004612116481180659, -0.001024468120657814},
|
||||
{-0.005599300279638699, 0.006828277067771868},
|
||||
{ 0.000228879728552504, -0.010675998154712657},
|
||||
{ 0.005692081512980654, 0.007582243186569848},
|
||||
{-0.005100500569859509, -0.001364751685737153},
|
||||
{-0.000902490398043454, 0.000385770160220703},
|
||||
{ 0.003673858819546609, -0.006701685283451640},
|
||||
{ 0.002079056046131593, 0.012568579063417429},
|
||||
{-0.010730008156911677, -0.009826454574016218},
|
||||
{ 0.012092401380903161, 0.000921764172237851},
|
||||
{-0.004714530989129091, 0.003151948807627123},
|
||||
{-0.001055930168838909, 0.003228576712467020},
|
||||
{-0.004343270165991213, -0.011924332879354394},
|
||||
{ 0.016499994418955999, 0.010255324919126899},
|
||||
{-0.021047239750251585, 0.002309419513135448},
|
||||
{ 0.011855513874047341, -0.011604071033866310},
|
||||
{-0.000777842281358575, 0.005916341648175263},
|
||||
{ 0.004380939277688377, 0.007397670455730446},
|
||||
{-0.021891594662401131, -0.008509480947490166},
|
||||
{ 0.032787638290674201, -0.009950745850861956},
|
||||
{-0.021022579272463194, 0.030030850567389102},
|
||||
{-0.001508145650189953, -0.027571914870304640},
|
||||
{ 0.004056649693022923, 0.004624901687718579},
|
||||
{ 0.025728742586666287, 0.004824671348397606},
|
||||
{-0.058002700931665603, 0.030198618296813803},
|
||||
{ 0.043631619628438784, -0.096308304333327280},
|
||||
{ 0.033451363423624300, 0.136687079396426990},
|
||||
{-0.129387018420204200, -0.101540513046619400},
|
||||
{ 0.172881344826560730, -0.000000000000005297},
|
||||
{-0.129387018420198010, 0.101540513046627330},
|
||||
{ 0.033451363423615862, -0.136687079396429050},
|
||||
{ 0.043631619628444723, 0.096308304333324601},
|
||||
{-0.058002700931667456, -0.030198618296810247},
|
||||
{ 0.025728742586665992, -0.004824671348399184},
|
||||
{ 0.004056649693022639, -0.004624901687718827},
|
||||
{-0.001508145650188251, 0.027571914870304734},
|
||||
{-0.021022579272465047, -0.030030850567387805},
|
||||
{ 0.032787638290674812, 0.009950745850859947},
|
||||
{-0.021891594662400610, 0.008509480947491507},
|
||||
{ 0.004380939277687923, -0.007397670455730714},
|
||||
{-0.000777842281358940, -0.005916341648175215},
|
||||
{ 0.011855513874048058, 0.011604071033865578},
|
||||
{-0.021047239750251731, -0.002309419513134139},
|
||||
{ 0.016499994418955360, -0.010255324919127926},
|
||||
{-0.004343270165990471, 0.011924332879354665},
|
||||
{-0.001055930168839110, -0.003228576712466955},
|
||||
{-0.004714530989129287, -0.003151948807626830},
|
||||
{ 0.012092401380903103, -0.000921764172238603},
|
||||
{-0.010730008156911072, 0.009826454574016881},
|
||||
{ 0.002079056046130817, -0.012568579063417559},
|
||||
{ 0.003673858819547020, 0.006701685283451416},
|
||||
{-0.000902490398043478, -0.000385770160220647},
|
||||
{-0.005100500569859424, 0.001364751685737466},
|
||||
{ 0.005692081512980187, -0.007582243186570198},
|
||||
{ 0.000228879728553163, 0.010675998154712643},
|
||||
{-0.005599300279639117, -0.006828277067771524},
|
||||
{ 0.004612116481180722, 0.001024468120657532},
|
||||
{ 0.000280518918541900, -0.000134405998842571},
|
||||
{-0.002131333814462586, 0.004317129694157243},
|
||||
{-0.001560310257561563, -0.007437030759707604},
|
||||
{ 0.006164252120862052, 0.005177351717450635},
|
||||
{-0.006240953957978898, -0.000207330368697911},
|
||||
{ 0.002315022846573286, -0.001695671268241552},
|
||||
{ 0.000273874932822152, -0.000977326273749050},
|
||||
{ 0.001642959659015084, 0.003972384205230976},
|
||||
{-0.005338456415106324, -0.003008811999350072},
|
||||
{ 0.006047866290490063, -0.000927406808800258},
|
||||
{-0.003025291044449980, 0.003226370992888153},
|
||||
{ 0.000144278726929308, -0.001638049051599074},
|
||||
{-0.000744999556260777, -0.001143238699138063},
|
||||
{ 0.003556824805628873, 0.001209822327859134},
|
||||
{-0.004645661091012323, 0.001630427298020484},
|
||||
{ 0.002496092353182751, -0.003912508340989219},
|
||||
{ 0.000302090333345882, 0.003088058972305475},
|
||||
{-0.000575340825070231, -0.000601820846099991},
|
||||
{-0.001471518558760183, -0.000211117948702046},
|
||||
{ 0.002783459090201593, -0.001604420226187919},
|
||||
{-0.001462571137390710, 0.003635296917435769},
|
||||
{-0.000974502437588628, -0.003352512117661619},
|
||||
{ 0.001737955094951189, 0.001247368808692742},
|
||||
{-0.000307792427984885, 0.000013203419520814},
|
||||
{-0.001109526585744628, 0.000950323796527789},
|
||||
{ 0.000526319899588746, -0.002635084366837765},
|
||||
{ 0.001389314639579712, 0.002746943712072799},
|
||||
{-0.002351020828600294, -0.001098649819278158},
|
||||
{ 0.001403876768349682, -0.000326101441888477},
|
||||
{ 0.000007636494885364, -0.000009498318627546},
|
||||
{-0.000015810020735412, 0.001342809547658261},
|
||||
{-0.001336084746214299, -0.001744394557524099},
|
||||
{ 0.002306569133792808, 0.000593352416441460},
|
||||
{-0.001741577737284259, 0.000764423771425344},
|
||||
{ 0.000446259382722843, -0.000833040920509266},
|
||||
{-0.000032439446797982, -0.000184988059956732},
|
||||
{ 0.000872822027879478, 0.000783952720205515},
|
||||
{-0.001752019159639665, -0.000116536066154024},
|
||||
{ 0.001497010004594416, -0.001021907858926351},
|
||||
{-0.000414412310798685, 0.001309793399193761},
|
||||
{-0.000211542240694677, -0.000563783548428934},
|
||||
{-0.000225464280571550, -0.000137131865995694},
|
||||
{ 0.000974834882891133, -0.000116507082762092},
|
||||
{-0.000970457632383734, 0.000968411010101219},
|
||||
{ 0.000163814255478569, -0.001346530693477844},
|
||||
{ 0.000507024815168339, 0.000837598610490586},
|
||||
{-0.000349821460486328, -0.000132102793530797},
|
||||
{-0.000262675893448681, 0.000082499729563353},
|
||||
{ 0.000447037274751782, -0.000651912509450940},
|
||||
{ 0.000067236591919819, 0.001044125966364416},
|
||||
{-0.000666108629277537, -0.000744775901128932},
|
||||
{ 0.000680260922139908, 0.000120771182888810},
|
||||
{-0.000201935458823935, 0.000107628631934352},
|
||||
{-0.000100626407015480, 0.000227947144491114},
|
||||
{-0.000151885493743030, -0.000595641190573172},
|
||||
{ 0.000619888661818225, 0.000476871323359771},
|
||||
{-0.000726760198519770, 0.000007022279302861},
|
||||
{ 0.000379089999045936, -0.000303466839685386},
|
||||
{-0.000032082305030256, 0.000136804226080666},
|
||||
{ 0.000087462353623023, 0.000188197153014303},
|
||||
{-0.000416485880859098, -0.000211750352828883},
|
||||
{ 0.000568731727879734, -0.000112347863435717},
|
||||
{-0.000345943017888307, 0.000402175417043329},
|
||||
{ 0.000015664427565742, -0.000348002612845697},
|
||||
{ 0.000054324657659007, 0.000076028700470034},
|
||||
{ 0.000154951430569292, 0.000045395998708319},
|
||||
{-0.000325534912280742, 0.000130173041693986},
|
||||
{ 0.000215876012859716, -0.000372695852521222},
|
||||
{ 0.000054431163395054, 0.000385174790951269},
|
||||
{-0.000174999505027930, -0.000168008090089447},
|
||||
{ 0.000030499908326113, 0.000003048682668941},
|
||||
{ 0.000166817395492779, -0.000105930895534485},
|
||||
{-0.000131793335799479, 0.000373003580727555},
|
||||
{-0.000169437838021966, -0.000501610900725898},
|
||||
{ 0.000488176200631435, 0.000319593757302892},
|
||||
{-0.000558465829929111, 0.000048001521408758},
|
||||
{ 0.000349316846854170, -0.000326162940234938},
|
||||
{-0.000055467806072849, 0.000356692479491629},
|
||||
{-0.000115428390169126, -0.000205816198882806},
|
||||
{ 0.000114833396071144, 0.000047778708840601},
|
||||
{-0.000038085228233508, 0.000010585909953741},
|
||||
{-0.000008324593371228, 0.000011315001355977},
|
||||
{-0.000001217597841650, -0.000039141482370942},
|
||||
{ 0.000027694034878707, 0.000033114740542633},
|
||||
{-0.000034177222729439, -0.000007245841504979},
|
||||
{ 0.000020060944485413, -0.000009851315045204},
|
||||
{-0.000005461290583903, 0.000011336784355656},
|
||||
};
|
||||
|
||||
#define CHROMA_FIR_SIZE (sizeof(CHROMA_FIR)/sizeof(dsp::complex_t))
|
||||
#define CHROMA_FIR_DELAY ((CHROMA_FIR_SIZE-1)/2)
|
@ -1,193 +0,0 @@
|
||||
#pragma once
|
||||
#include <dsp/processor.h>
|
||||
#include <dsp/loop/phase_control_loop.h>
|
||||
#include <dsp/taps/windowed_sinc.h>
|
||||
#include <dsp/multirate/polyphase_bank.h>
|
||||
#include <dsp/math/step.h>
|
||||
|
||||
class LineSync : public dsp::Processor<float, float> {
|
||||
using base_type = dsp::Processor<float, float>;
|
||||
public:
|
||||
LineSync() {}
|
||||
|
||||
LineSync(dsp::stream<float>* in, double omega, double omegaGain, double muGain, double omegaRelLimit, int interpPhaseCount = 128, int interpTapCount = 8) { init(in, omega, omegaGain, muGain, omegaRelLimit, interpPhaseCount, interpTapCount); }
|
||||
|
||||
~LineSync() {
|
||||
if (!base_type::_block_init) { return; }
|
||||
base_type::stop();
|
||||
dsp::multirate::freePolyphaseBank(interpBank);
|
||||
dsp::buffer::free(buffer);
|
||||
}
|
||||
|
||||
void init(dsp::stream<float>* in, double omega, double omegaGain, double muGain, double omegaRelLimit, int interpPhaseCount = 128, int interpTapCount = 8) {
|
||||
_omega = omega;
|
||||
_omegaGain = omegaGain;
|
||||
_muGain = muGain;
|
||||
_omegaRelLimit = omegaRelLimit;
|
||||
_interpPhaseCount = interpPhaseCount;
|
||||
_interpTapCount = interpTapCount;
|
||||
|
||||
pcl.init(_muGain, _omegaGain, 0.0, 0.0, 1.0, _omega, _omega * (1.0 - omegaRelLimit), _omega * (1.0 + omegaRelLimit));
|
||||
generateInterpTaps();
|
||||
buffer = dsp::buffer::alloc<float>(STREAM_BUFFER_SIZE + _interpTapCount);
|
||||
bufStart = &buffer[_interpTapCount - 1];
|
||||
|
||||
base_type::init(in);
|
||||
}
|
||||
|
||||
void setOmegaGain(double omegaGain) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
_omegaGain = omegaGain;
|
||||
pcl.setCoefficients(_muGain, _omegaGain);
|
||||
}
|
||||
|
||||
void setMuGain(double muGain) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
_muGain = muGain;
|
||||
pcl.setCoefficients(_muGain, _omegaGain);
|
||||
}
|
||||
|
||||
void setOmegaRelLimit(double omegaRelLimit) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
_omegaRelLimit = omegaRelLimit;
|
||||
pcl.setFreqLimits(_omega * (1.0 - _omegaRelLimit), _omega * (1.0 + _omegaRelLimit));
|
||||
}
|
||||
|
||||
void setSyncLevel(float level) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
syncLevel = level;
|
||||
}
|
||||
|
||||
void setInterpParams(int interpPhaseCount, int interpTapCount) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
base_type::tempStop();
|
||||
_interpPhaseCount = interpPhaseCount;
|
||||
_interpTapCount = interpTapCount;
|
||||
dsp::multirate::freePolyphaseBank(interpBank);
|
||||
dsp::buffer::free(buffer);
|
||||
generateInterpTaps();
|
||||
buffer = dsp::buffer::alloc<float>(STREAM_BUFFER_SIZE + _interpTapCount);
|
||||
bufStart = &buffer[_interpTapCount - 1];
|
||||
base_type::tempStart();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
base_type::tempStop();
|
||||
offset = 0;
|
||||
pcl.phase = 0.0f;
|
||||
pcl.freq = _omega;
|
||||
base_type::tempStart();
|
||||
}
|
||||
|
||||
int run() {
|
||||
int count = base_type::_in->read();
|
||||
if (count < 0) { return -1; }
|
||||
|
||||
// Copy data to work buffer
|
||||
memcpy(bufStart, base_type::_in->readBuf, count * sizeof(float));
|
||||
|
||||
if (test2) {
|
||||
test2 = false;
|
||||
offset += 5;
|
||||
}
|
||||
|
||||
// Process all samples
|
||||
while (offset < count) {
|
||||
// Calculate new output value
|
||||
int phase = std::clamp<int>(floorf(pcl.phase * (float)_interpPhaseCount), 0, _interpPhaseCount - 1);
|
||||
float outVal;
|
||||
volk_32f_x2_dot_prod_32f(&outVal, &buffer[offset], interpBank.phases[phase], _interpTapCount);
|
||||
base_type::out.writeBuf[outCount++] = outVal;
|
||||
|
||||
// If the end of the line is reached, process it and determin error
|
||||
float error = 0;
|
||||
if (outCount >= 720) {
|
||||
// Compute averages.
|
||||
float left = 0.0f, right = 0.0f;
|
||||
for (int i = (720-17); i < 720; i++) {
|
||||
left += base_type::out.writeBuf[i];
|
||||
}
|
||||
for (int i = 0; i < 27; i++) {
|
||||
left += base_type::out.writeBuf[i];
|
||||
}
|
||||
for (int i = 27; i < (54+17); i++) {
|
||||
right += base_type::out.writeBuf[i];
|
||||
}
|
||||
left *= (1.0f/44.0f);
|
||||
right *= (1.0f/44.0f);
|
||||
|
||||
// If the sync is present, compute error
|
||||
if ((left < syncLevel && right < syncLevel) && !forceLock) {
|
||||
error = (left + syncBias - right);
|
||||
locked = true;
|
||||
}
|
||||
else {
|
||||
locked = false;
|
||||
}
|
||||
|
||||
if (++counter >= 100) {
|
||||
counter = 0;
|
||||
//flog::warn("Left: {}, Right: {}, Error: {}, Freq: {}, Phase: {}", left, right, error, pcl.freq, pcl.phase);
|
||||
}
|
||||
|
||||
// Output line
|
||||
if (!base_type::out.swap(outCount)) { break; }
|
||||
outCount = 0;
|
||||
}
|
||||
|
||||
// Advance symbol offset and phase
|
||||
pcl.advance(error);
|
||||
float delta = floorf(pcl.phase);
|
||||
offset += delta;
|
||||
pcl.phase -= delta;
|
||||
}
|
||||
offset -= count;
|
||||
|
||||
// Update delay buffer
|
||||
memmove(buffer, &buffer[count], (_interpTapCount - 1) * sizeof(float));
|
||||
|
||||
// Swap if some data was generated
|
||||
base_type::_in->flush();
|
||||
return outCount;
|
||||
}
|
||||
|
||||
bool locked = false;
|
||||
bool test2 = false;
|
||||
|
||||
float syncBias = 0.0f;
|
||||
bool forceLock = false;
|
||||
|
||||
int counter = 0;
|
||||
|
||||
protected:
|
||||
void generateInterpTaps() {
|
||||
double bw = 0.5 / (double)_interpPhaseCount;
|
||||
dsp::tap<float> lp = dsp::taps::windowedSinc<float>(_interpPhaseCount * _interpTapCount, dsp::math::hzToRads(bw, 1.0), dsp::window::nuttall, _interpPhaseCount);
|
||||
interpBank = dsp::multirate::buildPolyphaseBank<float>(_interpPhaseCount, lp);
|
||||
dsp::taps::free(lp);
|
||||
}
|
||||
|
||||
dsp::multirate::PolyphaseBank<float> interpBank;
|
||||
dsp::loop::PhaseControlLoop<double, false> pcl;
|
||||
|
||||
double _omega;
|
||||
double _omegaGain;
|
||||
double _muGain;
|
||||
double _omegaRelLimit;
|
||||
int _interpPhaseCount;
|
||||
int _interpTapCount;
|
||||
|
||||
int offset = 0;
|
||||
int outCount = 0;
|
||||
float* buffer;
|
||||
float* bufStart;
|
||||
|
||||
float syncLevel = -0.03f;
|
||||
};
|
@ -10,15 +10,6 @@
|
||||
|
||||
#include <dsp/demod/quadrature.h>
|
||||
#include <dsp/sink/handler_sink.h>
|
||||
#include "linesync.h"
|
||||
#include <dsp/loop/pll.h>
|
||||
#include <dsp/convert/real_to_complex.h>
|
||||
#include <dsp/filter/fir.h>
|
||||
#include <dsp/taps/from_array.h>
|
||||
|
||||
#include "chrominance_filter.h"
|
||||
|
||||
#include "chroma_pll.h"
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
@ -26,8 +17,7 @@ SDRPP_MOD_INFO{/* Name: */ "atv_decoder",
|
||||
/* Description: */ "ATV decoder for SDR++",
|
||||
/* Author: */ "Ryzerth",
|
||||
/* Version: */ 0, 1, 0,
|
||||
/* Max instances */ -1
|
||||
};
|
||||
/* Max instances */ -1};
|
||||
|
||||
#define SAMPLE_RATE (625.0f * 720.0f * 25.0f)
|
||||
|
||||
@ -39,16 +29,9 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 8000000.0f, SAMPLE_RATE, SAMPLE_RATE, SAMPLE_RATE, true);
|
||||
|
||||
demod.init(vfo->output, SAMPLE_RATE, SAMPLE_RATE / 2.0f);
|
||||
sync.init(&demod.out, 1.0f, 1e-6, 1.0, 0.05);
|
||||
sink.init(&sync.out, handler, this);
|
||||
|
||||
r2c.init(NULL);
|
||||
chromaTaps = dsp::taps::fromArray(CHROMA_FIR_SIZE, CHROMA_FIR);
|
||||
fir.init(NULL, chromaTaps);
|
||||
pll.init(NULL, 0.01, 0.0, dsp::math::hzToRads(4433618.75, SAMPLE_RATE), dsp::math::hzToRads(4433618.75*0.90, SAMPLE_RATE), dsp::math::hzToRads(4433618.75*1.1, SAMPLE_RATE));
|
||||
sink.init(&demod.out, handler, this);
|
||||
|
||||
demod.start();
|
||||
sync.start();
|
||||
sink.start();
|
||||
|
||||
gui::menu.registerEntry(name, menuHandler, this, this);
|
||||
@ -64,13 +47,9 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
|
||||
void postInit() {}
|
||||
|
||||
void enable() {
|
||||
enabled = true;
|
||||
}
|
||||
void enable() { enabled = true; }
|
||||
|
||||
void disable() {
|
||||
enabled = false;
|
||||
}
|
||||
void disable() { enabled = false; }
|
||||
|
||||
bool isEnabled() { return enabled; }
|
||||
|
||||
@ -82,8 +61,6 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
style::beginDisabled();
|
||||
}
|
||||
|
||||
// Ideal width for testing: 750pixels
|
||||
|
||||
ImGui::FillWidth();
|
||||
_this->img.draw();
|
||||
|
||||
@ -99,28 +76,6 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
ImGui::FillWidth();
|
||||
ImGui::SliderFloat("##spanLvl", &_this->spanLvl, 0, 1.0);
|
||||
|
||||
ImGui::LeftLabel("Sync Bias");
|
||||
ImGui::FillWidth();
|
||||
ImGui::SliderFloat("##syncBias", &_this->sync.syncBias,-0.1, 0.1);
|
||||
|
||||
if (ImGui::Button("Test2")) {
|
||||
_this->sync.test2 = true;
|
||||
}
|
||||
|
||||
if (ImGui::Button("Switch frame")) {
|
||||
std::lock_guard<std::mutex> lck(_this->evenFrameMtx);
|
||||
_this->evenFrame = !_this->evenFrame;
|
||||
}
|
||||
|
||||
if (_this->sync.locked) {
|
||||
ImGui::TextColored(ImVec4(0, 1, 0, 1), "Locked");
|
||||
}
|
||||
else {
|
||||
ImGui::TextUnformatted("Not locked");
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Force Lock", &_this->sync.forceLock);
|
||||
|
||||
if (!_this->enabled) {
|
||||
style::endDisabled();
|
||||
}
|
||||
@ -129,67 +84,70 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
static void handler(float *data, int count, void *ctx) {
|
||||
ATVDecoderModule *_this = (ATVDecoderModule *)ctx;
|
||||
|
||||
// Convert line to complex
|
||||
_this->r2c.process(720, data, _this->r2c.out.writeBuf);
|
||||
|
||||
// Isolate the chroma subcarrier
|
||||
_this->fir.process(720, _this->r2c.out.writeBuf, _this->fir.out.writeBuf);
|
||||
|
||||
// Run chroma carrier through the PLL
|
||||
_this->pll.process(720, _this->fir.out.writeBuf, _this->pll.out.writeBuf, ((_this->ypos%2)==1) ^ _this->evenFrame);
|
||||
|
||||
// Render line to the image without color
|
||||
int lypos = _this->ypos - 1;
|
||||
if (lypos < 0) { lypos = 624; }
|
||||
uint32_t* lastLine = &((uint32_t *)_this->img.buffer)[(lypos < 313) ? (lypos*720*2) : ((((lypos - 313)*2)+1)*720) ];
|
||||
uint32_t* currentLine = &((uint32_t *)_this->img.buffer)[(_this->ypos < 313) ? (_this->ypos*720*2) : ((((_this->ypos - 313)*2)+1)*720) ];
|
||||
|
||||
//uint32_t* currentLine = &((uint32_t *)_this->img.buffer)[_this->ypos*720];
|
||||
|
||||
uint8_t *buf = (uint8_t *)_this->img.buffer;
|
||||
float val;
|
||||
float imval;
|
||||
int pos = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
int imval = std::clamp<float>((data[i] - _this->minLvl) * 255.0 / _this->spanLvl, 0, 255);
|
||||
// uint32_t re = std::clamp<float>((_this->pll.out.writeBuf[i].re - _this->minLvl) * 255.0 / _this->spanLvl, 0, 255);
|
||||
// uint32_t im = std::clamp<float>((_this->pll.out.writeBuf[i].im - _this->minLvl) * 255.0 / _this->spanLvl, 0, 255);
|
||||
// currentLine[i] = 0xFF000000 | (im << 8) | re;
|
||||
currentLine[i] = 0xFF000000 | (imval << 16) | (imval << 8) | imval;
|
||||
}
|
||||
|
||||
// Vertical scan logic
|
||||
_this->ypos++;
|
||||
bool rollover = _this->ypos >= 625;
|
||||
if (rollover) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lck(_this->evenFrameMtx);
|
||||
_this->evenFrame = !_this->evenFrame;
|
||||
val = data[i];
|
||||
// Sync
|
||||
if (val < _this->sync_level) {
|
||||
_this->sync_count++;
|
||||
}
|
||||
_this->ypos = 0;
|
||||
_this->img.swap();
|
||||
}
|
||||
|
||||
// Measure vsync levels
|
||||
float sync0 = 0.0f, sync1 = 0.0f;
|
||||
for (int i = 0; i < 306; i++) {
|
||||
sync0 += data[i];
|
||||
}
|
||||
for (int i = (720/2); i < ((720/2)+306); i++) {
|
||||
sync1 += data[i];
|
||||
}
|
||||
sync0 *= (1.0f/305.0f);
|
||||
sync1 *= (1.0f/305.0f);
|
||||
|
||||
// Save sync detection to history
|
||||
_this->syncHistory >>= 2;
|
||||
_this->syncHistory |= (((uint16_t)(sync1 < _this->sync_level)) << 9) | (((uint16_t)(sync0 < _this->sync_level)) << 8);
|
||||
|
||||
// Trigger vsync in case one is detected
|
||||
// TODO: Also sync with odd field
|
||||
if (!rollover && _this->syncHistory == 0b0000011111) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lck(_this->evenFrameMtx);
|
||||
_this->evenFrame = !_this->evenFrame;
|
||||
else {
|
||||
if (_this->sync_count >= 300) {
|
||||
_this->short_sync = 0;
|
||||
}
|
||||
else if (_this->sync_count >= 33) {
|
||||
if (_this->short_sync == 5) {
|
||||
_this->even_field = false;
|
||||
_this->ypos = 0;
|
||||
_this->img.swap();
|
||||
buf = (uint8_t *)_this->img.buffer;
|
||||
}
|
||||
else if (_this->short_sync == 4) {
|
||||
_this->even_field = true;
|
||||
_this->ypos = 0;
|
||||
}
|
||||
_this->xpos = 0;
|
||||
_this->short_sync = 0;
|
||||
}
|
||||
else if (_this->sync_count >= 15) {
|
||||
_this->short_sync++;
|
||||
}
|
||||
_this->sync_count = 0;
|
||||
}
|
||||
|
||||
|
||||
// Draw
|
||||
imval = std::clamp<float>((val - _this->minLvl) * 255.0 / _this->spanLvl, 0, 255);
|
||||
if (_this->even_field) {
|
||||
pos = ((720 * _this->ypos * 2) + _this->xpos) * 4;
|
||||
}
|
||||
else {
|
||||
pos = ((720 * (_this->ypos * 2 + 1)) + _this->xpos) * 4;
|
||||
}
|
||||
|
||||
buf[pos] = imval;
|
||||
buf[pos + 1] = imval;
|
||||
buf[pos + 2] = imval;
|
||||
buf[pos + 3] = imval;
|
||||
|
||||
// Image logic
|
||||
_this->xpos++;
|
||||
if (_this->xpos >= 720) {
|
||||
_this->ypos++;
|
||||
_this->xpos = 0;
|
||||
}
|
||||
if (_this->ypos >= 312) {
|
||||
_this->ypos = 0;
|
||||
_this->xpos = 0;
|
||||
_this->even_field = !_this->even_field;
|
||||
if (_this->even_field) {
|
||||
_this->img.swap();
|
||||
buf = (uint8_t *)_this->img.buffer;
|
||||
}
|
||||
}
|
||||
_this->ypos = 0;
|
||||
_this->img.swap();
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,27 +156,19 @@ class ATVDecoderModule : public ModuleManager::Instance {
|
||||
|
||||
VFOManager::VFO *vfo = NULL;
|
||||
dsp::demod::Quadrature demod;
|
||||
LineSync sync;
|
||||
dsp::sink::Handler<float> sink;
|
||||
dsp::convert::RealToComplex r2c;
|
||||
dsp::tap<dsp::complex_t> chromaTaps;
|
||||
dsp::filter::FIR<dsp::complex_t, dsp::complex_t> fir;
|
||||
dsp::loop::ChromaPLL pll;
|
||||
|
||||
int xpos = 0;
|
||||
int ypos = 0;
|
||||
bool even_field = false;
|
||||
|
||||
bool evenFrame = false;
|
||||
std::mutex evenFrameMtx;
|
||||
|
||||
float sync_level = -0.06f;
|
||||
float sync_level = -0.3f;
|
||||
int sync_count = 0;
|
||||
int short_sync = 0;
|
||||
|
||||
float minLvl = 0.0f;
|
||||
float spanLvl = 1.0f;
|
||||
|
||||
bool lockedLines = 0;
|
||||
uint16_t syncHistory = 0;
|
||||
|
||||
ImGui::ImageDisplay img;
|
||||
};
|
||||
|
||||
|
@ -214,10 +214,10 @@ private:
|
||||
|
||||
if (ImGui::Checkbox(CONCAT("Show Reference Lines##m17_showlines_", _this->name), &_this->showLines)) {
|
||||
if (_this->showLines) {
|
||||
_this->diag.lines.push_back(-1.0);
|
||||
_this->diag.lines.push_back(-1.0/3.0);
|
||||
_this->diag.lines.push_back(1.0/3.0);
|
||||
_this->diag.lines.push_back(1.0);
|
||||
_this->diag.lines.push_back(-0.75f);
|
||||
_this->diag.lines.push_back(-0.25f);
|
||||
_this->diag.lines.push_back(0.25f);
|
||||
_this->diag.lines.push_back(0.75f);
|
||||
}
|
||||
else {
|
||||
_this->diag.lines.clear();
|
||||
|
@ -57,13 +57,10 @@ public:
|
||||
if (config.conf[name].contains("brokenModulation")) {
|
||||
brokenModulation = config.conf[name]["brokenModulation"];
|
||||
}
|
||||
if (config.conf[name].contains("oqpsk")) {
|
||||
oqpsk = config.conf[name]["oqpsk"];
|
||||
}
|
||||
config.release();
|
||||
|
||||
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, INPUT_SAMPLE_RATE, INPUT_SAMPLE_RATE, INPUT_SAMPLE_RATE, INPUT_SAMPLE_RATE, true);
|
||||
demod.init(vfo->output, 72000.0f, INPUT_SAMPLE_RATE, 33, 0.6f, 0.1f, 0.005f, brokenModulation, oqpsk, 1e-6, 0.01);
|
||||
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 150000, INPUT_SAMPLE_RATE, 150000, 150000, true);
|
||||
demod.init(vfo->output, 72000.0f, INPUT_SAMPLE_RATE, 33, 0.6f, 0.1f, 0.005f, brokenModulation, 1e-6, 0.01);
|
||||
split.init(&demod.out);
|
||||
split.bindStream(&symSinkStream);
|
||||
split.bindStream(&sinkStream);
|
||||
@ -102,7 +99,6 @@ public:
|
||||
double bw = gui::waterfall.getBandwidth();
|
||||
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, std::clamp<double>(0, -bw / 2.0, bw / 2.0), 150000, INPUT_SAMPLE_RATE, 150000, 150000, true);
|
||||
|
||||
demod.setBrokenModulation(brokenModulation);
|
||||
demod.setInput(vfo->output);
|
||||
|
||||
demod.start();
|
||||
@ -155,13 +151,6 @@ private:
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox(CONCAT("OQPSK##oqpsk", _this->name), &_this->oqpsk)) {
|
||||
_this->demod.setOQPSK(_this->oqpsk);
|
||||
config.acquire();
|
||||
config.conf[_this->name]["oqpsk"] = _this->oqpsk;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (!_this->folderSelect.pathIsValid() && _this->enabled) { style::beginDisabled(); }
|
||||
|
||||
if (_this->recording) {
|
||||
@ -256,7 +245,7 @@ private:
|
||||
uint64_t dataWritten = 0;
|
||||
std::ofstream recFile;
|
||||
bool brokenModulation = false;
|
||||
bool oqpsk = false;
|
||||
|
||||
int8_t* writeBuffer;
|
||||
};
|
||||
|
||||
|
@ -11,8 +11,8 @@ namespace dsp::demod {
|
||||
public:
|
||||
Meteor() {}
|
||||
|
||||
Meteor(stream<complex_t>* in, double symbolrate, double samplerate, int rrcTapCount, double rrcBeta, double agcRate, double costasBandwidth, bool brokenModulation, bool oqpsk, double omegaGain, double muGain, double omegaRelLimit = 0.01) {
|
||||
init(in, symbolrate, samplerate, rrcTapCount, rrcBeta, agcRate, costasBandwidth, brokenModulation, oqpsk, omegaGain, muGain);
|
||||
Meteor(stream<complex_t>* in, double symbolrate, double samplerate, int rrcTapCount, double rrcBeta, double agcRate, double costasBandwidth, bool brokenModulation, double omegaGain, double muGain, double omegaRelLimit = 0.01) {
|
||||
init(in, symbolrate, samplerate, rrcTapCount, rrcBeta, agcRate, costasBandwidth, brokenModulation, omegaGain, muGain);
|
||||
}
|
||||
|
||||
~Meteor() {
|
||||
@ -21,12 +21,11 @@ namespace dsp::demod {
|
||||
taps::free(rrcTaps);
|
||||
}
|
||||
|
||||
void init(stream<complex_t>* in, double symbolrate, double samplerate, int rrcTapCount, double rrcBeta, double agcRate, double costasBandwidth, bool brokenModulation, bool oqpsk, double omegaGain, double muGain, double omegaRelLimit = 0.01) {
|
||||
void init(stream<complex_t>* in, double symbolrate, double samplerate, int rrcTapCount, double rrcBeta, double agcRate, double costasBandwidth, bool brokenModulation, double omegaGain, double muGain, double omegaRelLimit = 0.01) {
|
||||
_symbolrate = symbolrate;
|
||||
_samplerate = samplerate;
|
||||
_rrcTapCount = rrcTapCount;
|
||||
_rrcBeta = rrcBeta;
|
||||
_oqpsk = oqpsk;
|
||||
|
||||
rrcTaps = taps::rootRaisedCosine<float>(_rrcTapCount, _rrcBeta, _symbolrate, _samplerate);
|
||||
rrc.init(NULL, rrcTaps);
|
||||
@ -130,12 +129,6 @@ namespace dsp::demod {
|
||||
costas.setBrokenModulation(enabled);
|
||||
}
|
||||
|
||||
void setOQPSK(bool enabled) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
_oqpsk = enabled;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
@ -151,18 +144,6 @@ namespace dsp::demod {
|
||||
rrc.process(count, in, out);
|
||||
agc.process(count, out, out);
|
||||
costas.process(count, out, out);
|
||||
|
||||
if (_oqpsk) {
|
||||
// Single sample delay + deinterleave
|
||||
for (int i = 0; i < count; i++) {
|
||||
float tmp = out[i].im;
|
||||
out[i].im = lastI;
|
||||
lastI = tmp;
|
||||
}
|
||||
|
||||
// TODO: Additional 1/24th sample delay
|
||||
}
|
||||
|
||||
return recov.process(count, out, out);
|
||||
}
|
||||
|
||||
@ -185,8 +166,6 @@ namespace dsp::demod {
|
||||
double _samplerate;
|
||||
int _rrcTapCount;
|
||||
double _rrcBeta;
|
||||
float lastI = 0.0f;
|
||||
bool _oqpsk = false;
|
||||
|
||||
tap<float> rrcTaps;
|
||||
filter::FIR<complex_t, float> rrc;
|
||||
|
@ -1,8 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(pager_decoder)
|
||||
|
||||
file(GLOB_RECURSE SRC "src/*.cpp" "src/*.c")
|
||||
|
||||
include(${SDRPP_MODULE_CMAKE})
|
||||
|
||||
target_include_directories(pager_decoder PRIVATE "src/")
|
@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
#include <signal_path/vfo_manager.h>
|
||||
|
||||
class Decoder {
|
||||
public:
|
||||
virtual ~Decoder() {}
|
||||
virtual void showMenu() {};
|
||||
virtual void setVFO(VFOManager::VFO* vfo) = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void stop() = 0;
|
||||
};
|
@ -1,96 +0,0 @@
|
||||
#pragma once
|
||||
#include "../decoder.h"
|
||||
#include <signal_path/vfo_manager.h>
|
||||
#include <utils/optionlist.h>
|
||||
#include <gui/widgets/symbol_diagram.h>
|
||||
#include <gui/style.h>
|
||||
#include <dsp/sink/handler_sink.h>
|
||||
#include "flex.h"
|
||||
|
||||
class FLEXDecoder : public Decoder {
|
||||
dsp::stream<float> dummy1;
|
||||
dsp::stream<uint8_t> dummy2;
|
||||
public:
|
||||
FLEXDecoder(const std::string& name, VFOManager::VFO* vfo) : diag(0.6, 1600) {
|
||||
this->name = name;
|
||||
this->vfo = vfo;
|
||||
|
||||
// Define baudrate options
|
||||
baudrates.define(1600, "1600 Baud", 1600);
|
||||
baudrates.define(3200, "3200 Baud", 3200);
|
||||
baudrates.define(6400, "6400 Baud", 6400);
|
||||
|
||||
// Init DSP
|
||||
vfo->setBandwidthLimits(12500, 12500, true);
|
||||
vfo->setSampleRate(16000, 12500);
|
||||
reshape.init(&dummy1, 1600.0, (1600 / 30.0) - 1600.0);
|
||||
dataHandler.init(&dummy2, _dataHandler, this);
|
||||
diagHandler.init(&reshape.out, _diagHandler, this);
|
||||
}
|
||||
|
||||
~FLEXDecoder() {
|
||||
stop();
|
||||
}
|
||||
|
||||
void showMenu() {
|
||||
ImGui::LeftLabel("Baudrate");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo(("##pager_decoder_flex_br_" + name).c_str(), &brId, baudrates.txt)) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
ImGui::FillWidth();
|
||||
diag.draw();
|
||||
}
|
||||
|
||||
void setVFO(VFOManager::VFO* vfo) {
|
||||
this->vfo = vfo;
|
||||
vfo->setBandwidthLimits(12500, 12500, true);
|
||||
vfo->setSampleRate(24000, 12500);
|
||||
// dsp.setInput(vfo->output);
|
||||
}
|
||||
|
||||
void start() {
|
||||
flog::debug("FLEX start");
|
||||
// dsp.start();
|
||||
reshape.start();
|
||||
dataHandler.start();
|
||||
diagHandler.start();
|
||||
}
|
||||
|
||||
void stop() {
|
||||
flog::debug("FLEX stop");
|
||||
// dsp.stop();
|
||||
reshape.stop();
|
||||
dataHandler.stop();
|
||||
diagHandler.stop();
|
||||
}
|
||||
|
||||
private:
|
||||
static void _dataHandler(uint8_t* data, int count, void* ctx) {
|
||||
FLEXDecoder* _this = (FLEXDecoder*)ctx;
|
||||
// _this->decoder.process(data, count);
|
||||
}
|
||||
|
||||
static void _diagHandler(float* data, int count, void* ctx) {
|
||||
FLEXDecoder* _this = (FLEXDecoder*)ctx;
|
||||
float* buf = _this->diag.acquireBuffer();
|
||||
memcpy(buf, data, count * sizeof(float));
|
||||
_this->diag.releaseBuffer();
|
||||
}
|
||||
|
||||
std::string name;
|
||||
|
||||
VFOManager::VFO* vfo;
|
||||
dsp::buffer::Reshaper<float> reshape;
|
||||
dsp::sink::Handler<uint8_t> dataHandler;
|
||||
dsp::sink::Handler<float> diagHandler;
|
||||
|
||||
flex::Decoder decoder;
|
||||
|
||||
ImGui::SymbolDiagram diag;
|
||||
|
||||
int brId = 0;
|
||||
|
||||
OptionList<int, int> baudrates;
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
#include "flex.h"
|
||||
|
||||
namespace flex {
|
||||
// TODO
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace flex {
|
||||
class Decoder {
|
||||
public:
|
||||
// TODO
|
||||
|
||||
private:
|
||||
// TODO
|
||||
};
|
||||
}
|
@ -1,172 +0,0 @@
|
||||
#include <imgui.h>
|
||||
#include <config.h>
|
||||
#include <core.h>
|
||||
#include <gui/style.h>
|
||||
#include <gui/gui.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <module.h>
|
||||
#include <gui/widgets/folder_select.h>
|
||||
#include <utils/optionlist.h>
|
||||
#include "decoder.h"
|
||||
#include "pocsag/decoder.h"
|
||||
#include "flex/decoder.h"
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "pager_decoder",
|
||||
/* Description: */ "POCSAG and Flex Pager Decoder"
|
||||
/* Author: */ "Ryzerth",
|
||||
/* Version: */ 0, 1, 0,
|
||||
/* Max instances */ -1
|
||||
};
|
||||
|
||||
ConfigManager config;
|
||||
|
||||
enum Protocol {
|
||||
PROTOCOL_INVALID = -1,
|
||||
PROTOCOL_POCSAG,
|
||||
PROTOCOL_FLEX
|
||||
};
|
||||
|
||||
class PagerDecoderModule : public ModuleManager::Instance {
|
||||
public:
|
||||
PagerDecoderModule(std::string name) {
|
||||
this->name = name;
|
||||
|
||||
// Define protocols
|
||||
protocols.define("POCSAG", PROTOCOL_POCSAG);
|
||||
//protocols.define("FLEX", PROTOCOL_FLEX);
|
||||
|
||||
// Initialize VFO with default values
|
||||
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 12500, 24000, 12500, 12500, true);
|
||||
vfo->setSnapInterval(1);
|
||||
|
||||
// Select the protocol
|
||||
selectProtocol(PROTOCOL_POCSAG);
|
||||
|
||||
gui::menu.registerEntry(name, menuHandler, this, this);
|
||||
}
|
||||
|
||||
~PagerDecoderModule() {
|
||||
gui::menu.removeEntry(name);
|
||||
// Stop DSP
|
||||
if (enabled) {
|
||||
decoder->stop();
|
||||
decoder.reset();
|
||||
sigpath::vfoManager.deleteVFO(vfo);
|
||||
}
|
||||
|
||||
sigpath::sinkManager.unregisterStream(name);
|
||||
}
|
||||
|
||||
void postInit() {}
|
||||
|
||||
void enable() {
|
||||
double bw = gui::waterfall.getBandwidth();
|
||||
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, std::clamp<double>(0, -bw / 2.0, bw / 2.0), 12500, 24000, 12500, 12500, true);
|
||||
vfo->setSnapInterval(1);
|
||||
|
||||
decoder->setVFO(vfo);
|
||||
decoder->start();
|
||||
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
void disable() {
|
||||
decoder->stop();
|
||||
sigpath::vfoManager.deleteVFO(vfo);
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
bool isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void selectProtocol(Protocol newProto) {
|
||||
// Cannot change while disabled
|
||||
if (!enabled) { return; }
|
||||
|
||||
// If the protocol hasn't changed, no need to do anything
|
||||
if (newProto == proto) { return; }
|
||||
|
||||
// Delete current decoder
|
||||
decoder.reset();
|
||||
|
||||
// Create a new decoder
|
||||
switch (newProto) {
|
||||
case PROTOCOL_POCSAG:
|
||||
decoder = std::make_unique<POCSAGDecoder>(name, vfo);
|
||||
break;
|
||||
case PROTOCOL_FLEX:
|
||||
decoder = std::make_unique<FLEXDecoder>(name, vfo);
|
||||
break;
|
||||
default:
|
||||
flog::error("Tried to select unknown pager protocol");
|
||||
return;
|
||||
}
|
||||
|
||||
// Start the new decoder
|
||||
decoder->start();
|
||||
|
||||
// Save selected protocol
|
||||
proto = newProto;
|
||||
}
|
||||
|
||||
private:
|
||||
static void menuHandler(void* ctx) {
|
||||
PagerDecoderModule* _this = (PagerDecoderModule*)ctx;
|
||||
|
||||
float menuWidth = ImGui::GetContentRegionAvail().x;
|
||||
|
||||
if (!_this->enabled) { style::beginDisabled(); }
|
||||
|
||||
ImGui::LeftLabel("Protocol");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo(("##pager_decoder_proto_" + _this->name).c_str(), &_this->protoId, _this->protocols.txt)) {
|
||||
_this->selectProtocol(_this->protocols.value(_this->protoId));
|
||||
}
|
||||
|
||||
if (_this->decoder) { _this->decoder->showMenu(); }
|
||||
|
||||
ImGui::Button(("Record##pager_decoder_show_" + _this->name).c_str(), ImVec2(menuWidth, 0));
|
||||
ImGui::Button(("Show Messages##pager_decoder_show_" + _this->name).c_str(), ImVec2(menuWidth, 0));
|
||||
|
||||
if (!_this->enabled) { style::endDisabled(); }
|
||||
}
|
||||
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
|
||||
Protocol proto = PROTOCOL_INVALID;
|
||||
int protoId = 0;
|
||||
|
||||
OptionList<std::string, Protocol> protocols;
|
||||
|
||||
// DSP Chain
|
||||
VFOManager::VFO* vfo;
|
||||
std::unique_ptr<Decoder> decoder;
|
||||
|
||||
bool showLines = false;
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
// Create default recording directory
|
||||
json def = json({});
|
||||
config.setPath(core::args["root"].s() + "/pager_decoder_config.json");
|
||||
config.load(def);
|
||||
config.enableAutoSave();
|
||||
}
|
||||
|
||||
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
|
||||
return new PagerDecoderModule(name);
|
||||
}
|
||||
|
||||
MOD_EXPORT void _DELETE_INSTANCE_(void* instance) {
|
||||
delete (PagerDecoderModule*)instance;
|
||||
}
|
||||
|
||||
MOD_EXPORT void _END_() {
|
||||
config.disableAutoSave();
|
||||
config.save();
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
#pragma once
|
||||
#include "../decoder.h"
|
||||
#include <signal_path/vfo_manager.h>
|
||||
#include <utils/optionlist.h>
|
||||
#include <gui/widgets/symbol_diagram.h>
|
||||
#include <gui/style.h>
|
||||
#include <dsp/sink/handler_sink.h>
|
||||
#include "dsp.h"
|
||||
#include "pocsag.h"
|
||||
|
||||
class POCSAGDecoder : public Decoder {
|
||||
public:
|
||||
POCSAGDecoder(const std::string& name, VFOManager::VFO* vfo) : diag(0.6, 2400) {
|
||||
this->name = name;
|
||||
this->vfo = vfo;
|
||||
|
||||
// Default baudrate (TODO: Load from config)
|
||||
baudrate = 2400;
|
||||
|
||||
// Define baudrate options
|
||||
baudrates.define(512, "512 Baud", 512);
|
||||
baudrates.define(1200, "1200 Baud", 1200);
|
||||
baudrates.define(2400, "2400 Baud", 2400);
|
||||
|
||||
// Init DSP
|
||||
vfo->setBandwidthLimits(12500, 12500, true);
|
||||
vfo->setSampleRate(baudrate*10.0, 12500);
|
||||
dsp.init(vfo->output, baudrate*10.0, baudrate);
|
||||
reshape.init(&dsp.soft, baudrate, (baudrate / 30.0) - baudrate);
|
||||
dataHandler.init(&dsp.out, _dataHandler, this);
|
||||
diagHandler.init(&reshape.out, _diagHandler, this);
|
||||
|
||||
// Init decoder
|
||||
decoder.onMessage.bind(&POCSAGDecoder::messageHandler, this);
|
||||
}
|
||||
|
||||
~POCSAGDecoder() {
|
||||
stop();
|
||||
}
|
||||
|
||||
void showMenu() {
|
||||
ImGui::LeftLabel("Baudrate");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo(("##pager_decoder_pocsag_br_" + name).c_str(), &brId, baudrates.txt)) {
|
||||
setBaudrate(baudrates.value(brId));
|
||||
}
|
||||
|
||||
ImGui::FillWidth();
|
||||
diag.draw();
|
||||
}
|
||||
|
||||
void setVFO(VFOManager::VFO* vfo) {
|
||||
this->vfo = vfo;
|
||||
vfo->setBandwidthLimits(12500, 12500, true);
|
||||
vfo->setSampleRate(24000, 12500);
|
||||
dsp.setInput(vfo->output);
|
||||
}
|
||||
|
||||
void start() {
|
||||
dsp.start();
|
||||
reshape.start();
|
||||
dataHandler.start();
|
||||
diagHandler.start();
|
||||
}
|
||||
|
||||
void stop() {
|
||||
dsp.stop();
|
||||
reshape.stop();
|
||||
dataHandler.stop();
|
||||
diagHandler.stop();
|
||||
}
|
||||
|
||||
private:
|
||||
static void _dataHandler(uint8_t* data, int count, void* ctx) {
|
||||
POCSAGDecoder* _this = (POCSAGDecoder*)ctx;
|
||||
_this->decoder.process(data, count);
|
||||
}
|
||||
|
||||
static void _diagHandler(float* data, int count, void* ctx) {
|
||||
POCSAGDecoder* _this = (POCSAGDecoder*)ctx;
|
||||
float* buf = _this->diag.acquireBuffer();
|
||||
int maxCount = std::min<int>(count, _this->diag.getCount());
|
||||
memcpy(buf, data, maxCount * sizeof(float));
|
||||
_this->diag.releaseBuffer();
|
||||
}
|
||||
|
||||
void messageHandler(pocsag::Address addr, pocsag::MessageType type, const std::string& msg) {
|
||||
flog::debug("[{}]: '{}'", (uint32_t)addr, msg);
|
||||
}
|
||||
|
||||
void setBaudrate(double baudrate) {
|
||||
vfo->setSampleRate(baudrate*10.0, 12500);
|
||||
stop();
|
||||
reshape.setKeep(baudrate);
|
||||
reshape.setSkip((baudrate / 30.0) - baudrate);
|
||||
diag.setCount(baudrate);
|
||||
start();
|
||||
}
|
||||
|
||||
std::string name;
|
||||
VFOManager::VFO* vfo;
|
||||
|
||||
POCSAGDSP dsp;
|
||||
dsp::buffer::Reshaper<float> reshape;
|
||||
dsp::sink::Handler<uint8_t> dataHandler;
|
||||
dsp::sink::Handler<float> diagHandler;
|
||||
|
||||
pocsag::Decoder decoder;
|
||||
|
||||
ImGui::SymbolDiagram diag;
|
||||
|
||||
int brId = 2;
|
||||
double baudrate = 2400;
|
||||
|
||||
OptionList<int, int> baudrates;
|
||||
};
|
@ -1,76 +0,0 @@
|
||||
#pragma once
|
||||
#include <dsp/stream.h>
|
||||
#include <dsp/buffer/reshaper.h>
|
||||
#include <dsp/multirate/rational_resampler.h>
|
||||
#include <dsp/sink/handler_sink.h>
|
||||
#include <dsp/demod/quadrature.h>
|
||||
#include <dsp/clock_recovery/mm.h>
|
||||
#include <dsp/taps/root_raised_cosine.h>
|
||||
#include <dsp/correction/dc_blocker.h>
|
||||
#include <dsp/loop/fast_agc.h>
|
||||
#include <dsp/digital/binary_slicer.h>
|
||||
#include <dsp/routing/doubler.h>
|
||||
|
||||
class POCSAGDSP : public dsp::Processor<dsp::complex_t, uint8_t> {
|
||||
using base_type = dsp::Processor<dsp::complex_t, uint8_t>;
|
||||
public:
|
||||
POCSAGDSP() {}
|
||||
POCSAGDSP(dsp::stream<dsp::complex_t>* in, double samplerate, double baudrate) { init(in, samplerate, baudrate); }
|
||||
|
||||
void init(dsp::stream<dsp::complex_t>* in, double samplerate, double baudrate) {
|
||||
// Save settings
|
||||
_samplerate = samplerate;
|
||||
|
||||
// Configure blocks
|
||||
demod.init(NULL, -4500.0, samplerate);
|
||||
float taps[] = { 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f };
|
||||
shape = dsp::taps::fromArray<float>(10, taps);
|
||||
fir.init(NULL, shape);
|
||||
recov.init(NULL, samplerate/baudrate, 1e-4, 1.0, 0.05);
|
||||
|
||||
// Free useless buffers
|
||||
fir.out.free();
|
||||
recov.out.free();
|
||||
|
||||
// Init base
|
||||
base_type::init(in);
|
||||
}
|
||||
|
||||
int process(int count, dsp::complex_t* in, float* softOut, uint8_t* out) {
|
||||
count = demod.process(count, in, demod.out.readBuf);
|
||||
count = fir.process(count, demod.out.readBuf, demod.out.readBuf);
|
||||
count = recov.process(count, demod.out.readBuf, softOut);
|
||||
dsp::digital::BinarySlicer::process(count, softOut, out);
|
||||
return count;
|
||||
}
|
||||
|
||||
void setBaudrate(double baudrate) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
base_type::tempStop();
|
||||
|
||||
base_type::tempStart();
|
||||
}
|
||||
|
||||
int run() {
|
||||
int count = base_type::_in->read();
|
||||
if (count < 0) { return -1; }
|
||||
|
||||
count = process(count, base_type::_in->readBuf, soft.writeBuf, base_type::out.writeBuf);
|
||||
|
||||
base_type::_in->flush();
|
||||
if (!base_type::out.swap(count)) { return -1; }
|
||||
if (count) { if (!soft.swap(count)) { return -1; } }
|
||||
return count;
|
||||
}
|
||||
|
||||
dsp::stream<float> soft;
|
||||
|
||||
private:
|
||||
dsp::demod::Quadrature demod;
|
||||
dsp::tap<float> shape;
|
||||
dsp::filter::FIR<float, float> fir;
|
||||
dsp::clock_recovery::MM<float> recov;
|
||||
|
||||
double _samplerate;
|
||||
};
|
@ -1,173 +0,0 @@
|
||||
#include "pocsag.h"
|
||||
#include <string.h>
|
||||
#include <utils/flog.h>
|
||||
|
||||
#define POCSAG_FRAME_SYNC_CODEWORD ((uint32_t)(0b01111100110100100001010111011000))
|
||||
#define POCSAG_IDLE_CODEWORD_DATA ((uint32_t)(0b011110101100100111000))
|
||||
#define POCSAG_BATCH_BIT_COUNT (POCSAG_BATCH_CODEWORD_COUNT*32)
|
||||
#define POCSAG_DATA_BITS_PER_CW 20
|
||||
|
||||
#define POCSAG_GEN_POLY ((uint32_t)(0b11101101001))
|
||||
|
||||
namespace pocsag {
|
||||
const char NUMERIC_CHARSET[] = {
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'*',
|
||||
'U',
|
||||
' ',
|
||||
'-',
|
||||
']',
|
||||
'['
|
||||
};
|
||||
|
||||
Decoder::Decoder() {
|
||||
// Zero out batch
|
||||
memset(batch, 0, sizeof(batch));
|
||||
}
|
||||
|
||||
void Decoder::process(uint8_t* symbols, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
// Get symbol
|
||||
uint32_t s = symbols[i];
|
||||
|
||||
// If not sync, try to acquire sync (TODO: sync confidence)
|
||||
if (!synced) {
|
||||
// Append new symbol to sync shift register
|
||||
syncSR = (syncSR << 1) | s;
|
||||
|
||||
// Test for sync
|
||||
synced = (distance(syncSR, POCSAG_FRAME_SYNC_CODEWORD) <= POCSAG_SYNC_DIST);
|
||||
|
||||
// Go to next symbol
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: Flush message on desync
|
||||
|
||||
// Append bit to batch
|
||||
batch[batchOffset >> 5] |= (s << (31 - (batchOffset & 0b11111)));
|
||||
batchOffset++;
|
||||
|
||||
// On end of batch, decode and reset
|
||||
if (batchOffset >= POCSAG_BATCH_BIT_COUNT) {
|
||||
decodeBatch();
|
||||
batchOffset = 0;
|
||||
synced = false;
|
||||
memset(batch, 0, sizeof(batch));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Decoder::distance(uint32_t a, uint32_t b) {
|
||||
uint32_t diff = a ^ b;
|
||||
int dist = 0;
|
||||
for (int i = 0; i < 32; i++) {
|
||||
dist += (diff >> i ) & 1;
|
||||
}
|
||||
return dist;
|
||||
}
|
||||
|
||||
bool Decoder::correctCodeword(Codeword in, Codeword& out) {
|
||||
|
||||
|
||||
return true; // TODO
|
||||
}
|
||||
|
||||
void Decoder::flushMessage() {
|
||||
if (!msg.empty()) {
|
||||
// Send out message
|
||||
onMessage(addr, msgType, msg);
|
||||
|
||||
// Reset state
|
||||
msg.clear();
|
||||
currChar = 0;
|
||||
currOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void printbin(uint32_t cw) {
|
||||
for (int i = 31; i >= 0; i--) {
|
||||
printf("%c", ((cw >> i) & 1) ? '1':'0');
|
||||
}
|
||||
}
|
||||
|
||||
void bitswapChar(char in, char& out) {
|
||||
out = 0;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
out |= ((in >> (6-i)) & 1) << i;
|
||||
}
|
||||
}
|
||||
|
||||
void Decoder::decodeBatch() {
|
||||
for (int i = 0; i < POCSAG_BATCH_CODEWORD_COUNT; i++) {
|
||||
// Get codeword
|
||||
Codeword cw = batch[i];
|
||||
|
||||
// Correct errors. If corrupted, skip
|
||||
if (!correctCodeword(cw, cw)) { continue; }
|
||||
// TODO: End message if two consecutive are corrupt
|
||||
|
||||
// Get codeword type
|
||||
CodewordType type = (CodewordType)((cw >> 31) & 1);
|
||||
if (type == CODEWORD_TYPE_ADDRESS && (cw >> 11) == POCSAG_IDLE_CODEWORD_DATA) {
|
||||
type = CODEWORD_TYPE_IDLE;
|
||||
}
|
||||
|
||||
// Decode codeword
|
||||
if (type == CODEWORD_TYPE_IDLE) {
|
||||
// If a non-empty message is available, send it out and clear
|
||||
flushMessage();
|
||||
}
|
||||
else if (type == CODEWORD_TYPE_ADDRESS) {
|
||||
// If a non-empty message is available, send it out and clear
|
||||
flushMessage();
|
||||
|
||||
// Decode message type
|
||||
msgType = MESSAGE_TYPE_ALPHANUMERIC;
|
||||
// msgType = (MessageType)((cw >> 11) & 0b11);
|
||||
|
||||
// Decode address and append lower 8 bits from position
|
||||
addr = ((cw >> 13) & 0b111111111111111111) << 3;
|
||||
addr |= (i >> 1);
|
||||
}
|
||||
else if (type == CODEWORD_TYPE_MESSAGE) {
|
||||
// Extract the 20 data bits
|
||||
uint32_t data = (cw >> 11) & 0b11111111111111111111;
|
||||
|
||||
// Decode data depending on message type
|
||||
if (msgType == MESSAGE_TYPE_NUMERIC) {
|
||||
// Numeric messages pack 5 characters per message codeword
|
||||
msg += NUMERIC_CHARSET[(data >> 16) & 0b1111];
|
||||
msg += NUMERIC_CHARSET[(data >> 12) & 0b1111];
|
||||
msg += NUMERIC_CHARSET[(data >> 8) & 0b1111];
|
||||
msg += NUMERIC_CHARSET[(data >> 4) & 0b1111];
|
||||
msg += NUMERIC_CHARSET[data & 0b1111];
|
||||
}
|
||||
else if (msgType == MESSAGE_TYPE_ALPHANUMERIC) {
|
||||
// Unpack ascii bits 7 at a time (TODO: could be more efficient)
|
||||
for (int i = 19; i >= 0; i--) {
|
||||
// Append bit to char
|
||||
currChar |= ((data >> i) & 1) << (currOffset++);
|
||||
|
||||
// When the char is full, append to message
|
||||
if (currOffset >= 7) {
|
||||
// TODO: maybe replace with std::isprint
|
||||
if (currChar) { msg += currChar; }
|
||||
currChar = 0;
|
||||
currOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <utils/new_event.h>
|
||||
|
||||
#define POCSAG_SYNC_DIST 4
|
||||
#define POCSAG_BATCH_CODEWORD_COUNT 16
|
||||
|
||||
namespace pocsag {
|
||||
enum CodewordType {
|
||||
CODEWORD_TYPE_IDLE = -1,
|
||||
CODEWORD_TYPE_ADDRESS = 0,
|
||||
CODEWORD_TYPE_MESSAGE = 1
|
||||
};
|
||||
|
||||
enum MessageType {
|
||||
MESSAGE_TYPE_NUMERIC = 0b00,
|
||||
MESSAGE_TYPE_ALPHANUMERIC = 0b11
|
||||
};
|
||||
|
||||
using Codeword = uint32_t;
|
||||
using Address = uint32_t;
|
||||
|
||||
class Decoder {
|
||||
public:
|
||||
Decoder();
|
||||
|
||||
void process(uint8_t* symbols, int count);
|
||||
|
||||
NewEvent<Address, MessageType, const std::string&> onMessage;
|
||||
|
||||
private:
|
||||
static int distance(uint32_t a, uint32_t b);
|
||||
bool correctCodeword(Codeword in, Codeword& out);
|
||||
void flushMessage();
|
||||
void decodeBatch();
|
||||
|
||||
uint32_t syncSR = 0;
|
||||
bool synced = false;
|
||||
int batchOffset = 0;
|
||||
|
||||
Codeword batch[POCSAG_BATCH_CODEWORD_COUNT];
|
||||
|
||||
Address addr;
|
||||
MessageType msgType;
|
||||
std::string msg;
|
||||
|
||||
char currChar = 0;
|
||||
int currOffset = 0;
|
||||
};
|
||||
}
|
@ -19,17 +19,15 @@ namespace demod {
|
||||
|
||||
// Load config
|
||||
_config->acquire();
|
||||
bool modified = false;
|
||||
if (config->conf[name][getName()].contains("lowPass")) {
|
||||
_lowPass = config->conf[name][getName()]["lowPass"];
|
||||
}
|
||||
if (config->conf[name][getName()].contains("highPass")) {
|
||||
_highPass = config->conf[name][getName()]["highPass"];
|
||||
}
|
||||
_config->release();
|
||||
_config->release(modified);
|
||||
|
||||
|
||||
// Define structure
|
||||
demod.init(input, getIFSampleRate(), bandwidth, _lowPass, _highPass);
|
||||
demod.init(input, getIFSampleRate(), bandwidth, _lowPass);
|
||||
}
|
||||
|
||||
void start() { demod.start(); }
|
||||
@ -43,12 +41,6 @@ namespace demod {
|
||||
_config->conf[name][getName()]["lowPass"] = _lowPass;
|
||||
_config->release(true);
|
||||
}
|
||||
if (ImGui::Checkbox(("High Pass##_radio_wfm_highpass_" + name).c_str(), &_highPass)) {
|
||||
demod.setHighPass(_highPass);
|
||||
_config->acquire();
|
||||
_config->conf[name][getName()]["highPass"] = _highPass;
|
||||
_config->release(true);
|
||||
}
|
||||
}
|
||||
|
||||
void setBandwidth(double bandwidth) {
|
||||
@ -83,7 +75,6 @@ namespace demod {
|
||||
ConfigManager* _config = NULL;
|
||||
|
||||
bool _lowPass = true;
|
||||
bool _highPass = false;
|
||||
|
||||
std::string name;
|
||||
};
|
||||
|
@ -1,22 +1,22 @@
|
||||
#pragma once
|
||||
#include "../demod.h"
|
||||
#include <dsp/demod/broadcast_fm.h>
|
||||
#include "../rds_demod.h"
|
||||
#include <dsp/clock_recovery/mm.h>
|
||||
#include <dsp/clock_recovery/fd.h>
|
||||
#include <dsp/taps/root_raised_cosine.h>
|
||||
#include <dsp/digital/binary_slicer.h>
|
||||
#include <dsp/digital/manchester_decoder.h>
|
||||
#include <dsp/digital/differential_decoder.h>
|
||||
#include <gui/widgets/symbol_diagram.h>
|
||||
#include <fstream>
|
||||
#include <rds.h>
|
||||
|
||||
namespace demod {
|
||||
enum RDSRegion {
|
||||
RDS_REGION_EUROPE,
|
||||
RDS_REGION_NORTH_AMERICA
|
||||
};
|
||||
|
||||
class WFM : public Demodulator {
|
||||
public:
|
||||
WFM() : diag(0.5, 4096) {}
|
||||
WFM() {}
|
||||
|
||||
WFM(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, double audioSR) : diag(0.5, 4096) {
|
||||
WFM(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, double audioSR) {
|
||||
init(name, config, input, bandwidth, audioSR);
|
||||
}
|
||||
|
||||
@ -29,18 +29,10 @@ namespace demod {
|
||||
this->name = name;
|
||||
_config = config;
|
||||
|
||||
// Define RDS regions
|
||||
rdsRegions.define("eu", "Europe", RDS_REGION_EUROPE);
|
||||
rdsRegions.define("na", "North America", RDS_REGION_NORTH_AMERICA);
|
||||
|
||||
// Register FFT draw handler
|
||||
fftRedrawHandler.handler = fftRedraw;
|
||||
fftRedrawHandler.ctx = this;
|
||||
gui::waterfall.onFFTRedraw.bindHandler(&fftRedrawHandler);
|
||||
|
||||
// Default
|
||||
std::string rdsRegionStr = "eu";
|
||||
|
||||
// Load config
|
||||
_config->acquire();
|
||||
bool modified = false;
|
||||
@ -53,50 +45,33 @@ namespace demod {
|
||||
if (config->conf[name][getName()].contains("rds")) {
|
||||
_rds = config->conf[name][getName()]["rds"];
|
||||
}
|
||||
if (config->conf[name][getName()].contains("rdsInfo")) {
|
||||
_rdsInfo = config->conf[name][getName()]["rdsInfo"];
|
||||
}
|
||||
if (config->conf[name][getName()].contains("rdsRegion")) {
|
||||
rdsRegionStr = config->conf[name][getName()]["rdsRegion"];
|
||||
}
|
||||
_config->release(modified);
|
||||
|
||||
// Load RDS region
|
||||
if (rdsRegions.keyExists(rdsRegionStr)) {
|
||||
rdsRegionId = rdsRegions.keyId(rdsRegionStr);
|
||||
rdsRegion = rdsRegions.value(rdsRegionId);
|
||||
}
|
||||
else {
|
||||
rdsRegion = RDS_REGION_EUROPE;
|
||||
rdsRegionId = rdsRegions.valueId(rdsRegion);
|
||||
}
|
||||
|
||||
// Init DSP
|
||||
// Define structure
|
||||
demod.init(input, bandwidth / 2.0f, getIFSampleRate(), _stereo, _lowPass, _rds);
|
||||
rdsDemod.init(&demod.rdsOut, _rdsInfo);
|
||||
hs.init(&rdsDemod.out, rdsHandler, this);
|
||||
reshape.init(&rdsDemod.soft, 4096, (1187 / 30) - 4096);
|
||||
diagHandler.init(&reshape.out, _diagHandler, this);
|
||||
|
||||
// Init RDS display
|
||||
diag.lines.push_back(-0.8);
|
||||
diag.lines.push_back(0.8);
|
||||
recov.init(&demod.rdsOut, 5000.0 / 2375, omegaGain, muGain, 0.01);
|
||||
slice.init(&recov.out);
|
||||
manch.init(&slice.out);
|
||||
diff.init(&manch.out, 2);
|
||||
hs.init(&diff.out, rdsHandler, this);
|
||||
}
|
||||
|
||||
void start() {
|
||||
demod.start();
|
||||
rdsDemod.start();
|
||||
recov.start();
|
||||
slice.start();
|
||||
manch.start();
|
||||
diff.start();
|
||||
hs.start();
|
||||
reshape.start();
|
||||
diagHandler.start();
|
||||
}
|
||||
|
||||
void stop() {
|
||||
demod.stop();
|
||||
rdsDemod.stop();
|
||||
recov.stop();
|
||||
slice.stop();
|
||||
manch.stop();
|
||||
diff.stop();
|
||||
hs.stop();
|
||||
reshape.stop();
|
||||
diagHandler.stop();
|
||||
}
|
||||
|
||||
void showMenu() {
|
||||
@ -119,129 +94,14 @@ namespace demod {
|
||||
_config->release(true);
|
||||
}
|
||||
|
||||
// TODO: This might break when the entire radio module is disabled
|
||||
if (!_rds) { ImGui::BeginDisabled(); }
|
||||
if (ImGui::Checkbox(("Advanced RDS Info##_radio_wfm_rds_info_" + name).c_str(), &_rdsInfo)) {
|
||||
setAdvancedRds(_rdsInfo);
|
||||
_config->acquire();
|
||||
_config->conf[name][getName()]["rdsInfo"] = _rdsInfo;
|
||||
_config->release(true);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo(("##_radio_wfm_rds_region_" + name).c_str(), &rdsRegionId, rdsRegions.txt)) {
|
||||
rdsRegion = rdsRegions.value(rdsRegionId);
|
||||
_config->acquire();
|
||||
_config->conf[name][getName()]["rdsRegion"] = rdsRegions.key(rdsRegionId);
|
||||
_config->release(true);
|
||||
}
|
||||
if (!_rds) { ImGui::EndDisabled(); }
|
||||
|
||||
float menuWidth = ImGui::GetContentRegionAvail().x;
|
||||
|
||||
if (_rds && _rdsInfo) {
|
||||
ImGui::BeginTable(("##radio_wfm_rds_info_tbl_" + name).c_str(), 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders);
|
||||
if (rdsDecode.piCodeValid()) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("PI Code");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if (rdsRegion == RDS_REGION_NORTH_AMERICA) {
|
||||
ImGui::Text("0x%04X (%s)", rdsDecode.getPICode(), rdsDecode.getCallsign().c_str());
|
||||
}
|
||||
else {
|
||||
ImGui::Text("0x%04X", rdsDecode.getPICode());
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Country Code");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%d", rdsDecode.getCountryCode());
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Program Coverage");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%s (%d)", rds::AREA_COVERAGE_TO_STR[rdsDecode.getProgramCoverage()], rdsDecode.getProgramCoverage());
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Reference Number");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%d", rdsDecode.getProgramRefNumber());
|
||||
}
|
||||
else {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("PI Code");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if (rdsRegion == RDS_REGION_NORTH_AMERICA) {
|
||||
ImGui::TextUnformatted("0x---- (----)");
|
||||
}
|
||||
else {
|
||||
ImGui::TextUnformatted("0x----");
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Country Code");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextUnformatted("--"); // TODO: String
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Program Coverage");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextUnformatted("------- (--)");
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Reference Number");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextUnformatted("--");
|
||||
}
|
||||
|
||||
if (rdsDecode.programTypeValid()) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Program Type");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if (rdsRegion == RDS_REGION_NORTH_AMERICA) {
|
||||
ImGui::Text("%s (%d)", rds::PROGRAM_TYPE_US_TO_STR[rdsDecode.getProgramType()], rdsDecode.getProgramType());
|
||||
}
|
||||
else {
|
||||
ImGui::Text("%s (%d)", rds::PROGRAM_TYPE_EU_TO_STR[rdsDecode.getProgramType()], rdsDecode.getProgramType());
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Program Type");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextUnformatted("------- (--)"); // TODO: String
|
||||
}
|
||||
|
||||
if (rdsDecode.musicValid()) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Music");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%s", rdsDecode.getMusic() ? "Yes":"No");
|
||||
}
|
||||
else {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted("Music");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextUnformatted("---");
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
ImGui::SetNextItemWidth(menuWidth);
|
||||
diag.draw();
|
||||
}
|
||||
// if (_rds) {
|
||||
// if (rdsDecode.countryCodeValid()) { ImGui::Text("Country code: %d", rdsDecode.getCountryCode()); }
|
||||
// if (rdsDecode.programCoverageValid()) { ImGui::Text("Program coverage: %d", rdsDecode.getProgramCoverage()); }
|
||||
// if (rdsDecode.programRefNumberValid()) { ImGui::Text("Reference number: %d", rdsDecode.getProgramRefNumber()); }
|
||||
// if (rdsDecode.programTypeValid()) { ImGui::Text("Program type: %d", rdsDecode.getProgramType()); }
|
||||
// if (rdsDecode.PSNameValid()) { ImGui::Text("Program name: [%s]", rdsDecode.getPSName().c_str()); }
|
||||
// if (rdsDecode.radioTextValid()) { ImGui::Text("Radiotext: [%s]", rdsDecode.getRadioText().c_str()); }
|
||||
// }
|
||||
}
|
||||
|
||||
void setBandwidth(double bandwidth) {
|
||||
@ -279,24 +139,12 @@ namespace demod {
|
||||
demod.setStereo(_stereo);
|
||||
}
|
||||
|
||||
void setAdvancedRds(bool enabled) {
|
||||
rdsDemod.setSoftEnabled(enabled);
|
||||
_rdsInfo = enabled;
|
||||
}
|
||||
|
||||
private:
|
||||
static void rdsHandler(uint8_t* data, int count, void* ctx) {
|
||||
WFM* _this = (WFM*)ctx;
|
||||
_this->rdsDecode.process(data, count);
|
||||
}
|
||||
|
||||
static void _diagHandler(float* data, int count, void* ctx) {
|
||||
WFM* _this = (WFM*)ctx;
|
||||
float* buf = _this->diag.acquireBuffer();
|
||||
memcpy(buf, data, count * sizeof(float));
|
||||
_this->diag.releaseBuffer();
|
||||
}
|
||||
|
||||
static void fftRedraw(ImGui::WaterFall::FFTRedrawArgs args, void* ctx) {
|
||||
WFM* _this = (WFM*)ctx;
|
||||
if (!_this->_rds) { return; }
|
||||
@ -338,31 +186,23 @@ namespace demod {
|
||||
}
|
||||
|
||||
dsp::demod::BroadcastFM demod;
|
||||
RDSDemod rdsDemod;
|
||||
dsp::clock_recovery::FD recov;
|
||||
dsp::digital::BinarySlicer slice;
|
||||
dsp::digital::ManchesterDecoder manch;
|
||||
dsp::digital::DifferentialDecoder diff;
|
||||
dsp::sink::Handler<uint8_t> hs;
|
||||
EventHandler<ImGui::WaterFall::FFTRedrawArgs> fftRedrawHandler;
|
||||
|
||||
dsp::buffer::Reshaper<float> reshape;
|
||||
dsp::sink::Handler<float> diagHandler;
|
||||
ImGui::SymbolDiagram diag;
|
||||
|
||||
rds::Decoder rdsDecode;
|
||||
rds::RDSDecoder rdsDecode;
|
||||
|
||||
ConfigManager* _config = NULL;
|
||||
|
||||
bool _stereo = false;
|
||||
bool _lowPass = true;
|
||||
bool _rds = false;
|
||||
bool _rdsInfo = false;
|
||||
float muGain = 0.01;
|
||||
float omegaGain = (0.01*0.01)/4.0;
|
||||
|
||||
int rdsRegionId = 0;
|
||||
RDSRegion rdsRegion = RDS_REGION_EUROPE;
|
||||
|
||||
OptionList<std::string, RDSRegion> rdsRegions;
|
||||
|
||||
|
||||
std::string name;
|
||||
};
|
||||
}
|
@ -597,16 +597,14 @@ private:
|
||||
|
||||
static void moduleInterfaceHandler(int code, void* in, void* out, void* ctx) {
|
||||
RadioModule* _this = (RadioModule*)ctx;
|
||||
|
||||
// If no demod is selected, reject the command
|
||||
if (!_this->selectedDemod) { return; }
|
||||
if (!_this->enabled || !_this->selectedDemod) { return; }
|
||||
|
||||
// Execute commands
|
||||
if (code == RADIO_IFACE_CMD_GET_MODE && out) {
|
||||
int* _out = (int*)out;
|
||||
*_out = _this->selectedDemodID;
|
||||
}
|
||||
else if (code == RADIO_IFACE_CMD_SET_MODE && in && _this->enabled) {
|
||||
else if (code == RADIO_IFACE_CMD_SET_MODE && in) {
|
||||
int* _in = (int*)in;
|
||||
_this->selectDemodByID((DemodID)*_in);
|
||||
}
|
||||
@ -614,7 +612,7 @@ private:
|
||||
float* _out = (float*)out;
|
||||
*_out = _this->bandwidth;
|
||||
}
|
||||
else if (code == RADIO_IFACE_CMD_SET_BANDWIDTH && in && _this->enabled) {
|
||||
else if (code == RADIO_IFACE_CMD_SET_BANDWIDTH && in) {
|
||||
float* _in = (float*)in;
|
||||
if (_this->bandwidthLocked) { return; }
|
||||
_this->setBandwidth(*_in);
|
||||
@ -623,7 +621,7 @@ private:
|
||||
bool* _out = (bool*)out;
|
||||
*_out = _this->squelchEnabled;
|
||||
}
|
||||
else if (code == RADIO_IFACE_CMD_SET_SQUELCH_ENABLED && in && _this->enabled) {
|
||||
else if (code == RADIO_IFACE_CMD_SET_SQUELCH_ENABLED && in) {
|
||||
bool* _in = (bool*)in;
|
||||
_this->setSquelchEnabled(*_in);
|
||||
}
|
||||
@ -631,7 +629,7 @@ private:
|
||||
float* _out = (float*)out;
|
||||
*_out = _this->squelchLevel;
|
||||
}
|
||||
else if (code == RADIO_IFACE_CMD_SET_SQUELCH_LEVEL && in && _this->enabled) {
|
||||
else if (code == RADIO_IFACE_CMD_SET_SQUELCH_LEVEL && in) {
|
||||
float* _in = (float*)in;
|
||||
_this->setSquelchLevel(*_in);
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
#include <utils/flog.h>
|
||||
|
||||
namespace rds {
|
||||
std::map<uint16_t, BlockType> SYNDROMES = {
|
||||
{ 0b1111011000, BLOCK_TYPE_A },
|
||||
@ -22,98 +20,6 @@ namespace rds {
|
||||
{ BLOCK_TYPE_D, 0b0110110100 }
|
||||
};
|
||||
|
||||
std::map<uint16_t, const char*> THREE_LETTER_CALLS = {
|
||||
{ 0x99A5, "KBW" },
|
||||
{ 0x99A6, "KCY" },
|
||||
{ 0x9990, "KDB" },
|
||||
{ 0x99A7, "KDF" },
|
||||
{ 0x9950, "KEX" },
|
||||
{ 0x9951, "KFH" },
|
||||
{ 0x9952, "KFI" },
|
||||
{ 0x9953, "KGA" },
|
||||
{ 0x9991, "KGB" },
|
||||
{ 0x9954, "KGO" },
|
||||
{ 0x9955, "KGU" },
|
||||
{ 0x9956, "KGW" },
|
||||
{ 0x9957, "KGY" },
|
||||
{ 0x99AA, "KHQ" },
|
||||
{ 0x9958, "KID" },
|
||||
{ 0x9959, "KIT" },
|
||||
{ 0x995A, "KJR" },
|
||||
{ 0x995B, "KLO" },
|
||||
{ 0x995C, "KLZ" },
|
||||
{ 0x995D, "KMA" },
|
||||
{ 0x995E, "KMJ" },
|
||||
{ 0x995F, "KNX" },
|
||||
{ 0x9960, "KOA" },
|
||||
{ 0x99AB, "KOB" },
|
||||
{ 0x9992, "KOY" },
|
||||
{ 0x9993, "KPQ" },
|
||||
{ 0x9964, "KQV" },
|
||||
{ 0x9994, "KSD" },
|
||||
{ 0x9965, "KSL" },
|
||||
{ 0x9966, "KUJ" },
|
||||
{ 0x9995, "KUT" },
|
||||
{ 0x9967, "KVI" },
|
||||
{ 0x9968, "KWG" },
|
||||
{ 0x9996, "KXL" },
|
||||
{ 0x9997, "KXO" },
|
||||
{ 0x996B, "KYW" },
|
||||
{ 0x9999, "WBT" },
|
||||
{ 0x996D, "WBZ" },
|
||||
{ 0x996E, "WDZ" },
|
||||
{ 0x996F, "WEW" },
|
||||
{ 0x999A, "WGH" },
|
||||
{ 0x9971, "WGL" },
|
||||
{ 0x9972, "WGN" },
|
||||
{ 0x9973, "WGR" },
|
||||
{ 0x999B, "WGY" },
|
||||
{ 0x9975, "WHA" },
|
||||
{ 0x9976, "WHB" },
|
||||
{ 0x9977, "WHK" },
|
||||
{ 0x9978, "WHO" },
|
||||
{ 0x999C, "WHP" },
|
||||
{ 0x999D, "WIL" },
|
||||
{ 0x997A, "WIP" },
|
||||
{ 0x99B3, "WIS" },
|
||||
{ 0x997B, "WJR" },
|
||||
{ 0x99B4, "WJW" },
|
||||
{ 0x99B5, "WJZ" },
|
||||
{ 0x997C, "WKY" },
|
||||
{ 0x997D, "WLS" },
|
||||
{ 0x997E, "WLW" },
|
||||
{ 0x999E, "WMC" },
|
||||
{ 0x999F, "WMT" },
|
||||
{ 0x9981, "WOC" },
|
||||
{ 0x99A0, "WOI" },
|
||||
{ 0x9983, "WOL" },
|
||||
{ 0x9984, "WOR" },
|
||||
{ 0x99A1, "WOW" },
|
||||
{ 0x99B9, "WRC" },
|
||||
{ 0x99A2, "WRR" },
|
||||
{ 0x99A3, "WSB" },
|
||||
{ 0x99A4, "WSM" },
|
||||
{ 0x9988, "WWJ" },
|
||||
{ 0x9989, "WWL" }
|
||||
};
|
||||
|
||||
std::map<uint16_t, const char*> NAT_LOC_LINKED_STATIONS = {
|
||||
{ 0xB01, "NPR-1" },
|
||||
{ 0xB02, "CBC - Radio One" },
|
||||
{ 0xB03, "CBC - Radio Two" },
|
||||
{ 0xB04, "Radio-Canada - Première Chaîne" },
|
||||
{ 0xB05, "Radio-Canada - Espace Musique" },
|
||||
{ 0xB06, "CBC" },
|
||||
{ 0xB07, "CBC" },
|
||||
{ 0xB08, "CBC" },
|
||||
{ 0xB09, "CBC" },
|
||||
{ 0xB0A, "NPR-2" },
|
||||
{ 0xB0B, "NPR-3" },
|
||||
{ 0xB0C, "NPR-4" },
|
||||
{ 0xB0D, "NPR-5" },
|
||||
{ 0xB0E, "NPR-6" }
|
||||
};
|
||||
|
||||
// 9876543210
|
||||
const uint16_t LFSR_POLY = 0b0110111001;
|
||||
const uint16_t IN_POLY = 0b1100011011;
|
||||
@ -122,7 +28,7 @@ namespace rds {
|
||||
const int DATA_LEN = 16;
|
||||
const int POLY_LEN = 10;
|
||||
|
||||
void Decoder::process(uint8_t* symbols, int count) {
|
||||
void RDSDecoder::process(uint8_t* symbols, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
// Shift in the bit
|
||||
shiftReg = ((shiftReg << 1) & 0x3FFFFFF) | (symbols[i] & 1);
|
||||
@ -148,26 +54,18 @@ namespace rds {
|
||||
type = (BlockType)((lastType + 1) % _BLOCK_TYPE_COUNT);
|
||||
}
|
||||
|
||||
// Save block while correcting errors (NOT YET) <- idk why the "not yet is here", TODO: find why
|
||||
// Save block while correcting errors (NOT YET)
|
||||
blocks[type] = correctErrors(shiftReg, type, blockAvail[type]);
|
||||
|
||||
// If block type is A, decode it directly, otherwise, update continous count
|
||||
if (type == BLOCK_TYPE_A) {
|
||||
decodeBlockA();
|
||||
}
|
||||
else if (type == BLOCK_TYPE_B) { contGroup = 1; }
|
||||
// Update continous group count
|
||||
if (type == BLOCK_TYPE_A) { contGroup = 1; }
|
||||
else if (type == BLOCK_TYPE_B && lastType == BLOCK_TYPE_A) { contGroup++; }
|
||||
else if ((type == BLOCK_TYPE_C || type == BLOCK_TYPE_CP) && lastType == BLOCK_TYPE_B) { contGroup++; }
|
||||
else if (type == BLOCK_TYPE_D && (lastType == BLOCK_TYPE_C || lastType == BLOCK_TYPE_CP)) { contGroup++; }
|
||||
else {
|
||||
// If block B is available, decode it alone.
|
||||
if (contGroup == 1) {
|
||||
decodeBlockB();
|
||||
}
|
||||
contGroup = 0;
|
||||
}
|
||||
else { contGroup = 0; }
|
||||
|
||||
// If we've got an entire group, process it
|
||||
if (contGroup >= 3) {
|
||||
if (contGroup >= 4) {
|
||||
contGroup = 0;
|
||||
decodeGroup();
|
||||
}
|
||||
@ -178,7 +76,7 @@ namespace rds {
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t Decoder::calcSyndrome(uint32_t block) {
|
||||
uint16_t RDSDecoder::calcSyndrome(uint32_t block) {
|
||||
uint16_t syn = 0;
|
||||
|
||||
// Calculate the syndrome using a LFSR
|
||||
@ -197,7 +95,7 @@ namespace rds {
|
||||
return syn;
|
||||
}
|
||||
|
||||
uint32_t Decoder::correctErrors(uint32_t block, BlockType type, bool& recovered) {
|
||||
uint32_t RDSDecoder::correctErrors(uint32_t block, BlockType type, bool& recovered) {
|
||||
// Subtract the offset from block
|
||||
block ^= (uint32_t)OFFSETS[type];
|
||||
uint32_t out = block;
|
||||
@ -226,264 +124,96 @@ namespace rds {
|
||||
return out;
|
||||
}
|
||||
|
||||
void Decoder::decodeBlockA() {
|
||||
// Acquire lock
|
||||
std::lock_guard<std::mutex> lck(blockAMtx);
|
||||
void RDSDecoder::decodeGroup() {
|
||||
std::lock_guard<std::mutex> lck(groupMtx);
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
anyGroupLastUpdate = now;
|
||||
|
||||
// If it didn't decode properly return
|
||||
if (!blockAvail[BLOCK_TYPE_A]) { return; }
|
||||
// Make sure blocks A and B are available
|
||||
if (!blockAvail[BLOCK_TYPE_A] || !blockAvail[BLOCK_TYPE_B]) { return; }
|
||||
|
||||
// Decode PI code
|
||||
piCode = (blocks[BLOCK_TYPE_A] >> 10) & 0xFFFF;
|
||||
countryCode = (blocks[BLOCK_TYPE_A] >> 22) & 0xF;
|
||||
programCoverage = (AreaCoverage)((blocks[BLOCK_TYPE_A] >> 18) & 0xF);
|
||||
programRefNumber = (blocks[BLOCK_TYPE_A] >> 10) & 0xFF;
|
||||
callsign = decodeCallsign(piCode);
|
||||
|
||||
// Update timeout
|
||||
blockALastUpdate = std::chrono::high_resolution_clock::now();;
|
||||
}
|
||||
|
||||
void Decoder::decodeBlockB() {
|
||||
// Acquire lock
|
||||
std::lock_guard<std::mutex> lck(blockBMtx);
|
||||
|
||||
// If it didn't decode properly return (TODO: Make sure this is not needed)
|
||||
if (!blockAvail[BLOCK_TYPE_B]) { return; }
|
||||
|
||||
// Decode group type and version
|
||||
groupType = (blocks[BLOCK_TYPE_B] >> 22) & 0xF;
|
||||
groupVer = (GroupVersion)((blocks[BLOCK_TYPE_B] >> 21) & 1);
|
||||
uint8_t groupType = (blocks[BLOCK_TYPE_B] >> 22) & 0xF;
|
||||
GroupVersion groupVer = (GroupVersion)((blocks[BLOCK_TYPE_B] >> 21) & 1);
|
||||
|
||||
// Decode traffic program and program type
|
||||
trafficProgram = (blocks[BLOCK_TYPE_B] >> 20) & 1;
|
||||
programType = (ProgramType)((blocks[BLOCK_TYPE_B] >> 15) & 0x1F);
|
||||
|
||||
if (groupType == 0) {
|
||||
group0LastUpdate = now;
|
||||
trafficAnnouncement = (blocks[BLOCK_TYPE_B] >> 14) & 1;
|
||||
music = (blocks[BLOCK_TYPE_B] >> 13) & 1;
|
||||
uint8_t diBit = (blocks[BLOCK_TYPE_B] >> 12) & 1;
|
||||
uint8_t offset = ((blocks[BLOCK_TYPE_B] >> 10) & 0b11);
|
||||
uint8_t diOffset = 3 - offset;
|
||||
uint8_t psOffset = offset * 2;
|
||||
|
||||
// Update timeout
|
||||
blockBLastUpdate = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void Decoder::decodeGroup0() {
|
||||
// Acquire lock
|
||||
std::lock_guard<std::mutex> lck(group0Mtx);
|
||||
|
||||
// Decode Block B data
|
||||
trafficAnnouncement = (blocks[BLOCK_TYPE_B] >> 14) & 1;
|
||||
music = (blocks[BLOCK_TYPE_B] >> 13) & 1;
|
||||
uint8_t diBit = (blocks[BLOCK_TYPE_B] >> 12) & 1;
|
||||
uint8_t offset = ((blocks[BLOCK_TYPE_B] >> 10) & 0b11);
|
||||
uint8_t diOffset = 3 - offset;
|
||||
uint8_t psOffset = offset * 2;
|
||||
|
||||
// Decode Block C data
|
||||
if (groupVer == GROUP_VER_A && blockAvail[BLOCK_TYPE_C]) {
|
||||
alternateFrequency = (blocks[BLOCK_TYPE_C] >> 10) & 0xFFFF;
|
||||
}
|
||||
|
||||
// Write DI bit to the decoder identification
|
||||
decoderIdent &= ~(1 << diOffset);
|
||||
decoderIdent |= (diBit << diOffset);
|
||||
|
||||
// Write chars at offset the PSName
|
||||
if (blockAvail[BLOCK_TYPE_D]) {
|
||||
programServiceName[psOffset] = (blocks[BLOCK_TYPE_D] >> 18) & 0xFF;
|
||||
programServiceName[psOffset + 1] = (blocks[BLOCK_TYPE_D] >> 10) & 0xFF;
|
||||
}
|
||||
|
||||
// Update timeout
|
||||
group0LastUpdate = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void Decoder::decodeGroup2() {
|
||||
// Acquire lock
|
||||
std::lock_guard<std::mutex> lck(group2Mtx);
|
||||
|
||||
// Get char offset and write chars in the Radiotext
|
||||
bool nAB = (blocks[BLOCK_TYPE_B] >> 14) & 1;
|
||||
uint8_t offset = (blocks[BLOCK_TYPE_B] >> 10) & 0xF;
|
||||
|
||||
// Clear text field if the A/B flag changed
|
||||
if (nAB != rtAB) {
|
||||
radioText = " ";
|
||||
}
|
||||
rtAB = nAB;
|
||||
|
||||
// Write char at offset in Radiotext
|
||||
if (groupVer == GROUP_VER_A) {
|
||||
uint8_t rtOffset = offset * 4;
|
||||
if (blockAvail[BLOCK_TYPE_C]) {
|
||||
radioText[rtOffset] = (blocks[BLOCK_TYPE_C] >> 18) & 0xFF;
|
||||
radioText[rtOffset + 1] = (blocks[BLOCK_TYPE_C] >> 10) & 0xFF;
|
||||
if (groupVer == GROUP_VER_A && blockAvail[BLOCK_TYPE_C]) {
|
||||
alternateFrequency = (blocks[BLOCK_TYPE_C] >> 10) & 0xFFFF;
|
||||
}
|
||||
|
||||
// Write DI bit to the decoder identification
|
||||
decoderIdent &= ~(1 << diOffset);
|
||||
decoderIdent |= (diBit << diOffset);
|
||||
|
||||
// Write chars at offset the PSName
|
||||
if (blockAvail[BLOCK_TYPE_D]) {
|
||||
radioText[rtOffset + 2] = (blocks[BLOCK_TYPE_D] >> 18) & 0xFF;
|
||||
radioText[rtOffset + 3] = (blocks[BLOCK_TYPE_D] >> 10) & 0xFF;
|
||||
programServiceName[psOffset] = (blocks[BLOCK_TYPE_D] >> 18) & 0xFF;
|
||||
programServiceName[psOffset + 1] = (blocks[BLOCK_TYPE_D] >> 10) & 0xFF;
|
||||
}
|
||||
}
|
||||
else {
|
||||
uint8_t rtOffset = offset * 2;
|
||||
if (blockAvail[BLOCK_TYPE_D]) {
|
||||
radioText[rtOffset] = (blocks[BLOCK_TYPE_D] >> 18) & 0xFF;
|
||||
radioText[rtOffset + 1] = (blocks[BLOCK_TYPE_D] >> 10) & 0xFF;
|
||||
else if (groupType == 2) {
|
||||
group2LastUpdate = now;
|
||||
// Get char offset and write chars in the Radiotext
|
||||
bool nAB = (blocks[BLOCK_TYPE_B] >> 14) & 1;
|
||||
uint8_t offset = (blocks[BLOCK_TYPE_B] >> 10) & 0xF;
|
||||
|
||||
// Clear text field if the A/B flag changed
|
||||
if (nAB != rtAB) {
|
||||
radioText = " ";
|
||||
}
|
||||
}
|
||||
rtAB = nAB;
|
||||
|
||||
// Update timeout
|
||||
group2LastUpdate = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void Decoder::decodeGroup10() {
|
||||
// Acquire lock
|
||||
std::lock_guard<std::mutex> lck(group10Mtx);
|
||||
|
||||
// Check if the text needs to be cleared
|
||||
bool ab = (blocks[BLOCK_TYPE_B] >> 14) & 1;
|
||||
if (ab != ptnAB) {
|
||||
programTypeName = " ";
|
||||
}
|
||||
ptnAB = ab;
|
||||
|
||||
// Decode segment address
|
||||
bool addr = (blocks[BLOCK_TYPE_B] >> 10) & 1;
|
||||
|
||||
// Save text depending on address
|
||||
if (addr) {
|
||||
if (blockAvail[BLOCK_TYPE_C]) {
|
||||
programTypeName[4] = (blocks[BLOCK_TYPE_C] >> 18) & 0xFF;
|
||||
programTypeName[5] = (blocks[BLOCK_TYPE_C] >> 10) & 0xFF;
|
||||
}
|
||||
if (blockAvail[BLOCK_TYPE_D]) {
|
||||
programTypeName[6] = (blocks[BLOCK_TYPE_D] >> 18) & 0xFF;
|
||||
programTypeName[7] = (blocks[BLOCK_TYPE_D] >> 10) & 0xFF;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (blockAvail[BLOCK_TYPE_C]) {
|
||||
programTypeName[0] = (blocks[BLOCK_TYPE_C] >> 18) & 0xFF;
|
||||
programTypeName[1] = (blocks[BLOCK_TYPE_C] >> 10) & 0xFF;
|
||||
}
|
||||
if (blockAvail[BLOCK_TYPE_D]) {
|
||||
programTypeName[2] = (blocks[BLOCK_TYPE_D] >> 18) & 0xFF;
|
||||
programTypeName[3] = (blocks[BLOCK_TYPE_D] >> 10) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
// Update timeout
|
||||
group10LastUpdate = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void Decoder::decodeGroup() {
|
||||
// Make sure blocks B is available
|
||||
if (!blockAvail[BLOCK_TYPE_B]) { return; }
|
||||
|
||||
// Decode block B
|
||||
decodeBlockB();
|
||||
|
||||
// Decode depending on group type
|
||||
switch (groupType) {
|
||||
case 0:
|
||||
decodeGroup0();
|
||||
break;
|
||||
case 2:
|
||||
decodeGroup2();
|
||||
break;
|
||||
case 10:
|
||||
decodeGroup10();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Decoder::base26ToCall(uint16_t pi) {
|
||||
// Determin first better based on offset
|
||||
bool w = (pi >= 21672);
|
||||
std::string callsign(w ? "W" : "K");
|
||||
|
||||
// Base25 decode the rest
|
||||
std::string restStr;
|
||||
int rest = pi - (w ? 21672 : 4096);
|
||||
while (rest) {
|
||||
restStr += 'A' + (rest % 26);
|
||||
rest /= 26;
|
||||
}
|
||||
|
||||
// Pad with As
|
||||
while (restStr.size() < 3) {
|
||||
restStr += 'A';
|
||||
}
|
||||
|
||||
// Reorder chars
|
||||
for (int i = restStr.size() - 1; i >= 0; i--) {
|
||||
callsign += restStr[i];
|
||||
}
|
||||
|
||||
return callsign;
|
||||
}
|
||||
|
||||
std::string Decoder::decodeCallsign(uint16_t pi) {
|
||||
if ((pi >> 8) == 0xAF) {
|
||||
// AFXY -> XY00
|
||||
return base26ToCall((pi & 0xFF) << 8);
|
||||
}
|
||||
else if ((pi >> 12) == 0xA) {
|
||||
// AXYZ -> X0YZ
|
||||
return base26ToCall((((pi >> 8) & 0xF) << 12) | (pi & 0xFF));
|
||||
}
|
||||
else if (pi >= 0x9950 && pi <= 0x9EFF) {
|
||||
// 3 letter callsigns
|
||||
if (THREE_LETTER_CALLS.find(pi) != THREE_LETTER_CALLS.end()) {
|
||||
return THREE_LETTER_CALLS[pi];
|
||||
// Write char at offset in Radiotext
|
||||
if (groupVer == GROUP_VER_A) {
|
||||
uint8_t rtOffset = offset * 4;
|
||||
if (blockAvail[BLOCK_TYPE_C]) {
|
||||
radioText[rtOffset] = (blocks[BLOCK_TYPE_C] >> 18) & 0xFF;
|
||||
radioText[rtOffset + 1] = (blocks[BLOCK_TYPE_C] >> 10) & 0xFF;
|
||||
}
|
||||
if (blockAvail[BLOCK_TYPE_D]) {
|
||||
radioText[rtOffset + 2] = (blocks[BLOCK_TYPE_D] >> 18) & 0xFF;
|
||||
radioText[rtOffset + 3] = (blocks[BLOCK_TYPE_D] >> 10) & 0xFF;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return "Not Assigned";
|
||||
uint8_t rtOffset = offset * 2;
|
||||
if (blockAvail[BLOCK_TYPE_D]) {
|
||||
radioText[rtOffset] = (blocks[BLOCK_TYPE_D] >> 18) & 0xFF;
|
||||
radioText[rtOffset + 1] = (blocks[BLOCK_TYPE_D] >> 10) & 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pi >= 0x1000 && pi <= 0x994F) {
|
||||
// Normal encoding
|
||||
if ((pi & 0xFF) == 0 || ((pi >> 8) & 0xF) == 0) {
|
||||
return "Not Assigned";
|
||||
}
|
||||
else {
|
||||
return base26ToCall(pi);
|
||||
}
|
||||
}
|
||||
else if (pi >= 0xB000 && pi <= 0xEFFF) {
|
||||
uint16_t _pi = ((pi >> 12) << 8) | (pi & 0xFF);
|
||||
if (NAT_LOC_LINKED_STATIONS.find(_pi) != NAT_LOC_LINKED_STATIONS.end()) {
|
||||
return NAT_LOC_LINKED_STATIONS[_pi];
|
||||
}
|
||||
else {
|
||||
return "Not Assigned";
|
||||
}
|
||||
}
|
||||
else {
|
||||
return "Not Assigned";
|
||||
}
|
||||
}
|
||||
|
||||
bool Decoder::blockAValid() {
|
||||
bool RDSDecoder::anyGroupValid() {
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(now - blockALastUpdate)).count() < RDS_BLOCK_A_TIMEOUT_MS;
|
||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(now - anyGroupLastUpdate)).count() < 5000.0;
|
||||
}
|
||||
|
||||
bool Decoder::blockBValid() {
|
||||
bool RDSDecoder::group0Valid() {
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(now - blockBLastUpdate)).count() < RDS_BLOCK_B_TIMEOUT_MS;
|
||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(now - group0LastUpdate)).count() < 5000.0;
|
||||
}
|
||||
|
||||
bool Decoder::group0Valid() {
|
||||
bool RDSDecoder::group2Valid() {
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(now - group0LastUpdate)).count() < RDS_GROUP_0_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
bool Decoder::group2Valid() {
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(now - group2LastUpdate)).count() < RDS_GROUP_2_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
bool Decoder::group10Valid() {
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(now - group10LastUpdate)).count() < RDS_GROUP_10_TIMEOUT_MS;
|
||||
return (std::chrono::duration_cast<std::chrono::milliseconds>(now - group2LastUpdate)).count() < 5000.0;
|
||||
}
|
||||
}
|
@ -4,12 +4,6 @@
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
|
||||
#define RDS_BLOCK_A_TIMEOUT_MS 5000.0
|
||||
#define RDS_BLOCK_B_TIMEOUT_MS 5000.0
|
||||
#define RDS_GROUP_0_TIMEOUT_MS 5000.0
|
||||
#define RDS_GROUP_2_TIMEOUT_MS 5000.0
|
||||
#define RDS_GROUP_10_TIMEOUT_MS 5000.0
|
||||
|
||||
namespace rds {
|
||||
enum BlockType {
|
||||
BLOCK_TYPE_A,
|
||||
@ -26,42 +20,22 @@ namespace rds {
|
||||
};
|
||||
|
||||
enum AreaCoverage {
|
||||
AREA_COVERAGE_INVALID = -1,
|
||||
AREA_COVERAGE_LOCAL = 0,
|
||||
AREA_COVERAGE_INTERNATIONAL = 1,
|
||||
AREA_COVERAGE_NATIONAL = 2,
|
||||
AREA_COVERAGE_SUPRA_NATIONAL = 3,
|
||||
AREA_COVERAGE_REGIONAL1 = 4,
|
||||
AREA_COVERAGE_REGIONAL2 = 5,
|
||||
AREA_COVERAGE_REGIONAL3 = 6,
|
||||
AREA_COVERAGE_REGIONAL4 = 7,
|
||||
AREA_COVERAGE_REGIONAL5 = 8,
|
||||
AREA_COVERAGE_REGIONAL6 = 9,
|
||||
AREA_COVERAGE_REGIONAL7 = 10,
|
||||
AREA_COVERAGE_REGIONAL8 = 11,
|
||||
AREA_COVERAGE_REGIONAL9 = 12,
|
||||
AREA_COVERAGE_REGIONAL10 = 13,
|
||||
AREA_COVERAGE_REGIONAL11 = 14,
|
||||
AREA_COVERAGE_REGIONAL12 = 15
|
||||
};
|
||||
|
||||
inline const char* AREA_COVERAGE_TO_STR[] = {
|
||||
"Local",
|
||||
"International",
|
||||
"National",
|
||||
"Supra-National",
|
||||
"Regional 1",
|
||||
"Regional 2",
|
||||
"Regional 3",
|
||||
"Regional 4",
|
||||
"Regional 5",
|
||||
"Regional 6",
|
||||
"Regional 7",
|
||||
"Regional 8",
|
||||
"Regional 9",
|
||||
"Regional 10",
|
||||
"Regional 11",
|
||||
"Regional 12",
|
||||
AREA_COVERAGE_LOCAL,
|
||||
AREA_COVERAGE_INTERNATIONAL,
|
||||
AREA_COVERAGE_NATIONAL,
|
||||
AREA_COVERAGE_SUPRA_NATIONAL,
|
||||
AREA_COVERAGE_REGIONAL1,
|
||||
AREA_COVERAGE_REGIONAL2,
|
||||
AREA_COVERAGE_REGIONAL3,
|
||||
AREA_COVERAGE_REGIONAL4,
|
||||
AREA_COVERAGE_REGIONAL5,
|
||||
AREA_COVERAGE_REGIONAL6,
|
||||
AREA_COVERAGE_REGIONAL7,
|
||||
AREA_COVERAGE_REGIONAL8,
|
||||
AREA_COVERAGE_REGIONAL9,
|
||||
AREA_COVERAGE_REGIONAL10,
|
||||
AREA_COVERAGE_REGIONAL11,
|
||||
AREA_COVERAGE_REGIONAL12
|
||||
};
|
||||
|
||||
enum ProgramType {
|
||||
@ -134,76 +108,6 @@ namespace rds {
|
||||
PROGRAM_TYPE_EU_ALARM = 31
|
||||
};
|
||||
|
||||
inline const char* PROGRAM_TYPE_EU_TO_STR[] = {
|
||||
"None",
|
||||
"News",
|
||||
"Current Affairs",
|
||||
"Information",
|
||||
"Sports",
|
||||
"Education",
|
||||
"Drama",
|
||||
"Culture",
|
||||
"Science",
|
||||
"Varied",
|
||||
"Pop Music",
|
||||
"Rock Music",
|
||||
"Easy Listening Music",
|
||||
"Light Classical",
|
||||
"Serious Classical",
|
||||
"Other Music",
|
||||
"Weather",
|
||||
"Finance",
|
||||
"Children Program",
|
||||
"Social Affairs",
|
||||
"Religion",
|
||||
"Phone-in",
|
||||
"Travel",
|
||||
"Leisure",
|
||||
"Jazz Music",
|
||||
"Country Music",
|
||||
"National Music",
|
||||
"Oldies Music",
|
||||
"Folk Music",
|
||||
"Documentary",
|
||||
"Alarm Test",
|
||||
"Alarm",
|
||||
};
|
||||
|
||||
inline const char* PROGRAM_TYPE_US_TO_STR[] = {
|
||||
"None",
|
||||
"News",
|
||||
"Information",
|
||||
"Sports",
|
||||
"Talk",
|
||||
"Rock",
|
||||
"Classic Rock",
|
||||
"Adult Hits",
|
||||
"Soft Rock",
|
||||
"Top 40",
|
||||
"Country",
|
||||
"Oldies",
|
||||
"Soft",
|
||||
"Nostalgia",
|
||||
"Jazz",
|
||||
"Classical",
|
||||
"Rythm and Blues",
|
||||
"Soft Rythm and Blues",
|
||||
"Foreign Language",
|
||||
"Religious Music",
|
||||
"Religious Talk",
|
||||
"Personality",
|
||||
"Public",
|
||||
"College",
|
||||
"Unassigned",
|
||||
"Unassigned",
|
||||
"Unassigned",
|
||||
"Unassigned",
|
||||
"Unassigned",
|
||||
"Weather",
|
||||
"Emergency Test",
|
||||
"Emergency",
|
||||
};
|
||||
|
||||
enum DecoderIdentification {
|
||||
DECODER_IDENT_STEREO = (1 << 0),
|
||||
DECODER_IDENT_ARTIFICIAL_HEAD = (1 << 1),
|
||||
@ -211,49 +115,35 @@ namespace rds {
|
||||
DECODER_IDENT_VARIABLE_PTY = (1 << 0)
|
||||
};
|
||||
|
||||
class Decoder {
|
||||
class RDSDecoder {
|
||||
public:
|
||||
void process(uint8_t* symbols, int count);
|
||||
|
||||
bool piCodeValid() { std::lock_guard<std::mutex> lck(blockAMtx); return blockAValid(); }
|
||||
uint16_t getPICode() { std::lock_guard<std::mutex> lck(blockAMtx); return piCode; }
|
||||
uint8_t getCountryCode() { std::lock_guard<std::mutex> lck(blockAMtx); return countryCode; }
|
||||
uint8_t getProgramCoverage() { std::lock_guard<std::mutex> lck(blockAMtx); return programCoverage; }
|
||||
uint8_t getProgramRefNumber() { std::lock_guard<std::mutex> lck(blockAMtx); return programRefNumber; }
|
||||
std::string getCallsign() { std::lock_guard<std::mutex> lck(blockAMtx); return callsign; }
|
||||
|
||||
bool programTypeValid() { std::lock_guard<std::mutex> lck(blockBMtx); return blockBValid(); }
|
||||
ProgramType getProgramType() { std::lock_guard<std::mutex> lck(blockBMtx); return programType; }
|
||||
bool countryCodeValid() { std::lock_guard<std::mutex> lck(groupMtx); return anyGroupValid(); }
|
||||
uint8_t getCountryCode() { std::lock_guard<std::mutex> lck(groupMtx); return countryCode; }
|
||||
bool programCoverageValid() { std::lock_guard<std::mutex> lck(groupMtx); return anyGroupValid(); }
|
||||
uint8_t getProgramCoverage() { std::lock_guard<std::mutex> lck(groupMtx); return programCoverage; }
|
||||
bool programRefNumberValid() { std::lock_guard<std::mutex> lck(groupMtx); return anyGroupValid(); }
|
||||
uint8_t getProgramRefNumber() { std::lock_guard<std::mutex> lck(groupMtx); return programRefNumber; }
|
||||
bool programTypeValid() { std::lock_guard<std::mutex> lck(groupMtx); return anyGroupValid(); }
|
||||
ProgramType getProgramType() { std::lock_guard<std::mutex> lck(groupMtx); return programType; }
|
||||
|
||||
bool musicValid() { std::lock_guard<std::mutex> lck(group0Mtx); return group0Valid(); }
|
||||
bool getMusic() { std::lock_guard<std::mutex> lck(group0Mtx); return music; }
|
||||
bool PSNameValid() { std::lock_guard<std::mutex> lck(group0Mtx); return group0Valid(); }
|
||||
std::string getPSName() { std::lock_guard<std::mutex> lck(group0Mtx); return programServiceName; }
|
||||
bool musicValid() { std::lock_guard<std::mutex> lck(groupMtx); return group0Valid(); }
|
||||
bool getMusic() { std::lock_guard<std::mutex> lck(groupMtx); return music; }
|
||||
bool PSNameValid() { std::lock_guard<std::mutex> lck(groupMtx); return group0Valid(); }
|
||||
std::string getPSName() { std::lock_guard<std::mutex> lck(groupMtx); return programServiceName; }
|
||||
|
||||
bool radioTextValid() { std::lock_guard<std::mutex> lck(group2Mtx); return group2Valid(); }
|
||||
std::string getRadioText() { std::lock_guard<std::mutex> lck(group2Mtx); return radioText; }
|
||||
|
||||
bool programTypeNameValid() { std::lock_guard<std::mutex> lck(group10Mtx); return group10Valid(); }
|
||||
std::string getProgramTypeName() { std::lock_guard<std::mutex> lck(group10Mtx); return programTypeName; }
|
||||
bool radioTextValid() { std::lock_guard<std::mutex> lck(groupMtx); return group2Valid(); }
|
||||
std::string getRadioText() { std::lock_guard<std::mutex> lck(groupMtx); return radioText; }
|
||||
|
||||
private:
|
||||
static uint16_t calcSyndrome(uint32_t block);
|
||||
static uint32_t correctErrors(uint32_t block, BlockType type, bool& recovered);
|
||||
void decodeBlockA();
|
||||
void decodeBlockB();
|
||||
void decodeGroup0();
|
||||
void decodeGroup2();
|
||||
void decodeGroup10();
|
||||
void decodeGroup();
|
||||
|
||||
static std::string base26ToCall(uint16_t pi);
|
||||
static std::string decodeCallsign(uint16_t pi);
|
||||
|
||||
bool blockAValid();
|
||||
bool blockBValid();
|
||||
bool anyGroupValid();
|
||||
bool group0Valid();
|
||||
bool group2Valid();
|
||||
bool group10Valid();
|
||||
|
||||
// State machine
|
||||
uint32_t shiftReg = 0;
|
||||
@ -264,26 +154,17 @@ namespace rds {
|
||||
uint32_t blocks[_BLOCK_TYPE_COUNT];
|
||||
bool blockAvail[_BLOCK_TYPE_COUNT];
|
||||
|
||||
// Block A (All groups)
|
||||
std::mutex blockAMtx;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> blockALastUpdate{}; // 1970-01-01
|
||||
uint16_t piCode;
|
||||
// All groups
|
||||
std::mutex groupMtx;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> anyGroupLastUpdate;
|
||||
uint8_t countryCode;
|
||||
AreaCoverage programCoverage;
|
||||
uint8_t programRefNumber;
|
||||
std::string callsign;
|
||||
|
||||
// Block B (All groups)
|
||||
std::mutex blockBMtx;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> blockBLastUpdate{}; // 1970-01-01
|
||||
uint8_t groupType;
|
||||
GroupVersion groupVer;
|
||||
bool trafficProgram;
|
||||
ProgramType programType;
|
||||
|
||||
// Group type 0
|
||||
std::mutex group0Mtx;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> group0LastUpdate{}; // 1970-01-01
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> group0LastUpdate;
|
||||
bool trafficAnnouncement;
|
||||
bool music;
|
||||
uint8_t decoderIdent;
|
||||
@ -291,16 +172,9 @@ namespace rds {
|
||||
std::string programServiceName = " ";
|
||||
|
||||
// Group type 2
|
||||
std::mutex group2Mtx;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> group2LastUpdate{}; // 1970-01-01
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> group2LastUpdate;
|
||||
bool rtAB = false;
|
||||
std::string radioText = " ";
|
||||
|
||||
// Group type 10
|
||||
std::mutex group10Mtx;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> group10LastUpdate{}; // 1970-01-01
|
||||
bool ptnAB = false;
|
||||
std::string programTypeName = " ";
|
||||
|
||||
};
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
#pragma once
|
||||
#include <dsp/processor.h>
|
||||
#include <dsp/loop/fast_agc.h>
|
||||
#include <dsp/loop/costas.h>
|
||||
#include <dsp/taps/band_pass.h>
|
||||
#include <dsp/filter/fir.h>
|
||||
#include <dsp/convert/complex_to_real.h>
|
||||
#include <dsp/clock_recovery/mm.h>
|
||||
#include <dsp/digital/binary_slicer.h>
|
||||
#include <dsp/digital/differential_decoder.h>
|
||||
|
||||
class RDSDemod : public dsp::Processor<dsp::complex_t, uint8_t> {
|
||||
using base_type = dsp::Processor<dsp::complex_t, uint8_t>;
|
||||
public:
|
||||
RDSDemod() {}
|
||||
RDSDemod(dsp::stream<dsp::complex_t>* in, bool enableSoft) { init(in, enableSoft); }
|
||||
~RDSDemod() {}
|
||||
|
||||
void init(dsp::stream<dsp::complex_t>* in, bool enableSoft) {
|
||||
// Save config
|
||||
this->enableSoft = enableSoft;
|
||||
|
||||
// Initialize the DSP
|
||||
agc.init(NULL, 1.0, 1e6, 0.1);
|
||||
costas.init(NULL, 0.005f);
|
||||
taps = dsp::taps::bandPass<dsp::complex_t>(0, 2375, 100, 5000);
|
||||
fir.init(NULL, taps);
|
||||
double baudfreq = dsp::math::hzToRads(2375.0/2.0, 5000);
|
||||
costas2.init(NULL, 0.01, 0.0, baudfreq, baudfreq - (baudfreq*0.1), baudfreq + (baudfreq*0.1));
|
||||
recov.init(NULL, 5000.0 / (2375.0 / 2.0), 1e-6, 0.01, 0.01);
|
||||
diff.init(NULL, 2);
|
||||
|
||||
// Free useless buffers
|
||||
agc.out.free();
|
||||
fir.out.free();
|
||||
costas2.out.free();
|
||||
recov.out.free();
|
||||
|
||||
// Init the rest
|
||||
base_type::init(in);
|
||||
}
|
||||
|
||||
void setSoftEnabled(bool enable) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
base_type::tempStop();
|
||||
enableSoft = enable;
|
||||
base_type::tempStart();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
base_type::tempStop();
|
||||
agc.reset();
|
||||
costas.reset();
|
||||
fir.reset();
|
||||
costas2.reset();
|
||||
recov.reset();
|
||||
diff.reset();
|
||||
base_type::tempStart();
|
||||
}
|
||||
|
||||
inline int process(int count, dsp::complex_t* in, float* softOut, uint8_t* hardOut) {
|
||||
count = agc.process(count, in, costas.out.readBuf);
|
||||
count = costas.process(count, costas.out.readBuf, costas.out.writeBuf);
|
||||
count = fir.process(count, costas.out.writeBuf, costas.out.writeBuf);
|
||||
count = costas2.process(count, costas.out.writeBuf, costas.out.readBuf);
|
||||
count = dsp::convert::ComplexToReal::process(count, costas.out.readBuf, softOut);
|
||||
count = recov.process(count, softOut, softOut);
|
||||
count = dsp::digital::BinarySlicer::process(count, softOut, diff.out.readBuf);
|
||||
count = diff.process(count, diff.out.readBuf, hardOut);
|
||||
return count;
|
||||
}
|
||||
|
||||
int run() {
|
||||
int count = base_type::_in->read();
|
||||
if (count < 0) { return -1; }
|
||||
|
||||
count = process(count, base_type::_in->readBuf, soft.writeBuf, base_type::out.writeBuf);
|
||||
|
||||
base_type::_in->flush();
|
||||
if (!base_type::out.swap(count)) { return -1; }
|
||||
if (enableSoft) {
|
||||
if (!soft.swap(count)) { return -1; }
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
dsp::stream<float> soft;
|
||||
|
||||
private:
|
||||
bool enableSoft = false;
|
||||
|
||||
dsp::loop::FastAGC<dsp::complex_t> agc;
|
||||
dsp::loop::Costas<2> costas;
|
||||
dsp::tap<dsp::complex_t> taps;
|
||||
dsp::filter::FIR<dsp::complex_t, dsp::complex_t> fir;
|
||||
dsp::loop::Costas<2> costas2;
|
||||
dsp::clock_recovery::MM<float> recov;
|
||||
dsp::digital::DifferentialDecoder diff;
|
||||
};
|
@ -1,4 +0,0 @@
|
||||
FROM debian:bookworm
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
COPY do_build.sh /root
|
||||
RUN chmod +x /root/do_build.sh
|
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd /root
|
||||
|
||||
# Install dependencies and tools
|
||||
apt update
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libairspyhf-dev libairspy-dev \
|
||||
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
|
||||
libcodec2-dev autoconf libtool xxd
|
||||
|
||||
# Install SDRPlay libraries
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1
|
||||
cp x86_64/libsdrplay_api.so.3.15 /usr/lib/libsdrplay_api.so
|
||||
cp inc/* /usr/include/
|
||||
|
||||
# Install libperseus
|
||||
git clone https://github.com/Microtelecom/libperseus-sdr
|
||||
cd libperseus-sdr
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
ldconfig
|
||||
cd ..
|
||||
|
||||
cd SDRPlusPlus
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
make VERBOSE=1 -j2
|
||||
|
||||
cd ..
|
||||
sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk2-dev, librtaudio-dev, libzstd-dev'
|
@ -4,31 +4,21 @@ cd /root
|
||||
|
||||
# Install dependencies and tools
|
||||
apt update
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libairspyhf-dev libairspy-dev \
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
|
||||
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
|
||||
libcodec2-dev autoconf libtool xxd
|
||||
libcodec2-dev
|
||||
|
||||
# Install SDRPlay libraries
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1
|
||||
cp x86_64/libsdrplay_api.so.3.15 /usr/lib/libsdrplay_api.so
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1
|
||||
cp x86_64/libsdrplay_api.so.3.07 /usr/lib/libsdrplay_api.so
|
||||
cp inc/* /usr/include/
|
||||
|
||||
# Install libperseus
|
||||
git clone https://github.com/Microtelecom/libperseus-sdr
|
||||
cd libperseus-sdr
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
ldconfig
|
||||
cd ..
|
||||
|
||||
cd SDRPlusPlus
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
|
||||
make VERBOSE=1 -j2
|
||||
|
||||
cd ..
|
||||
|
@ -4,31 +4,21 @@ cd /root
|
||||
|
||||
# Install dependencies and tools
|
||||
apt update
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk1-dev libzstd-dev libairspyhf-dev libairspy-dev \
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk1-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
|
||||
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
|
||||
libcodec2-dev autoconf libtool xxd
|
||||
libcodec2-dev
|
||||
|
||||
# Install SDRPlay libraries
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1
|
||||
cp x86_64/libsdrplay_api.so.3.15 /usr/lib/libsdrplay_api.so
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1
|
||||
cp x86_64/libsdrplay_api.so.3.07 /usr/lib/libsdrplay_api.so
|
||||
cp inc/* /usr/include/
|
||||
|
||||
# Install libperseus
|
||||
git clone https://github.com/Microtelecom/libperseus-sdr
|
||||
cd libperseus-sdr
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
ldconfig
|
||||
cd ..
|
||||
|
||||
cd SDRPlusPlus
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
cmake .. -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
|
||||
make VERBOSE=1 -j2
|
||||
|
||||
cd ..
|
||||
|
@ -4,32 +4,22 @@ cd /root
|
||||
|
||||
# Install dependencies and tools
|
||||
apt update
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk-dev libzstd-dev libairspyhf-dev libairspy-dev \
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
|
||||
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
|
||||
libcodec2-dev autoconf libtool xxd
|
||||
libcodec2-dev
|
||||
|
||||
# Install SDRPlay libraries
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1
|
||||
cp x86_64/libsdrplay_api.so.3.15 /usr/lib/libsdrplay_api.so
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1
|
||||
cp x86_64/libsdrplay_api.so.3.07 /usr/lib/libsdrplay_api.so
|
||||
cp inc/* /usr/include/
|
||||
|
||||
# Install libperseus
|
||||
git clone https://github.com/Microtelecom/libperseus-sdr
|
||||
cd libperseus-sdr
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
ldconfig
|
||||
cd ..
|
||||
|
||||
cd SDRPlusPlus
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
|
||||
make VERBOSE=1 -j2
|
||||
|
||||
cd ..
|
||||
sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk-dev, librtaudio-dev, libzstd-dev'
|
||||
sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk2-dev, librtaudio-dev, libzstd-dev'
|
@ -10,15 +10,15 @@ echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://ap
|
||||
apt update
|
||||
|
||||
# Install dependencies and tools
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk1-dev libzstd-dev libairspy-dev \
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk1-dev libzstd-dev libsoapysdr-dev libairspy-dev \
|
||||
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
|
||||
libcodec2-dev libudev-dev autoconf libtool xxd
|
||||
libcodec2-dev libudev-dev
|
||||
|
||||
# Install SDRPlay libraries
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1
|
||||
cp x86_64/libsdrplay_api.so.3.15 /usr/lib/libsdrplay_api.so
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1
|
||||
cp x86_64/libsdrplay_api.so.3.07 /usr/lib/libsdrplay_api.so
|
||||
cp inc/* /usr/include/
|
||||
|
||||
# Install a more recent libusb version
|
||||
@ -41,16 +41,6 @@ make install
|
||||
ldconfig
|
||||
cd ../../
|
||||
|
||||
# Install libperseus
|
||||
git clone https://github.com/Microtelecom/libperseus-sdr
|
||||
cd libperseus-sdr
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
ldconfig
|
||||
cd ..
|
||||
|
||||
# Fix missing .pc file for codec2
|
||||
echo 'prefix=/usr/' >> /usr/share/pkgconfig/codec2.pc
|
||||
echo 'libdir=/usr/include/x86_64-linux-gnu/' >> /usr/share/pkgconfig/codec2.pc
|
||||
@ -66,9 +56,9 @@ echo 'Cflags: -I/usr/include/codec2' >> /usr/share/pkgconfig/codec2.pc
|
||||
cd SDRPlusPlus
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_OVERRIDE_STD_FILESYSTEM=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
cmake .. -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_OVERRIDE_STD_FILESYSTEM=ON -DOPT_BUILD_M17_DECODER=ON
|
||||
make VERBOSE=1 -j2
|
||||
|
||||
# Generate package
|
||||
cd ..
|
||||
sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk1-bin, librtaudio6, libzstd1'
|
||||
sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk1-dev, librtaudio-dev, libzstd-dev'
|
@ -4,32 +4,22 @@ cd /root
|
||||
|
||||
# Install dependencies and tools
|
||||
apt update
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libairspyhf-dev libairspy-dev \
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
|
||||
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
|
||||
libcodec2-dev autoconf libtool xxd
|
||||
libcodec2-dev
|
||||
|
||||
# Install SDRPlay libraries
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1
|
||||
cp x86_64/libsdrplay_api.so.3.15 /usr/lib/libsdrplay_api.so
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1
|
||||
cp x86_64/libsdrplay_api.so.3.07 /usr/lib/libsdrplay_api.so
|
||||
cp inc/* /usr/include/
|
||||
|
||||
# Install libperseus
|
||||
git clone https://github.com/Microtelecom/libperseus-sdr
|
||||
cd libperseus-sdr
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
ldconfig
|
||||
cd ..
|
||||
|
||||
cd SDRPlusPlus
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
|
||||
make VERBOSE=1 -j2
|
||||
|
||||
cd ..
|
||||
sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk2-bin, librtaudio6, libzstd1'
|
||||
sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk2-dev, librtaudio-dev, libzstd-dev'
|
@ -4,32 +4,22 @@ cd /root
|
||||
|
||||
# Install dependencies and tools
|
||||
apt update
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libairspyhf-dev libairspy-dev \
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
|
||||
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
|
||||
libcodec2-dev autoconf libtool xxd
|
||||
libcodec2-dev
|
||||
|
||||
# Install SDRPlay libraries
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1
|
||||
cp x86_64/libsdrplay_api.so.3.15 /usr/lib/libsdrplay_api.so
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.07.1
|
||||
cp x86_64/libsdrplay_api.so.3.07 /usr/lib/libsdrplay_api.so
|
||||
cp inc/* /usr/include/
|
||||
|
||||
# Install libperseus
|
||||
git clone https://github.com/Microtelecom/libperseus-sdr
|
||||
cd libperseus-sdr
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
ldconfig
|
||||
cd ..
|
||||
|
||||
cd SDRPlusPlus
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
|
||||
make VERBOSE=1 -j2
|
||||
|
||||
cd ..
|
||||
sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk2-bin, librtaudio6, libzstd1'
|
||||
sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk2-dev, librtaudio-dev, libzstd-dev'
|
@ -1,4 +0,0 @@
|
||||
FROM ubuntu:mantic
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
COPY do_build.sh /root
|
||||
RUN chmod +x /root/do_build.sh
|
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd /root
|
||||
|
||||
# Install dependencies and tools
|
||||
apt update
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk-dev libzstd-dev libairspyhf-dev libairspy-dev \
|
||||
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
|
||||
libcodec2-dev autoconf libtool xxd
|
||||
|
||||
# Install SDRPlay libraries
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1
|
||||
cp x86_64/libsdrplay_api.so.3.15 /usr/lib/libsdrplay_api.so
|
||||
cp inc/* /usr/include/
|
||||
|
||||
# Install libperseus
|
||||
git clone https://github.com/Microtelecom/libperseus-sdr
|
||||
cd libperseus-sdr
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
ldconfig
|
||||
cd ..
|
||||
|
||||
cd SDRPlusPlus
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
make VERBOSE=1 -j2
|
||||
|
||||
cd ..
|
||||
sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk-bin, librtaudio6, libzstd1'
|
@ -1,4 +0,0 @@
|
||||
FROM ubuntu:noble
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
COPY do_build.sh /root
|
||||
RUN chmod +x /root/do_build.sh
|
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd /root
|
||||
|
||||
# Install dependencies and tools
|
||||
apt update
|
||||
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk-dev libzstd-dev libairspyhf-dev libairspy-dev \
|
||||
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
|
||||
libcodec2-dev autoconf libtool xxd
|
||||
|
||||
# Install SDRPlay libraries
|
||||
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1.run
|
||||
7z x ./SDRplay_RSP_API-Linux-3.15.1
|
||||
cp x86_64/libsdrplay_api.so.3.15 /usr/lib/libsdrplay_api.so
|
||||
cp inc/* /usr/include/
|
||||
|
||||
# Install libperseus
|
||||
git clone https://github.com/Microtelecom/libperseus-sdr
|
||||
cd libperseus-sdr
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
ldconfig
|
||||
cd ..
|
||||
|
||||
cd SDRPlusPlus
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_PERSEUS_SOURCE=ON
|
||||
make VERBOSE=1 -j2
|
||||
|
||||
cd ..
|
||||
sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk-bin, librtaudio6, libzstd1'
|
@ -26,8 +26,7 @@ bundle_is_not_to_be_installed() {
|
||||
if [ "$1" = "CFNetwork" ]; then echo 1; fi
|
||||
if [ "$1" = "SystemConfiguration" ]; then echo 1; fi
|
||||
if [ "$1" = "Security" ]; then echo 1; fi
|
||||
if [ "$1" = "AppleFSCompression" ]; then echo 1; fi
|
||||
if [ "$1" = "libsdrplay_api.so.3.14" ]; then echo 1; fi
|
||||
if [ "$1" = "AppleFSCompression" ]; then echo 1; fi
|
||||
}
|
||||
|
||||
# ========================= FOR INTERNAL USE ONLY =========================
|
||||
@ -82,7 +81,7 @@ bundle_find_full_path() {
|
||||
|
||||
# Correct dep path
|
||||
echo $RPATH/$RPATH_NEXT
|
||||
return -1
|
||||
return
|
||||
done
|
||||
|
||||
# Search other common paths
|
||||
|
@ -8,7 +8,7 @@ mkdir sdrpp_debian_amd64/DEBIAN
|
||||
# Create package info
|
||||
echo Create package info
|
||||
echo Package: sdrpp >> sdrpp_debian_amd64/DEBIAN/control
|
||||
echo Version: 1.2.0$BUILD_NO >> sdrpp_debian_amd64/DEBIAN/control
|
||||
echo Version: 1.1.0$BUILD_NO >> sdrpp_debian_amd64/DEBIAN/control
|
||||
echo Maintainer: Ryzerth >> sdrpp_debian_amd64/DEBIAN/control
|
||||
echo Architecture: all >> sdrpp_debian_amd64/DEBIAN/control
|
||||
echo Description: Bloat-free SDR receiver software >> sdrpp_debian_amd64/DEBIAN/control
|
||||
|
@ -22,7 +22,7 @@ cp -R root/res/* $BUNDLE/Contents/Resources/
|
||||
bundle_create_icns root/res/icons/sdrpp.macos.png $BUNDLE/Contents/Resources/sdrpp
|
||||
|
||||
# Create the property list
|
||||
bundle_create_plist sdrpp SDR++ org.sdrpp.sdrpp 1.2.0 sdrp sdrpp sdrpp $BUNDLE/Contents/Info.plist
|
||||
bundle_create_plist sdrpp SDR++ org.sdrpp.sdrpp 1.1.0 sdrp sdrpp sdrpp $BUNDLE/Contents/Info.plist
|
||||
|
||||
# ========================= Install binaries =========================
|
||||
|
||||
@ -38,13 +38,13 @@ bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/hackrf_source/hackrf_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/hermes_source/hermes_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/limesdr_source/limesdr_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/perseus_source/perseus_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/plutosdr_source/plutosdr_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/rfspace_source/rfspace_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/rtl_sdr_source/rtl_sdr_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/rtl_tcp_source/rtl_tcp_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/sdrplay_source/sdrplay_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/sdrpp_server_source/sdrpp_server_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/soapy_source/soapy_source.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/spyserver_source/spyserver_source.dylib
|
||||
# bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/usrp_source/usrp_source.dylib
|
||||
|
||||
@ -62,7 +62,6 @@ bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/decoder_module
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/discord_integration/discord_integration.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/frequency_manager/frequency_manager.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/recorder/recorder.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/rigctl_client/rigctl_client.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/rigctl_server/rigctl_server.dylib
|
||||
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/misc_modules/scanner/scanner.dylib
|
||||
|
||||
|
@ -7,86 +7,82 @@ mkdir sdrpp_windows_x64
|
||||
cp -Recurse $root_dir/* sdrpp_windows_x64/
|
||||
|
||||
# Copy core
|
||||
cp $build_dir/Debug/* sdrpp_windows_x64/
|
||||
cp $build_dir/core/Debug/sdrpp_core.pdb sdrpp_windows_x64/
|
||||
cp $build_dir/Release/* sdrpp_windows_x64/
|
||||
cp 'C:/Program Files/PothosSDR/bin/volk.dll' sdrpp_windows_x64/
|
||||
|
||||
# Copy source modules
|
||||
cp $build_dir/source_modules/airspy_source/Debug/airspy_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/airspy_source/Release/airspy_source.dll sdrpp_windows_x64/modules/
|
||||
cp 'C:/Program Files/PothosSDR/bin/airspy.dll' sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/source_modules/airspyhf_source/Debug/airspyhf_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/airspyhf_source/Release/airspyhf_source.dll sdrpp_windows_x64/modules/
|
||||
cp 'C:/Program Files/PothosSDR/bin/airspyhf.dll' sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/source_modules/audio_source/Debug/audio_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/audio_source/Release/audio_source.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/source_modules/bladerf_source/Debug/bladerf_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/bladerf_source/Release/bladerf_source.dll sdrpp_windows_x64/modules/
|
||||
cp 'C:/Program Files/PothosSDR/bin/bladeRF.dll' sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/source_modules/file_source/Debug/file_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/file_source/Release/file_source.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/source_modules/hackrf_source/Debug/hackrf_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/hackrf_source/Release/hackrf_source.dll sdrpp_windows_x64/modules/
|
||||
cp 'C:/Program Files/PothosSDR/bin/hackrf.dll' sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/source_modules/hermes_source/Debug/hermes_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/hermes_source/Release/hermes_source.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/source_modules/limesdr_source/Debug/limesdr_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/limesdr_source/Release/limesdr_source.dll sdrpp_windows_x64/modules/
|
||||
cp 'C:/Program Files/PothosSDR/bin/LimeSuite.dll' sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/source_modules/perseus_source/Debug/perseus_source.dll sdrpp_windows_x64/modules/
|
||||
cp 'C:/Program Files/PothosSDR/bin/perseus-sdr.dll' sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/source_modules/plutosdr_source/Debug/plutosdr_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/plutosdr_source/Release/plutosdr_source.dll sdrpp_windows_x64/modules/
|
||||
cp 'C:/Program Files/PothosSDR/bin/libiio.dll' sdrpp_windows_x64/
|
||||
cp 'C:/Program Files/PothosSDR/bin/libad9361.dll' sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/source_modules/rfspace_source/Debug/rfspace_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/rfspace_source/Release/rfspace_source.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/source_modules/rtl_sdr_source/Debug/rtl_sdr_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/rtl_sdr_source/Release/rtl_sdr_source.dll sdrpp_windows_x64/modules/
|
||||
cp 'C:/Program Files/PothosSDR/bin/rtlsdr.dll' sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/source_modules/rtl_tcp_source/Debug/rtl_tcp_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/rtl_tcp_source/Release/rtl_tcp_source.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/source_modules/sdrplay_source/Debug/sdrplay_source.dll sdrpp_windows_x64/modules/ -ErrorAction SilentlyContinue
|
||||
cp $build_dir/source_modules/sdrplay_source/Release/sdrplay_source.dll sdrpp_windows_x64/modules/ -ErrorAction SilentlyContinue
|
||||
cp 'C:/Program Files/SDRplay/API/x64/sdrplay_api.dll' sdrpp_windows_x64/ -ErrorAction SilentlyContinue
|
||||
|
||||
cp $build_dir/source_modules/sdrpp_server_source/Debug/sdrpp_server_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/sdrpp_server_source/Release/sdrpp_server_source.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/source_modules/spyserver_source/Debug/spyserver_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/soapy_source/Release/soapy_source.dll sdrpp_windows_x64/modules/
|
||||
|
||||
# cp $build_dir/source_modules/usrp_source/Debug/usrp_source.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/source_modules/spyserver_source/Release/spyserver_source.dll sdrpp_windows_x64/modules/
|
||||
|
||||
# cp $build_dir/source_modules/usrp_source/Release/usrp_source.dll sdrpp_windows_x64/modules/
|
||||
|
||||
|
||||
# Copy sink modules
|
||||
cp $build_dir/sink_modules/audio_sink/Debug/audio_sink.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/sink_modules/audio_sink/Release/audio_sink.dll sdrpp_windows_x64/modules/
|
||||
cp "C:/Program Files (x86)/RtAudio/bin/rtaudio.dll" sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/sink_modules/network_sink/Debug/network_sink.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/sink_modules/network_sink/Release/network_sink.dll sdrpp_windows_x64/modules/
|
||||
|
||||
|
||||
# Copy decoder modules
|
||||
cp $build_dir/decoder_modules/m17_decoder/Debug/m17_decoder.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/decoder_modules/m17_decoder/Release/m17_decoder.dll sdrpp_windows_x64/modules/
|
||||
cp "C:/Program Files/codec2/lib/libcodec2.dll" sdrpp_windows_x64/
|
||||
|
||||
cp $build_dir/decoder_modules/meteor_demodulator/Debug/meteor_demodulator.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/decoder_modules/meteor_demodulator/Release/meteor_demodulator.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/decoder_modules/radio/Debug/radio.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/decoder_modules/radio/Release/radio.dll sdrpp_windows_x64/modules/
|
||||
|
||||
|
||||
# Copy misc modules
|
||||
cp $build_dir/misc_modules/discord_integration/Debug/discord_integration.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/misc_modules/discord_integration/Release/discord_integration.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/misc_modules/frequency_manager/Debug/frequency_manager.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/misc_modules/frequency_manager/Release/frequency_manager.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/misc_modules/iq_exporter/Debug/iq_exporter.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/misc_modules/recorder/Release/recorder.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/misc_modules/recorder/Debug/recorder.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/misc_modules/rigctl_client/Release/rigctl_client.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/misc_modules/rigctl_client/Debug/rigctl_client.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/misc_modules/rigctl_server/Release/rigctl_server.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/misc_modules/rigctl_server/Debug/rigctl_server.dll sdrpp_windows_x64/modules/
|
||||
|
||||
cp $build_dir/misc_modules/scanner/Debug/scanner.dll sdrpp_windows_x64/modules/
|
||||
cp $build_dir/misc_modules/scanner/Release/scanner.dll sdrpp_windows_x64/modules/
|
||||
|
||||
|
||||
# Copy supporting libs
|
||||
|
@ -1,12 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <mutex>
|
||||
|
||||
std::recursive_mutex mtx;
|
||||
|
||||
int main() {
|
||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||
|
||||
printf("Works just fine!\n");
|
||||
|
||||
return 0;
|
||||
}
|
@ -485,7 +485,7 @@ private:
|
||||
}
|
||||
|
||||
// Bookmark list
|
||||
if (ImGui::BeginTable(("freq_manager_bkm_table" + _this->name).c_str(), 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 200.0f * style::uiScale))) {
|
||||
if (ImGui::BeginTable(("freq_manager_bkm_table" + _this->name).c_str(), 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 200))) {
|
||||
ImGui::TableSetupColumn("Name");
|
||||
ImGui::TableSetupColumn("Bookmark");
|
||||
ImGui::TableSetupScrollFreeze(2, 1);
|
||||
@ -531,7 +531,7 @@ private:
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
if (ImGui::Button(("Import##_freq_mgr_imp_" + _this->name).c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0)) && !_this->importOpen) {
|
||||
_this->importOpen = true;
|
||||
_this->importDialog = new pfd::open_file("Import bookmarks", "", { "JSON Files (*.json)", "*.json", "All Files", "*" }, pfd::opt::multiselect);
|
||||
_this->importDialog = new pfd::open_file("Import bookmarks", "", { "JSON Files (*.json)", "*.json", "All Files", "*" }, true);
|
||||
}
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
@ -544,7 +544,7 @@ private:
|
||||
}
|
||||
config.release();
|
||||
_this->exportOpen = true;
|
||||
_this->exportDialog = new pfd::save_file("Export bookmarks", "", { "JSON Files (*.json)", "*.json", "All Files", "*" });
|
||||
_this->exportDialog = new pfd::save_file("Export bookmarks", "", { "JSON Files (*.json)", "*.json", "All Files", "*" }, true);
|
||||
}
|
||||
if (selectedNames.size() == 0 && _this->selectedListName != "") { style::endDisabled(); }
|
||||
ImGui::EndTable();
|
||||
@ -787,7 +787,7 @@ private:
|
||||
|
||||
void exportBookmarks(std::string path) {
|
||||
std::ofstream fs(path);
|
||||
fs << exportedBookmarks;
|
||||
exportedBookmarks >> fs;
|
||||
fs.close();
|
||||
}
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(iq_exporter)
|
||||
|
||||
file(GLOB SRC "src/*.cpp")
|
||||
|
||||
include(${SDRPP_MODULE_CMAKE})
|
@ -1,590 +0,0 @@
|
||||
#include <utils/net.h>
|
||||
#include <imgui.h>
|
||||
#include <module.h>
|
||||
#include <gui/gui.h>
|
||||
#include <gui/style.h>
|
||||
#include <utils/optionlist.h>
|
||||
#include <algorithm>
|
||||
#include <dsp/sink/handler_sink.h>
|
||||
#include <volk/volk.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
#include <dsp/buffer/reshaper.h>
|
||||
#include <gui/dialogs/dialog_box.h>
|
||||
#include <core.h>
|
||||
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "iq_exporter",
|
||||
/* Description: */ "Export raw IQ through TCP or UDP",
|
||||
/* Author: */ "Ryzerth",
|
||||
/* Version: */ 0, 1, 0,
|
||||
/* Max instances */ -1
|
||||
};
|
||||
|
||||
ConfigManager config;
|
||||
|
||||
enum Mode {
|
||||
MODE_NONE = -1,
|
||||
MODE_BASEBAND,
|
||||
MODE_VFO
|
||||
};
|
||||
|
||||
enum Protocol {
|
||||
PROTOCOL_TCP_SERVER,
|
||||
PROTOCOL_TCP_CLIENT,
|
||||
PROTOCOL_UDP
|
||||
};
|
||||
|
||||
enum SampleType {
|
||||
SAMPLE_TYPE_INT8,
|
||||
SAMPLE_TYPE_INT16,
|
||||
SAMPLE_TYPE_INT32,
|
||||
SAMPLE_TYPE_FLOAT32
|
||||
};
|
||||
|
||||
class IQExporterModule : public ModuleManager::Instance {
|
||||
public:
|
||||
IQExporterModule(std::string name) {
|
||||
this->name = name;
|
||||
|
||||
// Define operating modes
|
||||
modes.define("Baseband", MODE_BASEBAND);
|
||||
modes.define("VFO", MODE_VFO);
|
||||
|
||||
// Define VFO samplerates
|
||||
for (int i = 3000; i <= 192000; i <<= 1) {
|
||||
samplerates.define(i, getSrScaled(i), i);
|
||||
}
|
||||
for (int i = 250000; i < 1000000; i += 250000) {
|
||||
samplerates.define(i, getSrScaled(i), i);
|
||||
}
|
||||
for (int i = 1000000; i < 10000000; i += 500000) {
|
||||
samplerates.define(i, getSrScaled(i), i);
|
||||
}
|
||||
for (int i = 10000000; i <= 100000000; i += 5000000) {
|
||||
samplerates.define(i, getSrScaled(i), i);
|
||||
}
|
||||
|
||||
// Define protocols
|
||||
protocols.define("TCP (Server)", PROTOCOL_TCP_SERVER);
|
||||
protocols.define("TCP (Client)", PROTOCOL_TCP_CLIENT);
|
||||
protocols.define("UDP", PROTOCOL_UDP);
|
||||
|
||||
// Define sample types
|
||||
sampleTypes.define("Int8", SAMPLE_TYPE_INT8);
|
||||
sampleTypes.define("Int16", SAMPLE_TYPE_INT16);
|
||||
sampleTypes.define("Int32", SAMPLE_TYPE_INT32);
|
||||
sampleTypes.define("Float32", SAMPLE_TYPE_FLOAT32);
|
||||
|
||||
// Define packet sizes
|
||||
for (int i = 8; i <= 32768; i <<= 1) {
|
||||
char buf[16];
|
||||
sprintf(buf, "%d Bytes", i);
|
||||
packetSizes.define(i, buf, i);
|
||||
}
|
||||
|
||||
// Load config
|
||||
bool autoStart = false;
|
||||
Mode nMode = MODE_BASEBAND;
|
||||
config.acquire();
|
||||
if (config.conf[name].contains("mode")) {
|
||||
std::string modeStr = config.conf[name]["mode"];
|
||||
if (modes.keyExists(modeStr)) { nMode = modes.value(modes.keyId(modeStr)); }
|
||||
}
|
||||
if (config.conf[name].contains("samplerate")) {
|
||||
int sr = config.conf[name]["samplerate"];
|
||||
if (samplerates.keyExists(sr)) { samplerate = samplerates.value(samplerates.keyId(sr)); }
|
||||
}
|
||||
if (config.conf[name].contains("protocol")) {
|
||||
std::string protoStr = config.conf[name]["protocol"];
|
||||
if (protocols.keyExists(protoStr)) { proto = protocols.value(protocols.keyId(protoStr)); }
|
||||
}
|
||||
if (config.conf[name].contains("sampleType")) {
|
||||
std::string sampTypeStr = config.conf[name]["sampleType"];
|
||||
if (sampleTypes.keyExists(sampTypeStr)) { sampType = sampleTypes.value(sampleTypes.keyId(sampTypeStr)); }
|
||||
}
|
||||
if (config.conf[name].contains("packetSize")) {
|
||||
int size = config.conf[name]["packetSize"];
|
||||
if (packetSizes.keyExists(size)) { packetSize = packetSizes.value(packetSizes.keyId(size)); }
|
||||
}
|
||||
if (config.conf[name].contains("host")) {
|
||||
std::string hostStr = config.conf[name]["host"];
|
||||
strcpy(hostname, hostStr.c_str());
|
||||
}
|
||||
if (config.conf[name].contains("port")) {
|
||||
port = config.conf[name]["port"];
|
||||
port = std::clamp<int>(port, 1, 65535);
|
||||
}
|
||||
if (config.conf[name].contains("running")) {
|
||||
autoStart = config.conf[name]["running"];
|
||||
}
|
||||
config.release();
|
||||
|
||||
// Set menu IDs
|
||||
modeId = modes.valueId(nMode);
|
||||
srId = samplerates.valueId(samplerate);
|
||||
protoId = protocols.valueId(proto);
|
||||
sampTypeId = sampleTypes.valueId(sampType);
|
||||
packetSizeId = packetSizes.valueId(packetSize);
|
||||
|
||||
// Allocate buffer
|
||||
buffer = dsp::buffer::alloc<uint8_t>(STREAM_BUFFER_SIZE * sizeof(dsp::complex_t));
|
||||
|
||||
// Init DSP
|
||||
reshape.init(&iqStream, packetSize/sampleSize(), 0);
|
||||
handler.init(&reshape.out, dataHandler, this);
|
||||
|
||||
// Set operating mode
|
||||
setMode(nMode);
|
||||
|
||||
// Start if needed
|
||||
if (autoStart) { start(); }
|
||||
|
||||
// Register menu entry
|
||||
gui::menu.registerEntry(name, menuHandler, this, this);
|
||||
}
|
||||
|
||||
~IQExporterModule() {
|
||||
// Un-register menu entry
|
||||
gui::menu.removeEntry(name);
|
||||
|
||||
// Stop networking
|
||||
stop();
|
||||
|
||||
// Stop DSP
|
||||
setMode(MODE_NONE);
|
||||
|
||||
// Free buffer
|
||||
dsp::buffer::free(buffer);
|
||||
}
|
||||
|
||||
void postInit() {}
|
||||
|
||||
void enable() {
|
||||
// Rebind streams and start DSP
|
||||
setMode(mode, true);
|
||||
|
||||
// Restart networking if it was running
|
||||
if (wasRunning) { start(); }
|
||||
|
||||
// Mark as running
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
void disable() {
|
||||
// Save running state
|
||||
wasRunning = running;
|
||||
|
||||
// Stop networking
|
||||
stop();
|
||||
|
||||
// Stop the DSP and unbind streams
|
||||
setMode(MODE_NONE);
|
||||
|
||||
// Mark as disabled
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
bool isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void start() {
|
||||
if (running) { return; }
|
||||
|
||||
// Acquire lock on the socket
|
||||
std::lock_guard lck1(sockMtx);
|
||||
|
||||
// Start listening or open UDP socket
|
||||
try {
|
||||
if (proto == PROTOCOL_TCP_SERVER) {
|
||||
// Create listener
|
||||
listener = net::listen(hostname, port);
|
||||
|
||||
// Start listen worker
|
||||
listenWorkerThread = std::thread(&IQExporterModule::listenWorker, this);
|
||||
}
|
||||
else if (proto == PROTOCOL_TCP_CLIENT) {
|
||||
// Connect to TCP server
|
||||
sock = net::connect(hostname, port);
|
||||
}
|
||||
else {
|
||||
// Open UDP socket
|
||||
sock = net::openudp(hostname, port, "0.0.0.0", 0, true);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
flog::error("[IQExporter] Could not start socket: {}", e.what());
|
||||
errorStr = e.what();
|
||||
showError = true;
|
||||
return;
|
||||
}
|
||||
|
||||
running = true;
|
||||
}
|
||||
|
||||
void stop() {
|
||||
if (!running) { return; }
|
||||
|
||||
// Acquire lock on the socket
|
||||
std::lock_guard lck1(sockMtx);
|
||||
|
||||
// Stop listening or close UDP socket
|
||||
if (proto == PROTOCOL_TCP_SERVER) {
|
||||
// Stop listener
|
||||
if (listener) {
|
||||
listener->stop();
|
||||
}
|
||||
|
||||
// Wait for worker to stop
|
||||
if (listenWorkerThread.joinable()) { listenWorkerThread.join(); }
|
||||
|
||||
// Free listener
|
||||
listener.reset();
|
||||
|
||||
// Close socket and free it
|
||||
if (sock) {
|
||||
sock->close();
|
||||
sock.reset();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Close socket and free it
|
||||
if (sock) {
|
||||
sock->close();
|
||||
sock.reset();
|
||||
}
|
||||
}
|
||||
|
||||
running = false;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string getSrScaled(double sr) {
|
||||
char buf[1024];
|
||||
if (sr >= 1000000.0) {
|
||||
sprintf(buf, "%.1lf MS/s", sr / 1000000.0);
|
||||
}
|
||||
else if (sr >= 1000.0) {
|
||||
sprintf(buf, "%.1lf KS/s", sr / 1000.0);
|
||||
}
|
||||
else {
|
||||
sprintf(buf, "%.1lf S/s", sr);
|
||||
}
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
static void menuHandler(void* ctx) {
|
||||
IQExporterModule* _this = (IQExporterModule*)ctx;
|
||||
float menuWidth = ImGui::GetContentRegionAvail().x;
|
||||
|
||||
// Error message box
|
||||
ImGui::GenericDialog("##iq_exporter_err_", _this->showError, GENERIC_DIALOG_BUTTONS_OK, [=](){
|
||||
ImGui::Text("Error: %s", _this->errorStr.c_str());
|
||||
});
|
||||
|
||||
if (!_this->enabled) { ImGui::BeginDisabled(); }
|
||||
|
||||
if (_this->running) { ImGui::BeginDisabled(); }
|
||||
|
||||
// Mode selector
|
||||
ImGui::LeftLabel("Mode");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo(("##iq_exporter_mode_" + _this->name).c_str(), &_this->modeId, _this->modes.txt)) {
|
||||
_this->setMode(_this->modes.value(_this->modeId));
|
||||
config.acquire();
|
||||
config.conf[_this->name]["mode"] = _this->modes.key(_this->modeId);
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
// In VFO mode, show samplerate selector
|
||||
if (_this->mode == MODE_VFO) {
|
||||
ImGui::LeftLabel("Samplerate");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo(("##iq_exporter_sr_" + _this->name).c_str(), &_this->srId, _this->samplerates.txt)) {
|
||||
_this->samplerate = _this->samplerates.value(_this->srId);
|
||||
if (_this->vfo) {
|
||||
_this->vfo->setBandwidthLimits(_this->samplerate, _this->samplerate, true);
|
||||
_this->vfo->setSampleRate(_this->samplerate, _this->samplerate);
|
||||
}
|
||||
config.acquire();
|
||||
config.conf[_this->name]["samplerate"] = _this->samplerates.key(_this->srId);
|
||||
config.release(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Mode protocol selector
|
||||
ImGui::LeftLabel("Protocol");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo(("##iq_exporter_proto_" + _this->name).c_str(), &_this->protoId, _this->protocols.txt)) {
|
||||
_this->proto = _this->protocols.value(_this->protoId);
|
||||
config.acquire();
|
||||
config.conf[_this->name]["protocol"] = _this->protocols.key(_this->protoId);
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
// Sample type selector
|
||||
ImGui::LeftLabel("Sample type");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo(("##iq_exporter_samp_" + _this->name).c_str(), &_this->sampTypeId, _this->sampleTypes.txt)) {
|
||||
_this->sampType = _this->sampleTypes.value(_this->sampTypeId);
|
||||
_this->reshape.setKeep(_this->packetSize/_this->sampleSize());
|
||||
config.acquire();
|
||||
config.conf[_this->name]["sampleType"] = _this->sampleTypes.key(_this->sampTypeId);
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
// Packet size selector
|
||||
ImGui::LeftLabel("Packet size");
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::Combo(("##iq_exporter_pkt_sz_" + _this->name).c_str(), &_this->packetSizeId, _this->packetSizes.txt)) {
|
||||
_this->packetSize = _this->packetSizes.value(_this->packetSizeId);
|
||||
_this->reshape.setKeep(_this->packetSize/_this->sampleSize());
|
||||
config.acquire();
|
||||
config.conf[_this->name]["packetSize"] = _this->packetSizes.key(_this->packetSizeId);
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
// Hostname and port field
|
||||
if (ImGui::InputText(("##iq_exporter_host_" + _this->name).c_str(), _this->hostname, sizeof(_this->hostname))) {
|
||||
config.acquire();
|
||||
config.conf[_this->name]["host"] = _this->hostname;
|
||||
config.release(true);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::FillWidth();
|
||||
if (ImGui::InputInt(("##iq_exporter_port_" + _this->name).c_str(), &_this->port, 0, 0)) {
|
||||
_this->port = std::clamp<int>(_this->port, 1, 65535);
|
||||
config.acquire();
|
||||
config.conf[_this->name]["port"] = _this->port;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (_this->running) { ImGui::EndDisabled(); }
|
||||
|
||||
// Start/Stop buttons
|
||||
if (_this->running || (!_this->enabled && _this->wasRunning)) {
|
||||
if (ImGui::Button(("Stop##iq_exporter_stop_" + _this->name).c_str(), ImVec2(menuWidth, 0))) {
|
||||
_this->stop();
|
||||
config.acquire();
|
||||
config.conf[_this->name]["running"] = false;
|
||||
config.release(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ImGui::Button(("Start##iq_exporter_start_" + _this->name).c_str(), ImVec2(menuWidth, 0))) {
|
||||
_this->start();
|
||||
config.acquire();
|
||||
config.conf[_this->name]["running"] = true;
|
||||
config.release(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the socket is open by attempting a read
|
||||
bool sockOpen;
|
||||
{
|
||||
uint8_t dummy;
|
||||
sockOpen = !(!_this->sock || !_this->sock->isOpen() || (_this->proto != PROTOCOL_UDP && _this->sock->recv(&dummy, 1, false, net::NONBLOCKING) == 0));
|
||||
}
|
||||
|
||||
// Status text
|
||||
ImGui::TextUnformatted("Status:");
|
||||
ImGui::SameLine();
|
||||
if (sockOpen) {
|
||||
ImGui::TextColored(ImVec4(0.0, 1.0, 0.0, 1.0), (_this->proto == PROTOCOL_TCP_SERVER || _this->proto == PROTOCOL_TCP_CLIENT) ? "Connected" : "Sending");
|
||||
}
|
||||
else if (_this->listener && _this->listener->listening()) {
|
||||
ImGui::TextColored(ImVec4(1.0, 1.0, 0.0, 1.0), "Listening");
|
||||
}
|
||||
else if (!_this->enabled) {
|
||||
ImGui::TextUnformatted("Disabled");
|
||||
}
|
||||
else {
|
||||
// If we're idle and still supposed to be running, the server has closed the connection (TODO: kinda jank...)
|
||||
if (_this->running) { _this->stop(); }
|
||||
|
||||
ImGui::TextUnformatted("Idle");
|
||||
}
|
||||
|
||||
if (!_this->enabled) { ImGui::EndDisabled(); }
|
||||
}
|
||||
|
||||
void setMode(Mode newMode, bool forceSet = false) {
|
||||
// If there is no mode to change, do nothing
|
||||
if (!forceSet && mode == newMode) { return; }
|
||||
|
||||
// Stop the DSP
|
||||
reshape.stop();
|
||||
handler.stop();
|
||||
|
||||
// Delete VFO or unbind IQ stream
|
||||
if (vfo) {
|
||||
sigpath::vfoManager.deleteVFO(vfo);
|
||||
vfo = NULL;
|
||||
}
|
||||
if (streamBound) {
|
||||
sigpath::iqFrontEnd.unbindIQStream(&iqStream);
|
||||
streamBound = false;
|
||||
}
|
||||
|
||||
// If the mode was none, we're done
|
||||
if (newMode == MODE_NONE) { return; }
|
||||
|
||||
// Create VFO or bind IQ stream
|
||||
if (newMode == MODE_VFO) {
|
||||
// Create VFO
|
||||
vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, samplerate, samplerate, samplerate, samplerate, true);
|
||||
|
||||
// Set its output as the input to the DSP
|
||||
reshape.setInput(vfo->output);
|
||||
}
|
||||
else {
|
||||
// Bind IQ stream
|
||||
sigpath::iqFrontEnd.bindIQStream(&iqStream);
|
||||
streamBound = true;
|
||||
|
||||
// Set its output as the input to the DSP
|
||||
reshape.setInput(&iqStream);
|
||||
}
|
||||
|
||||
// Start DSP
|
||||
reshape.start();
|
||||
handler.start();
|
||||
|
||||
// Update mode
|
||||
mode = newMode;
|
||||
modeId = modes.valueId(newMode);
|
||||
}
|
||||
|
||||
void listenWorker() {
|
||||
while (true) {
|
||||
// Accept a client
|
||||
auto newSock = listener->accept();
|
||||
if (!newSock) { break; }
|
||||
|
||||
// Update socket
|
||||
{
|
||||
std::lock_guard lck(sockMtx);
|
||||
sock = newSock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int sampleSize() {
|
||||
switch (sampType) {
|
||||
case SAMPLE_TYPE_INT8:
|
||||
return sizeof(int8_t)*2;
|
||||
case SAMPLE_TYPE_INT16:
|
||||
return sizeof(int16_t)*2;
|
||||
case SAMPLE_TYPE_INT32:
|
||||
return sizeof(int32_t)*2;
|
||||
case SAMPLE_TYPE_FLOAT32:
|
||||
return sizeof(dsp::complex_t);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void dataHandler(dsp::complex_t* data, int count, void* ctx) {
|
||||
IQExporterModule* _this = (IQExporterModule*)ctx;
|
||||
|
||||
// Try to cquire lock on socket
|
||||
if (!_this->sockMtx.try_lock()) { return; }
|
||||
|
||||
// If not valid or open, give uo
|
||||
if (!_this->sock || !_this->sock->isOpen()) {
|
||||
// Unlock socket mutex
|
||||
_this->sockMtx.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert the samples or send directory for float32
|
||||
int size;
|
||||
switch (_this->sampType) {
|
||||
case SAMPLE_TYPE_INT8:
|
||||
volk_32f_s32f_convert_8i((int8_t*)_this->buffer, (float*)data, 128.0f, count*2);
|
||||
size = sizeof(int8_t)*2;
|
||||
break;
|
||||
case SAMPLE_TYPE_INT16:
|
||||
volk_32f_s32f_convert_16i((int16_t*)_this->buffer, (float*)data, 32768.0f, count*2);
|
||||
size = sizeof(int16_t)*2;
|
||||
break;
|
||||
case SAMPLE_TYPE_INT32:
|
||||
volk_32f_s32f_convert_32i((int32_t*)_this->buffer, (float*)data, 2147483647.0f, count*2);
|
||||
size = sizeof(int32_t)*2;
|
||||
break;
|
||||
case SAMPLE_TYPE_FLOAT32:
|
||||
_this->sock->send((uint8_t*)data, count*sizeof(dsp::complex_t));
|
||||
default:
|
||||
// Unlock socket mutex
|
||||
_this->sockMtx.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
// Send converted samples
|
||||
_this->sock->send(_this->buffer, count*size);
|
||||
|
||||
// Unlock socket mutex
|
||||
_this->sockMtx.unlock();
|
||||
}
|
||||
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
|
||||
Mode mode = MODE_NONE;
|
||||
int modeId;
|
||||
int samplerate = 1000000.0;
|
||||
int srId;
|
||||
Protocol proto = PROTOCOL_TCP_SERVER;
|
||||
int protoId;
|
||||
SampleType sampType = SAMPLE_TYPE_INT16;
|
||||
int sampTypeId;
|
||||
int packetSize = 1024;
|
||||
int packetSizeId;
|
||||
char hostname[1024] = "localhost";
|
||||
int port = 1234;
|
||||
bool running = false;
|
||||
bool wasRunning = false;
|
||||
|
||||
bool showError = false;
|
||||
std::string errorStr = "";
|
||||
|
||||
OptionList<std::string, Mode> modes;
|
||||
OptionList<int, int> samplerates;
|
||||
OptionList<std::string, Protocol> protocols;
|
||||
OptionList<std::string, SampleType> sampleTypes;
|
||||
OptionList<int, int> packetSizes;
|
||||
|
||||
VFOManager::VFO* vfo = NULL;
|
||||
bool streamBound = false;
|
||||
dsp::stream<dsp::complex_t> iqStream;
|
||||
dsp::buffer::Reshaper<dsp::complex_t> reshape;
|
||||
dsp::sink::Handler<dsp::complex_t> handler;
|
||||
uint8_t* buffer = NULL;
|
||||
|
||||
std::thread listenWorkerThread;
|
||||
|
||||
std::mutex sockMtx;
|
||||
std::shared_ptr<net::Socket> sock;
|
||||
std::shared_ptr<net::Listener> listener;
|
||||
};
|
||||
|
||||
MOD_EXPORT void _INIT_() {
|
||||
json def = json({});
|
||||
std::string root = (std::string)core::args["root"];
|
||||
config.setPath(root + "/iq_exporter_config.json");
|
||||
config.load(def);
|
||||
config.enableAutoSave();
|
||||
}
|
||||
|
||||
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
|
||||
return new IQExporterModule(name);
|
||||
}
|
||||
|
||||
MOD_EXPORT void _DELETE_INSTANCE_(void* instance) {
|
||||
delete (IQExporterModule*)instance;
|
||||
}
|
||||
|
||||
MOD_EXPORT void _END_() {
|
||||
config.disableAutoSave();
|
||||
config.save();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user