Skip to content

Commit

Permalink
Port for SDR++ v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
williamyang98 committed Apr 17, 2024
1 parent cad13f4 commit a2fbb69
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/arm-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: arm-macos
on:
workflow_dispatch:
push:
branches: [ "master", "dev" ]
branches: [ "master", "dev", "sdr-1.0.4" ]

env:
BUILD_TYPE: Release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/x86-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: x86-macos
on:
workflow_dispatch:
push:
branches: [ "master", "dev" ]
branches: [ "master", "dev", "sdr-1.0.4" ]

env:
BUILD_TYPE: Release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/x86-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: x86-ubuntu
on:
workflow_dispatch:
push:
branches: [ "master", "dev" ]
branches: [ "master", "dev", "sdr-1.0.4" ]

env:
BUILD_TYPE: Release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/x86-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: x86-windows
on:
workflow_dispatch:
push:
branches: [ "master", "dev" ]
branches: [ "master", "dev", "sdr-1.0.4" ]

env:
BUILD_TYPE: Release
Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ else()
# however pkg-config cant find libcorrect because it is not a package in the repository
endif()
set(OPT_BACKEND_GLFW ON CACHE BOOL "Enable glfw backend")
add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/sdrplusplus/core)
set_target_properties(sdrpp_core PROPERTIES CXX_STANDARD 17)

find_package(sdrpp_core REQUIRED)

