Skip to content

Commit 39193a4

Browse files
committed
Port for SDR++ v1.0.4
1 parent da4080f commit 39193a4

File tree

17 files changed

+149
-31
lines changed

17 files changed

+149
-31
lines changed

.github/workflows/arm-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: arm-macos
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ "master", "dev" ]
6+
branches: [ "master", "dev", "sdr-1.0.4" ]
77

88
env:
99
BUILD_TYPE: Release

.github/workflows/x86-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: x86-macos
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ "master", "dev" ]
6+
branches: [ "master", "dev", "sdr-1.0.4" ]
77

88
env:
99
BUILD_TYPE: Release

.github/workflows/x86-ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: x86-ubuntu
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ "master", "dev" ]
6+
branches: [ "master", "dev", "sdr-1.0.4" ]
77

88
env:
99
BUILD_TYPE: Release

.github/workflows/x86-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: x86-windows
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ "master", "dev" ]
6+
branches: [ "master", "dev", "sdr-1.0.4" ]
77

88
env:
99
BUILD_TYPE: Release

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ else()
3939
# however pkg-config cant find libcorrect because it is not a package in the repository
4040
endif()
4141
set(OPT_BACKEND_GLFW ON CACHE BOOL "Enable glfw backend")
42-
add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/sdrplusplus/core)
43-
set_target_properties(sdrpp_core PROPERTIES CXX_STANDARD 17)
44-
42+
find_package(sdrpp_core REQUIRED)
4543

