1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 10:05:46 -05:00

Liquid-dsp support correction. Created SymbolSynchronzier as an interface

This commit is contained in:
f4exb 2018-04-03 18:23:39 +02:00
parent d26464fcd8
commit b856bc2aac
5 changed files with 125 additions and 24 deletions

View File

@ -317,6 +317,7 @@ set(math_SOURCES
${LIQUIDDSPSRC}/src/math/src/math.complex.c
${LIQUIDDSPSRC}/src/math/src/math.trig.c
${LIQUIDDSPSRC}/src/math/src/modular_arithmetic.c
${LIQUIDDSPSRC}/src/math/src/windows.c
)
#
@ -441,7 +442,7 @@ set(vector_SOURCES
#
# Library
#
set(liquid_SOURCES
set(liquiddsp_SOURCES
${LIQUIDDSPSRC}/src/libliquid.c
${agc_SOURCES}
${audio_SOURCES}
@ -466,17 +467,27 @@ set(liquid_SOURCES
${vector_SOURCES}
)
add_library(liquid SHARED ${liquid_SOURCES})
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_SHARED)
add_library(liquiddsp SHARED
${liquiddsp_SOURCES}
${liquiddsp_HEADERS_MOC}
)
if (HAVE_LIBM)
target_link_libraries(liquid m)
endif ()
if (HAVE_LIBFEC)
target_link_libraries(liquid fec)
endif ()
if (NOT LIQUID_FFTOVERRIDE AND HAVE_LIBFFTW3F)
target_link_libraries(liquid fftw3f)
target_link_libraries(liquiddsp m)
endif ()
set_property(TARGET liquid PROPERTY OUTPUT_NAME "liquid")
set_property(TARGET liquid PROPERTY SOVERSION "${LIQUID_VERSION}")
set_property(TARGET liquid PROPERTY COMPILE_FLAGS "${_EXTRA_C_FLAGS}")
if (HAVE_LIBFEC)
target_link_libraries(liquiddsp fec)
endif ()
if (NOT LIQUID_FFTOVERRIDE AND HAVE_LIBFFTW3F)
target_link_libraries(liquiddsp fftw3f)
endif ()
#set_property(TARGET liquid PROPERTY OUTPUT_NAME "liquid")
#set_property(TARGET liquid PROPERTY SOVERSION "${LIQUID_VERSION}")
set_property(TARGET liquiddsp PROPERTY COMPILE_FLAGS "${_EXTRA_C_FLAGS}")

View File

@ -1,12 +0,0 @@
function(LIQUID_BUILD_SAMPLES)
cmake_parse_arguments(LBS "" "SUITE" "SAMPLES" ${ARGN})
if (NOT DEFINED LBS_SUITE)
message(FATAL_ERROR "Need to specify SUITE <name>")
endif ()
foreach(_sample IN ITEMS ${LBS_SAMPLES})
add_executable("${LBS_SUITE}_${_sample}" "${_sample}.c")
target_link_libraries("${LBS_SUITE}_${_sample}" ${LIQUID_LIBRARY})
set_property(TARGET "${LBS_SUITE}_${_sample}" PROPERTY OUTPUT_NAME "${_sample}")
endforeach()
endfunction()

View File

@ -45,6 +45,7 @@ set(sdrbase_SOURCES
dsp/basebandsamplesource.cpp
dsp/nullsink.cpp
dsp/recursivefilters.cpp
dsp/symsync.cpp
dsp/threadedbasebandsamplesink.cpp
dsp/threadedbasebandsamplesource.cpp
dsp/wfir.cpp
@ -146,6 +147,7 @@ set(sdrbase_HEADERS
dsp/basebandsamplesink.h
dsp/basebandsamplesource.h
dsp/nullsink.h
dsp/symsync.h
dsp/threadedbasebandsamplesink.h
dsp/threadedbasebandsamplesource.h
dsp/wfir.h
@ -262,6 +264,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/httpserver
${CMAKE_SOURCE_DIR}/qrtplib
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${LIQUIDDSPSRC}/include
)
target_link_libraries(sdrbase
@ -269,6 +272,7 @@ target_link_libraries(sdrbase
httpserver
qrtplib
swagger
liquiddsp
)
if(FFTW3F_FOUND)

62
sdrbase/dsp/symsync.cpp Normal file
View File

@ -0,0 +1,62 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// Symbol synchronizer or symbol clock recovery mostly encapsulating //
// liquid-dsp's symsync "object" //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "symsync.h"
SymbolSynchronizer::SymbolSynchronizer()
{
// For now use hardcoded values:
// - RRC filter
// - 4 samples per symbol
// - 5 sybols delay filter
// - 0.5 filter excess bandwidth factor
// - 32 filter elements for the internal polyphase filter
m_sync = symsync_crcf_create_rnyquist(LIQUID_FIRFILT_RRC, 4, 5, 0.5f, 32);
// - 0.02 loop filter bandwidth factor
symsync_crcf_set_lf_bw(m_sync, 0.02f);
// - 4 samples per symbol output rate
symsync_crcf_set_output_rate(m_sync, 4);
m_syncSampleCount = 0;
}
SymbolSynchronizer::~SymbolSynchronizer()
{
symsync_crcf_destroy(m_sync);
}
Real SymbolSynchronizer::run(const Sample& s)
{
unsigned int nn;
Real v = 0.0f;
liquid_float_complex y = (s.m_real / SDR_RX_SCALEF) + (s.m_imag / SDR_RX_SCALEF)*I;
symsync_crcf_execute(m_sync, &y, 1, m_z, &nn);
for (unsigned int i = 0; i < nn; i++)
{
v = (m_syncSampleCount < 2) ? 1.0f : 0.0f; // actual sync is at 0
if (m_syncSampleCount < 4) {
m_syncSampleCount++;
} else {
m_syncSampleCount = 0;
}
}
return v;
}

36
sdrbase/dsp/symsync.h Normal file
View File

@ -0,0 +1,36 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// Symbol synchronizer or symbol clock recovery mostly encapsulating //
// liquid-dsp's symsync "object" //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "dsp/dsptypes.h"
#include "liquid.h"
#include <complex.h>
class SymbolSynchronizer
{
public:
SymbolSynchronizer();
~SymbolSynchronizer();
Real run(const Sample& s);
private:
symsync_crcf m_sync;
liquid_float_complex m_z[4+4]; // 4 samples per symbol. One symbol plus extra space
int m_syncSampleCount;
};