# build dab modules
# copied from ./vendor/DAB-Radio/CMakeLists.txt
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Introduction
[![x86-windows](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-windows.yml/badge.svg)](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-windows.yml)
[![x86-ubuntu](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-ubuntu.yml/badge.svg)](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-ubuntu.yml)
[![x86-macos](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-macos.yml/badge.svg)](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-macos.yml)
[![arm-macos](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/arm-macos.yml/badge.svg)](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/arm-macos.yml)
[![x86-windows](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-windows.yml/badge.svg?branch=sdr-1.0.4)](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-windows.yml)
[![x86-ubuntu](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-ubuntu.yml/badge.svg?branch=sdr-1.0.4)](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-ubuntu.yml)
[![x86-macos](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-macos.yml/badge.svg?branch=sdr-1.0.4)](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/x86-macos.yml)
[![arm-macos](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/arm-macos.yml/badge.svg?branch=sdr-1.0.4)](https://github.com/williamyang98/SDRPlusPlus-DAB-Radio-Plugin/actions/workflows/arm-macos.yml)

SDR++ DAB radio plugin.

Expand Down
113 changes: 113 additions & 0 deletions cmake/Findsdrpp_core.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Copied from vendor/sdrplusplus/core/CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
project(sdrpp_core)

set(SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/../vendor/sdrplusplus/core)

# Main code
file(GLOB_RECURSE SRC "${SRC_DIR}/src/*.cpp" "${SRC_DIR}/src/*.c")

if (MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif ()

# Add code to dyn lib
add_library(sdrpp_core SHARED ${SRC})
# configure SDRPP_EXPORT dllimport/dllexport/extern properly for core/src/module.h
target_compile_definitions(sdrpp_core PRIVATE SDRPP_IS_CORE)

# Set compiler options
if (MSVC)
target_compile_options(sdrpp_core PRIVATE /O2 /Ob2 /std:c++17 /EHsc)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(sdrpp_core PRIVATE -O3 -std=c++17)
else ()
target_compile_options(sdrpp_core PRIVATE -O3 -std=c++17)
endif ()


# Set the install prefix
target_compile_definitions(sdrpp_core PUBLIC INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")

# Include core headers
target_include_directories(sdrpp_core PUBLIC "${SRC_DIR}/src/")
target_include_directories(sdrpp_core PUBLIC "${SRC_DIR}/src/imgui")

# Link to linkcorrect
if (USE_INTERNAL_LIBCORRECT)
add_subdirectory("${SRC_DIR}/libcorrect/")
target_include_directories(sdrpp_core PUBLIC "${SRC_DIR}/libcorrect/include")
target_link_libraries(sdrpp_core PUBLIC correct_static)
endif (USE_INTERNAL_LIBCORRECT)

if (OPT_OVERRIDE_STD_FILESYSTEM)
target_include_directories(sdrpp_core PUBLIC "${SRC_DIR}/std_replacement")
endif (OPT_OVERRIDE_STD_FILESYSTEM)

if (MSVC)
# Lib path
target_link_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/lib/")

# Misc headers
target_include_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/include/")

# Volk
target_link_libraries(sdrpp_core PUBLIC volk)

# Glew
find_package(GLEW REQUIRED)
target_link_libraries(sdrpp_core PUBLIC GLEW::GLEW)

# GLFW3
find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(sdrpp_core PUBLIC glfw)

# FFTW3
find_package(FFTW3f CONFIG REQUIRED)
target_link_libraries(sdrpp_core PUBLIC FFTW3::fftw3f)

# WinSock2
target_link_libraries(sdrpp_core PUBLIC wsock32 ws2_32)

else()
find_package(PkgConfig)
find_package(OpenGL REQUIRED)

pkg_check_modules(GLEW REQUIRED glew)
pkg_check_modules(FFTW3 REQUIRED fftw3f)
pkg_check_modules(VOLK REQUIRED volk)
pkg_check_modules(GLFW3 REQUIRED glfw3)

target_include_directories(sdrpp_core PUBLIC
${GLEW_INCLUDE_DIRS}
${FFTW3_INCLUDE_DIRS}
${GLFW3_INCLUDE_DIRS}
${VOLK_INCLUDE_DIRS}
)

target_link_directories(sdrpp_core PUBLIC
${GLEW_LIBRARY_DIRS}
${FFTW3_LIBRARY_DIRS}
${GLFW3_LIBRARY_DIRS}
${VOLK_LIBRARY_DIRS}
)

target_link_libraries(sdrpp_core PUBLIC
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${FFTW3_LIBRARIES}
${GLFW3_LIBRARIES}
${VOLK_LIBRARIES}
)

if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(sdrpp_core PUBLIC stdc++fs)
endif ()

if (NOT USE_INTERNAL_LIBCORRECT)
pkg_check_modules(CORRECT REQUIRED libcorrect)
target_include_directories(sdrpp_core PUBLIC ${CORRECT_INCLUDE_DIRS})
target_link_directories(sdrpp_core PUBLIC ${CORRECT_LIBRARY_DIRS})
target_link_libraries(sdrpp_core PUBLIC ${CORRECT_LIBRARIES})
endif (NOT USE_INTERNAL_LIBCORRECT)
endif ()
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ target_include_directories(dab_plugin PRIVATE ${SRC_DIR} ${ROOT_DIR} ${AUDIO_DIR
target_link_libraries(dab_plugin PRIVATE
sdrpp_core
ofdm_core dab_core basic_radio audio_mixer
fmt)
)
22 changes: 12 additions & 10 deletions src/dab_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
#include "utility/span.h"

ConfigManager config; // extern

int OFDM_Demodulator_Sink::run() {
int count = base_type::_in->read();
if (count < 0) return -1;
auto* buf = base_type::_in->readBuf;
auto block = tcb::span(reinterpret_cast<std::complex<float>*>(buf), size_t(count));
m_ofdm_demod->Process(block);
base_type::_in->flush();
return count;
//
OFDM_Demodulator_Sink::OFDM_Demodulator_Sink(std::shared_ptr<OFDM_Demod> ofdm_demod)
: m_ofdm_demod(ofdm_demod)
{
setHandler(
[](dsp::complex_t* buf, int count, void* ctx) {
auto ofdm_demod = reinterpret_cast<OFDM_Demod*>(ctx);
auto block = tcb::span(reinterpret_cast<std::complex<float>*>(buf), size_t(count));
ofdm_demod->Process(block);
},
reinterpret_cast<void*>(m_ofdm_demod.get())
);
}

Audio_Player_Stream::Audio_Player_Stream(float sample_rate, float block_size_seconds)
Expand Down Expand Up @@ -74,7 +77,6 @@ DABModule::DABModule(std::string _name)
// setup radio
radio_block = std::make_unique<Radio_Block>(1,1);
ofdm_demodulator_sink = std::make_unique<OFDM_Demodulator_Sink>(radio_block->get_ofdm_demodulator());
ofdm_demodulator_sink->init(nullptr);
radio_view_controller = std::make_unique<Radio_View_Controller>();
// setup audio
const float DEFAULT_AUDIO_SAMPLE_RATE = 48000.0f;
Expand Down
7 changes: 3 additions & 4 deletions src/dab_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ class OFDM_Demod;
class Radio_View_Controller;
class Radio_Block;

class OFDM_Demodulator_Sink: public dsp::Sink<dsp::complex_t>
class OFDM_Demodulator_Sink: public dsp::HandlerSink<dsp::complex_t>
{
private:
using base_type = dsp::Sink<dsp::complex_t>;
using base_type = dsp::HandlerSink<dsp::complex_t>;
std::shared_ptr<OFDM_Demod> m_ofdm_demod;
public:
OFDM_Demodulator_Sink(std::shared_ptr<OFDM_Demod> ofdm_demod): m_ofdm_demod(ofdm_demod) {}
OFDM_Demodulator_Sink(std::shared_ptr<OFDM_Demod> ofdm_demod);
~OFDM_Demodulator_Sink() override {
if (!base_type::_block_init) return;
base_type::stop();
}
int run();
};

class Audio_Player_Stream: public AudioPipelineSink
Expand Down
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <config.h>
#include <core.h>
#include <options.h>
#include <string>

#include "./dab_module.h"
Expand All @@ -14,7 +15,7 @@ SDRPP_MOD_INFO{

MOD_EXPORT void _INIT_() {
json def = json({});
config.setPath(core::args["root"].s() + "/dab_plugin_config.json");
config.setPath(options::opts.root + "/dab_plugin_config.json");
config.load(def);
config.enableAutoSave();
}
Expand Down
2 changes: 1 addition & 1 deletion src/render_formatters.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./render_formatters.h"
#include <fmt/core.h>
#include <spdlog/fmt/fmt.h>

#include "dab/constants/subchannel_protection_tables.h"
#include "dab/constants/country_table.h"
Expand Down
2 changes: 1 addition & 1 deletion src/render_radio_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <cmath>
#include <string_view>
#include <fmt/core.h>
#include <spdlog/fmt/fmt.h>
#include <imgui/imgui.h>
#include <imgui/imgui_internal.h>
#include <gui/widgets/constellation_diagram.h>
Expand Down
1 change: 1 addition & 0 deletions toolchains/macos/Brewfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
brew 'pkg-config'
brew 'fftw'
brew 'glew'
brew 'glfw'
brew 'zstd'
brew 'cmake'
Expand Down
2 changes: 1 addition & 1 deletion toolchains/ubuntu/install_packages.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

sudo apt-get --yes install build-essential ninja-build
sudo apt-get --yes install libglfw3-dev libopengl-dev libfftw3-dev libfftw3-single3 libvolk2-dev libzstd-dev libcpu-features-dev
sudo apt-get --yes install libglew-dev libglfw3-dev libopengl-dev libfftw3-dev libfftw3-single3 libvolk2-dev libzstd-dev libcpu-features-dev

# install mako for volk build
python -m pip install mako --quiet
4 changes: 4 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version-string": "latest",
"builtin-baseline": "c9140a3b500812ad3206317885860d9553b93f13",
"dependencies": [
{
"name": "glew",
"version>=": "2.2.0#3"
},
{
"name": "glfw3",
"version>=": "3.3.6"
Expand Down
2 changes: 1 addition & 1 deletion vendor/sdrplusplus
Submodule sdrplusplus updated 640 files

0 comments on commit a2fbb69

Please sign in to comment.