4644
# build dab modules
4745
# copied from ./vendor/DAB-Radio/CMakeLists.txt

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## Introduction
2-
[![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)
3-
[![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)
4-
[![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)
5-
[![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)
2+
[![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)
3+
[![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)
4+
[![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)
5+
[![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)
66

77
SDR++ DAB radio plugin.
88

cmake/Findsdrpp_core.cmake

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Copied from vendor/sdrplusplus/core/CMakeLists.txt
2+
cmake_minimum_required(VERSION 3.13)
3+
project(sdrpp_core)
4+
5+
set(SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/../vendor/sdrplusplus/core)
6+
7+
# Main code
8+
file(GLOB_RECURSE SRC "${SRC_DIR}/src/*.cpp" "${SRC_DIR}/src/*.c")
9+
10+
if (MSVC)
11+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
12+
endif ()
13+
14+
# Add code to dyn lib
15+
add_library(sdrpp_core SHARED ${SRC})
16+
# configure SDRPP_EXPORT dllimport/dllexport/extern properly for core/src/module.h
17+
target_compile_definitions(sdrpp_core PRIVATE SDRPP_IS_CORE)
18+
19+
# Set compiler options
20+
if (MSVC)
21+
target_compile_options(sdrpp_core PRIVATE /O2 /Ob2 /std:c++17 /EHsc)
22+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
23+
target_compile_options(sdrpp_core PRIVATE -O3 -std=c++17)
24+
else ()
25+
target_compile_options(sdrpp_core PRIVATE -O3 -std=c++17)
26+
endif ()
27+
28+
29+
# Set the install prefix
30+
target_compile_definitions(sdrpp_core PUBLIC INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
31+
32+
# Include core headers
33+
target_include_directories(sdrpp_core PUBLIC "${SRC_DIR}/src/")
34+
target_include_directories(sdrpp_core PUBLIC "${SRC_DIR}/src/imgui")
35+
36+
# Link to linkcorrect
37+
if (USE_INTERNAL_LIBCORRECT)
38+
add_subdirectory("${SRC_DIR}/libcorrect/")
39+
target_include_directories(sdrpp_core PUBLIC "${SRC_DIR}/libcorrect/include")
40+
target_link_libraries(sdrpp_core PUBLIC correct_static)
41+
endif (USE_INTERNAL_LIBCORRECT)
42+
43+
if (OPT_OVERRIDE_STD_FILESYSTEM)
44+
target_include_directories(sdrpp_core PUBLIC "${SRC_DIR}/std_replacement")
45+
endif (OPT_OVERRIDE_STD_FILESYSTEM)
46+
47+
if (MSVC)
48+
# Lib path
49+
target_link_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/lib/")
50+
51+
# Misc headers
52+
target_include_directories(sdrpp_core PUBLIC "C:/Program Files/PothosSDR/include/")
53+
54+
# Volk
55+
target_link_libraries(sdrpp_core PUBLIC volk)
56+
57+
# Glew
58+
find_package(GLEW REQUIRED)
59+
target_link_libraries(sdrpp_core PUBLIC GLEW::GLEW)
60+
61+
# GLFW3
62+
find_package(glfw3 CONFIG REQUIRED)
63+
target_link_libraries(sdrpp_core PUBLIC glfw)
64+
65+
# FFTW3
66+
find_package(FFTW3f CONFIG REQUIRED)
67+
target_link_libraries(sdrpp_core PUBLIC FFTW3::fftw3f)
68+
69+
# WinSock2
70+
target_link_libraries(sdrpp_core PUBLIC wsock32 ws2_32)
71+
72+
else()
73+
find_package(PkgConfig)
74+
find_package(OpenGL REQUIRED)
75+
76+
pkg_check_modules(GLEW REQUIRED glew)
77+
pkg_check_modules(FFTW3 REQUIRED fftw3f)
78+
pkg_check_modules(VOLK REQUIRED volk)
79+
pkg_check_modules(GLFW3 REQUIRED glfw3)
80+
81+
target_include_directories(sdrpp_core PUBLIC
82+
${GLEW_INCLUDE_DIRS}
83+
${FFTW3_INCLUDE_DIRS}
84+
${GLFW3_INCLUDE_DIRS}
85+
${VOLK_INCLUDE_DIRS}
86+
)
87+
88+
target_link_directories(sdrpp_core PUBLIC
89+
${GLEW_LIBRARY_DIRS}
90+
${FFTW3_LIBRARY_DIRS}
91+
${GLFW3_LIBRARY_DIRS}
92+
${VOLK_LIBRARY_DIRS}
93+
)
94+
95+
target_link_libraries(sdrpp_core PUBLIC
96+
${OPENGL_LIBRARIES}
97+
${GLEW_LIBRARIES}
98+
${FFTW3_LIBRARIES}
99+
${GLFW3_LIBRARIES}
100+
${VOLK_LIBRARIES}
101+
)
102+
103+
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
104+
target_link_libraries(sdrpp_core PUBLIC stdc++fs)
105+
endif ()
106+
107+
if (NOT USE_INTERNAL_LIBCORRECT)
108+
pkg_check_modules(CORRECT REQUIRED libcorrect)
109+
target_include_directories(sdrpp_core PUBLIC ${CORRECT_INCLUDE_DIRS})
110+
target_link_directories(sdrpp_core PUBLIC ${CORRECT_LIBRARY_DIRS})
111+
target_link_libraries(sdrpp_core PUBLIC ${CORRECT_LIBRARIES})
112+
endif (NOT USE_INTERNAL_LIBCORRECT)
113+
endif ()

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ target_include_directories(dab_plugin PRIVATE ${SRC_DIR} ${ROOT_DIR} ${AUDIO_DIR
2323
target_link_libraries(dab_plugin PRIVATE
2424
sdrpp_core
2525
ofdm_core dab_core basic_radio audio_mixer
26-
fmt)
26+
)

src/dab_module.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616
#include "utility/span.h"
1717

1818
ConfigManager config; // extern
19-
20-
int OFDM_Demodulator_Sink::run() {
21-
int count = base_type::_in->read();
22-
if (count < 0) return -1;
23-
auto* buf = base_type::_in->readBuf;
24-
auto block = tcb::span(reinterpret_cast<std::complex<float>*>(buf), size_t(count));
25-
m_ofdm_demod->Process(block);
26-
base_type::_in->flush();
27-
return count;
19+
//
20+
OFDM_Demodulator_Sink::OFDM_Demodulator_Sink(std::shared_ptr<OFDM_Demod> ofdm_demod)
21+
: m_ofdm_demod(ofdm_demod)
22+
{
23+
setHandler(
24+
[](dsp::complex_t* buf, int count, void* ctx) {
25+
auto ofdm_demod = reinterpret_cast<OFDM_Demod*>(ctx);
26+
auto block = tcb::span(reinterpret_cast<std::complex<float>*>(buf), size_t(count));
27+
ofdm_demod->Process(block);
28+
},
29+
reinterpret_cast<void*>(m_ofdm_demod.get())
30+
);
2831
}
2932

3033
Audio_Player_Stream::Audio_Player_Stream(float sample_rate, float block_size_seconds)
@@ -91,7 +94,6 @@ DABModule::DABModule(std::string _name)
9194
// setup radio
9295
radio_block = std::make_unique<Radio_Block>(1,1);
9396
ofdm_demodulator_sink = std::make_unique<OFDM_Demodulator_Sink>(radio_block->get_ofdm_demodulator());
94-
ofdm_demodulator_sink->init(nullptr);
9597
radio_view_controller = std::make_unique<Radio_View_Controller>();
9698
// setup audio
9799
const float DEFAULT_AUDIO_SAMPLE_RATE = 48000.0f;

src/dab_module.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@ class OFDM_Demod;
1919
class Radio_View_Controller;
2020
class Radio_Block;
2121

22-
class OFDM_Demodulator_Sink: public dsp::Sink<dsp::complex_t>
22+
class OFDM_Demodulator_Sink: public dsp::HandlerSink<dsp::complex_t>
2323
{
2424
private:
25-
using base_type = dsp::Sink<dsp::complex_t>;
25+
using base_type = dsp::HandlerSink<dsp::complex_t>;
2626
std::shared_ptr<OFDM_Demod> m_ofdm_demod;
2727
public:
28-
OFDM_Demodulator_Sink(std::shared_ptr<OFDM_Demod> ofdm_demod): m_ofdm_demod(ofdm_demod) {}
28+
OFDM_Demodulator_Sink(std::shared_ptr<OFDM_Demod> ofdm_demod);
2929
~OFDM_Demodulator_Sink() override {
3030
if (!base_type::_block_init) return;
3131
base_type::stop();
3232
}
33-
int run();
3433
};
3534

3635
class Audio_Player_Stream: public AudioPipelineSink

0 commit comments

Comments
 (0)