mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 13:21:50 -05:00
Added new rewritten library in C++ native for DSD: DSDplus
This commit is contained in:
parent
6a8d1e066e
commit
0b58a50ee8
@ -375,6 +375,7 @@ add_subdirectory(plugins)
|
||||
|
||||
if(LIBMBE_FOUND)
|
||||
add_subdirectory(dsd)
|
||||
add_subdirectory(dsdplus)
|
||||
endif(LIBMBE_FOUND)
|
||||
|
||||
if(LIBUSB_FOUND AND UNIX)
|
||||
|
31
dsdplus/CMakeLists.txt
Normal file
31
dsdplus/CMakeLists.txt
Normal file
@ -0,0 +1,31 @@
|
||||
project(dsdplus)
|
||||
|
||||
set(dsdplus_SOURCES
|
||||
dmr_voice.cpp
|
||||
dsd_decoder.cpp
|
||||
dsd_filters.cpp
|
||||
dsd_opts.cpp
|
||||
dsd_state.cpp
|
||||
)
|
||||
|
||||
set(dsdplus_HEADERS
|
||||
dmr_voice.h
|
||||
dsd_decoder.h
|
||||
dsd_filters.h
|
||||
dsd_opts.h
|
||||
dsd_state.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${LIBMBE_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
add_library(dsdplus SHARED
|
||||
${dsdplus_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(dsdplus ${LIBMBE_LIBRARY})
|
||||
|
||||
install(TARGETS dsdplus DESTINATION lib)
|
46
dsdplus/dmr_voice.cpp
Normal file
46
dsdplus/dmr_voice.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// 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 "dmr_voice.h"
|
||||
#include "dsd_decoder.h"
|
||||
|
||||
namespace DSDPlus
|
||||
{
|
||||
|
||||
DSDDMRVoice::DSDDMRVoice(DSDDecoder *dsdDecoder) :
|
||||
m_dsdDecoder(dsdDecoder)
|
||||
{
|
||||
}
|
||||
|
||||
DSDDMRVoice::~DSDDMRVoice()
|
||||
{
|
||||
}
|
||||
|
||||
void DSDDMRVoice::init()
|
||||
{
|
||||
mutecurrentslot = 0;
|
||||
msMode = 0;
|
||||
dibit_p = m_dsdDecoder->m_state.dibit_buf_p - 144;
|
||||
m_slotIndex = 0;
|
||||
m_majorBlock = 0;
|
||||
}
|
||||
|
||||
void DSDDMRVoice::process()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // namespace dsdplus
|
82
dsdplus/dmr_voice.h
Normal file
82
dsdplus/dmr_voice.h
Normal file
@ -0,0 +1,82 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* DMR voice frames
|
||||
* 6 Major blocks of 10 slots. 2 groups of slots of 144 bytes each.
|
||||
* Map is as follows in number of bytes
|
||||
*
|
||||
* 0 ... 5
|
||||
* A 0 54 ... 54 <- this one is always skipped
|
||||
* 1 12 12 <- cache data
|
||||
* 2 36 36 <- AMBE slot
|
||||
* 3 18 18 <- AMBE slot
|
||||
* 4 24 24 <- sync data
|
||||
* B 5 18 18 <- AMBE slot
|
||||
* 6 36 36 <- AMBE slot
|
||||
* 7 12 12 <- cache data
|
||||
* 8 54 54 <- this one is always skipped
|
||||
* 9 24 24 <- sync data
|
||||
*
|
||||
* The A gtoup of the first major block is already in memory and is processed
|
||||
* at initialization time
|
||||
* Then dibits for each slot are stored in cache and processed right after the
|
||||
* last dibit for the slot has been added.
|
||||
* For skipped slots the dibits are simply thrown away
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DSDPLUS_DMR_VOICE_H_
|
||||
#define DSDPLUS_DMR_VOICE_H_
|
||||
|
||||
namespace DSDPlus
|
||||
{
|
||||
|
||||
class DSDDecoder;
|
||||
|
||||
class DSDDMRVoice
|
||||
{
|
||||
public:
|
||||
DSDDMRVoice(DSDDecoder *dsdDecoder);
|
||||
~DSDDMRVoice();
|
||||
|
||||
void init();
|
||||
void process();
|
||||
|
||||
private:
|
||||
|
||||
DSDDecoder *m_dsdDecoder;
|
||||
// extracts AMBE frames from DMR frame
|
||||
int m_slotIndex; //!< Slot index in major block 0..9 //i;
|
||||
int m_majorBlock; //!< Major block index 0..5 //j;
|
||||
int dibit;
|
||||
int *dibit_p;
|
||||
char ambe_fr[4][24];
|
||||
char ambe_fr2[4][24];
|
||||
char ambe_fr3[4][24];
|
||||
const int *w, *x, *y, *z;
|
||||
char sync[25];
|
||||
char syncdata[25];
|
||||
char cachdata[13];
|
||||
int mutecurrentslot;
|
||||
int msMode;
|
||||
int m_dibitCache[54]; // biggest slot is 54 dibits
|
||||
int m_dibitIndex; // index in dibit cache
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* DSDPLUS_DMR_VOICE_H_ */
|
1380
dsdplus/dsd_decoder.cpp
Normal file
1380
dsdplus/dsd_decoder.cpp
Normal file
File diff suppressed because it is too large
Load Diff
130
dsdplus/dsd_decoder.h
Normal file
130
dsdplus/dsd_decoder.h
Normal file
@ -0,0 +1,130 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DSDPLUS_DSD_DECODER_H_
|
||||
#define DSDPLUS_DSD_DECODER_H_
|
||||
|
||||
#include "dsd_opts.h"
|
||||
#include "dsd_state.h"
|
||||
#include "dsd_filters.h"
|
||||
#include "dmr_voice.h"
|
||||
|
||||
/*
|
||||
* Frame sync patterns
|
||||
*/
|
||||
#define INV_P25P1_SYNC "333331331133111131311111"
|
||||
#define P25P1_SYNC "111113113311333313133333"
|
||||
|
||||
#define X2TDMA_BS_VOICE_SYNC "113131333331313331113311"
|
||||
#define X2TDMA_BS_DATA_SYNC "331313111113131113331133"
|
||||
#define X2TDMA_MS_DATA_SYNC "313113333111111133333313"
|
||||
#define X2TDMA_MS_VOICE_SYNC "131331111333333311111131"
|
||||
|
||||
#define DSTAR_HD "131313131333133113131111"
|
||||
#define INV_DSTAR_HD "313131313111311331313333"
|
||||
#define DSTAR_SYNC "313131313133131113313111"
|
||||
#define INV_DSTAR_SYNC "131313131311313331131333"
|
||||
|
||||
#define NXDN_MS_DATA_SYNC "313133113131111333"
|
||||
#define INV_NXDN_MS_DATA_SYNC "131311331313333111"
|
||||
#define NXDN_MS_VOICE_SYNC "313133113131113133"
|
||||
#define INV_NXDN_MS_VOICE_SYNC "131311331313331311"
|
||||
#define INV_NXDN_BS_DATA_SYNC "131311331313333131"
|
||||
#define NXDN_BS_DATA_SYNC "313133113131111313"
|
||||
#define INV_NXDN_BS_VOICE_SYNC "131311331313331331"
|
||||
#define NXDN_BS_VOICE_SYNC "313133113131113113"
|
||||
|
||||
#define DMR_BS_DATA_SYNC "313333111331131131331131"
|
||||
#define DMR_BS_VOICE_SYNC "131111333113313313113313"
|
||||
#define DMR_MS_DATA_SYNC "311131133313133331131113"
|
||||
#define DMR_MS_VOICE_SYNC "133313311131311113313331"
|
||||
|
||||
#define INV_PROVOICE_SYNC "31313111333133133311331133113311"
|
||||
#define PROVOICE_SYNC "13131333111311311133113311331133"
|
||||
#define INV_PROVOICE_EA_SYNC "13313133113113333311313133133311"
|
||||
#define PROVOICE_EA_SYNC "31131311331331111133131311311133"
|
||||
|
||||
namespace DSDPlus
|
||||
{
|
||||
|
||||
class DSDDecoder
|
||||
{
|
||||
friend class DSDDMRVoice;
|
||||
public:
|
||||
typedef enum
|
||||
{
|
||||
DSDLookForSync,
|
||||
DSDNoSync,
|
||||
DSDprocessFrame,
|
||||
DSDprocessNXDNVoice,
|
||||
DSDprocessNXDNData,
|
||||
DSDprocessDSTAR,
|
||||
DSDprocessDSTAR_HD,
|
||||
DSDprocessDMRvoice,
|
||||
DSDprocessDMRdata,
|
||||
DSDprocessX2TDMAvoice,
|
||||
DSDprocessX2TDMAdata,
|
||||
DSDprocessProVoice,
|
||||
DSDprocessUnknown
|
||||
} DSDFSMState;
|
||||
|
||||
DSDDecoder();
|
||||
~DSDDecoder();
|
||||
|
||||
void run(short sample);
|
||||
|
||||
private:
|
||||
bool pushSample(short sample, int have_sync); //!< push a new sample into the decoder. Returns true if a new symbol is available
|
||||
int getFrameSync();
|
||||
void resetSymbol();
|
||||
void resetFrameSync();
|
||||
void printFrameSync(const char *frametype, int offset, char *modulation);
|
||||
void noCarrier();
|
||||
void printFrameInfo();
|
||||
void processFrame();
|
||||
static int comp(const void *a, const void *b);
|
||||
|
||||
DSDOpts m_opts;
|
||||
DSDState m_state;
|
||||
DSDFSMState m_fsmState;
|
||||
// symbol engine
|
||||
int m_symbol; //!< the last retrieved symbol
|
||||
int m_sampleIndex; //!< the current sample index for the symbol in progress
|
||||
int m_sum;
|
||||
int m_count;
|
||||
// sync engine:
|
||||
int m_sync; //!< The current sync type
|
||||
int m_dibit, m_synctest_pos, m_lastt;
|
||||
char m_synctest[25];
|
||||
char m_synctest18[19];
|
||||
char m_synctest32[33];
|
||||
char m_modulation[8];
|
||||
char *m_synctest_p;
|
||||
char m_synctest_buf[10240];
|
||||
int m_lmin, m_lmax, m_lidx;
|
||||
int m_lbuf[24], m_lbuf2[24];
|
||||
int m_lsum;
|
||||
char m_spectrum[64];
|
||||
int m_t;
|
||||
// Other
|
||||
DSDFilters m_dsdFilters;
|
||||
// Frame decoders
|
||||
DSDDMRVoice m_dsdDMRVoice;
|
||||
};
|
||||
|
||||
} // namespace dsdplus
|
||||
|
||||
#endif /* DSDPLUS_DSD_DECODER_H_ */
|
141
dsdplus/dsd_filters.cpp
Normal file
141
dsdplus/dsd_filters.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// 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 "dsd_filters.h"
|
||||
|
||||
namespace DSDPlus
|
||||
{
|
||||
|
||||
// DMR filter
|
||||
const float DSDFilters::xcoeffs[] =
|
||||
{ -0.0083649323f, -0.0265444850f, -0.0428141462f, -0.0537571943f,
|
||||
-0.0564141052f, -0.0489161045f, -0.0310068662f, -0.0043393881f,
|
||||
+0.0275375106f, +0.0595423283f, +0.0857543325f, +0.1003565948f,
|
||||
+0.0986944931f, +0.0782804830f, +0.0395670487f, -0.0136691535f,
|
||||
-0.0744390415f, -0.1331834575f, -0.1788967208f, -0.2005995448f,
|
||||
-0.1889627181f, -0.1378439993f, -0.0454976231f, +0.0847488694f,
|
||||
+0.2444859269f, +0.4209222342f, +0.5982295474f, +0.7593684540f,
|
||||
+0.8881539892f, +0.9712773915f, +0.9999999166f, +0.9712773915f,
|
||||
+0.8881539892f, +0.7593684540f, +0.5982295474f, +0.4209222342f,
|
||||
+0.2444859269f, +0.0847488694f, -0.0454976231f, -0.1378439993f,
|
||||
-0.1889627181f, -0.2005995448f, -0.1788967208f, -0.1331834575f,
|
||||
-0.0744390415f, -0.0136691535f, +0.0395670487f, +0.0782804830f,
|
||||
+0.0986944931f, +0.1003565948f, +0.0857543325f, +0.0595423283f,
|
||||
+0.0275375106f, -0.0043393881f, -0.0310068662f, -0.0489161045f,
|
||||
-0.0564141052f, -0.0537571943f, -0.0428141462f, -0.0265444850f,
|
||||
-0.0083649323f, };
|
||||
|
||||
// NXDN filter
|
||||
const float DSDFilters::nxcoeffs[] =
|
||||
{ +0.031462429f, +0.031747267f, +0.030401148f, +0.027362877f, +0.022653298f,
|
||||
+0.016379869f, +0.008737200f, +0.000003302f, -0.009468531f,
|
||||
-0.019262057f, -0.028914291f, -0.037935027f, -0.045828927f,
|
||||
-0.052119261f, -0.056372283f, -0.058221106f, -0.057387924f,
|
||||
-0.053703443f, -0.047122444f, -0.037734535f, -0.025769308f,
|
||||
-0.011595336f, +0.004287292f, +0.021260954f, +0.038610717f,
|
||||
+0.055550276f, +0.071252765f, +0.084885375f, +0.095646450f,
|
||||
+0.102803611f, +0.105731303f, +0.103946126f, +0.097138329f,
|
||||
+0.085197939f, +0.068234131f, +0.046586711f, +0.020828821f,
|
||||
-0.008239664f, -0.039608255f, -0.072081234f, -0.104311776f,
|
||||
-0.134843790f, -0.162160200f, -0.184736015f, -0.201094346f,
|
||||
-0.209863285f, -0.209831516f, -0.200000470f, -0.179630919f,
|
||||
-0.148282051f, -0.105841323f, -0.052543664f, +0.011020985f,
|
||||
+0.083912428f, +0.164857408f, +0.252278939f, +0.344336996f,
|
||||
+0.438979335f, +0.534000832f, +0.627109358f, +0.715995947f,
|
||||
+0.798406824f, +0.872214756f, +0.935487176f, +0.986548646f,
|
||||
+1.024035395f, +1.046939951f, +1.054644241f, +1.046939951f,
|
||||
+1.024035395f, +0.986548646f, +0.935487176f, +0.872214756f,
|
||||
+0.798406824f, +0.715995947f, +0.627109358f, +0.534000832f,
|
||||
+0.438979335f, +0.344336996f, +0.252278939f, +0.164857408f,
|
||||
+0.083912428f, +0.011020985f, -0.052543664f, -0.105841323f,
|
||||
-0.148282051f, -0.179630919f, -0.200000470f, -0.209831516f,
|
||||
-0.209863285f, -0.201094346f, -0.184736015f, -0.162160200f,
|
||||
-0.134843790f, -0.104311776f, -0.072081234f, -0.039608255f,
|
||||
-0.008239664f, +0.020828821f, +0.046586711f, +0.068234131f,
|
||||
+0.085197939f, +0.097138329f, +0.103946126f, +0.105731303f,
|
||||
+0.102803611f, +0.095646450f, +0.084885375f, +0.071252765f,
|
||||
+0.055550276f, +0.038610717f, +0.021260954f, +0.004287292f,
|
||||
-0.011595336f, -0.025769308f, -0.037734535f, -0.047122444f,
|
||||
-0.053703443f, -0.057387924f, -0.058221106f, -0.056372283f,
|
||||
-0.052119261f, -0.045828927f, -0.037935027f, -0.028914291f,
|
||||
-0.019262057f, -0.009468531f, +0.000003302f, +0.008737200f,
|
||||
+0.016379869f, +0.022653298f, +0.027362877f, +0.030401148f,
|
||||
+0.031747267f, +0.031462429f, };
|
||||
|
||||
DSDFilters::DSDFilters()
|
||||
{
|
||||
for (int i=0; i < NZEROS+1; i++) {
|
||||
xv[i] = 0.0f;
|
||||
}
|
||||
|
||||
for (int i=0; i < NXZEROS+1; i++) {
|
||||
nxv[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
short DSDFilters::dmr_filter(short sample)
|
||||
{
|
||||
return dsd_input_filter(sample, 1);
|
||||
}
|
||||
|
||||
short DSDFilters::nxdn_filter(short sample)
|
||||
{
|
||||
return dsd_input_filter(sample, 2);
|
||||
}
|
||||
|
||||
short DSDFilters::dsd_input_filter(short sample, int mode)
|
||||
{
|
||||
float sum;
|
||||
int i;
|
||||
float gain;
|
||||
int zeros;
|
||||
float *v;
|
||||
const float *coeffs;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
gain = ngain;
|
||||
v = xv;
|
||||
coeffs = xcoeffs;
|
||||
zeros = NZEROS;
|
||||
break;
|
||||
case 2:
|
||||
gain = nxgain;
|
||||
v = nxv;
|
||||
coeffs = nxcoeffs;
|
||||
zeros = NXZEROS;
|
||||
break;
|
||||
default:
|
||||
return sample;
|
||||
}
|
||||
|
||||
for (i = 0; i < zeros; i++) {
|
||||
v[i] = v[i + 1];
|
||||
}
|
||||
|
||||
v[zeros] = sample; // unfiltered sample in
|
||||
sum = 0.0f;
|
||||
|
||||
for (i = 0; i <= zeros; i++) {
|
||||
sum += (coeffs[i] * v[i]);
|
||||
}
|
||||
|
||||
return sum / ngain; // filtered sample out
|
||||
}
|
||||
|
||||
} // namespace dsdplus
|
||||
|
49
dsdplus/dsd_filters.h
Normal file
49
dsdplus/dsd_filters.h
Normal file
@ -0,0 +1,49 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DSDPLUS_DSD_FILTERS_H_
|
||||
#define DSDPLUS_DSD_FILTERS_H_
|
||||
|
||||
#define NZEROS 60
|
||||
#define NXZEROS 134
|
||||
|
||||
|
||||
namespace DSDPlus
|
||||
{
|
||||
|
||||
class DSDFilters
|
||||
{
|
||||
public:
|
||||
DSDFilters();
|
||||
~DSDFilters();
|
||||
|
||||
static const float ngain = 7.423339364f;
|
||||
static const float xcoeffs[];
|
||||
static const float nxgain = 15.95930463f;
|
||||
static const float nxcoeffs[];
|
||||
|
||||
short dsd_input_filter(short sample, int mode);
|
||||
short dmr_filter(short sample);
|
||||
short nxdn_filter(short sample);
|
||||
|
||||
private:
|
||||
float xv[NZEROS+1];
|
||||
float nxv[NXZEROS+1];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* DSDPLUS_DSD_FILTERS_H_ */
|
65
dsdplus/dsd_opts.cpp
Normal file
65
dsdplus/dsd_opts.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// 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 "dsd_opts.h"
|
||||
|
||||
namespace DSDPlus
|
||||
{
|
||||
|
||||
DSDOpts::DSDOpts()
|
||||
{
|
||||
onesymbol = 10;
|
||||
errorbars = 1;
|
||||
datascope = 0;
|
||||
symboltiming = 0;
|
||||
verbose = 2;
|
||||
p25enc = 0;
|
||||
p25lc = 0;
|
||||
p25status = 0;
|
||||
p25tg = 0;
|
||||
scoperate = 15;
|
||||
split = 0;
|
||||
playoffset = 0;
|
||||
audio_gain = 0;
|
||||
audio_out = 1;
|
||||
resume = 0;
|
||||
frame_dstar = 0;
|
||||
frame_x2tdma = 1;
|
||||
frame_p25p1 = 1;
|
||||
frame_nxdn48 = 0;
|
||||
frame_nxdn96 = 1;
|
||||
frame_dmr = 1;
|
||||
frame_provoice = 0;
|
||||
mod_c4fm = 1;
|
||||
mod_qpsk = 1;
|
||||
mod_gfsk = 1;
|
||||
uvquality = 3;
|
||||
inverted_x2tdma = 1; // most transmitter + scanner + sound card combinations show inverted signals for this
|
||||
inverted_dmr = 0; // most transmitter + scanner + sound card combinations show non-inverted signals for this
|
||||
mod_threshold = 26;
|
||||
ssize = 36;
|
||||
msize = 15;
|
||||
delay = 0;
|
||||
use_cosine_filter = 1;
|
||||
unmute_encrypted_p25 = 0;
|
||||
}
|
||||
|
||||
DSDOpts::~DSDOpts()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace dsdplus
|
||||
|
67
dsdplus/dsd_opts.h
Normal file
67
dsdplus/dsd_opts.h
Normal file
@ -0,0 +1,67 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DSDPLUS_DSD_OPTS_H_
|
||||
#define DSDPLUS_DSD_OPTS_H_
|
||||
|
||||
namespace DSDPlus
|
||||
{
|
||||
|
||||
class DSDOpts
|
||||
{
|
||||
public:
|
||||
DSDOpts();
|
||||
~DSDOpts();
|
||||
|
||||
int onesymbol;
|
||||
int errorbars;
|
||||
int datascope;
|
||||
int symboltiming;
|
||||
int verbose;
|
||||
int p25enc;
|
||||
int p25lc;
|
||||
int p25status;
|
||||
int p25tg;
|
||||
int scoperate;
|
||||
int split;
|
||||
int playoffset;
|
||||
float audio_gain;
|
||||
int audio_out;
|
||||
int resume;
|
||||
int frame_dstar;
|
||||
int frame_x2tdma;
|
||||
int frame_p25p1;
|
||||
int frame_nxdn48;
|
||||
int frame_nxdn96;
|
||||
int frame_dmr;
|
||||
int frame_provoice;
|
||||
int mod_c4fm;
|
||||
int mod_qpsk;
|
||||
int mod_gfsk;
|
||||
int uvquality;
|
||||
int inverted_x2tdma;
|
||||
int inverted_dmr;
|
||||
int mod_threshold;
|
||||
int ssize;
|
||||
int msize;
|
||||
int delay;
|
||||
int use_cosine_filter;
|
||||
int unmute_encrypted_p25;
|
||||
};
|
||||
|
||||
} // namespace dsdplus
|
||||
|
||||
#endif /* DSDPLUS_DSD_OPTS_H_ */
|
128
dsdplus/dsd_state.cpp
Normal file
128
dsdplus/dsd_state.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// 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 "dsd_state.h"
|
||||
|
||||
namespace DSDPlus
|
||||
{
|
||||
|
||||
DSDState::DSDState()
|
||||
{
|
||||
int i, j;
|
||||
|
||||
dibit_buf = (int *) malloc(sizeof(int) * 1000000);
|
||||
dibit_buf_p = dibit_buf + 200;
|
||||
memset (dibit_buf, 0, sizeof (int) * 200);
|
||||
repeat = 0;
|
||||
audio_out_buf = (short *) malloc(sizeof(short) * 1000000);
|
||||
memset (audio_out_buf, 0, 100 * sizeof (short));
|
||||
audio_out_buf_p = audio_out_buf + 100;
|
||||
audio_out_float_buf = (float *) malloc(sizeof(float) * 1000000);
|
||||
memset (audio_out_float_buf, 0, 100 * sizeof (float));
|
||||
audio_out_float_buf_p = audio_out_float_buf + 100;
|
||||
audio_out_idx = 0;
|
||||
audio_out_idx2 = 0;
|
||||
audio_out_temp_buf_p = audio_out_temp_buf;
|
||||
center = 0;
|
||||
jitter = -1;
|
||||
synctype = -1;
|
||||
min = -15000;
|
||||
max = 15000;
|
||||
lmid = 0;
|
||||
umid = 0;
|
||||
minref = -12000;
|
||||
maxref = 12000;
|
||||
lastsample = 0;
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
sbuf[i] = 0;
|
||||
}
|
||||
sidx = 0;
|
||||
for (i = 0; i < 1024; i++)
|
||||
{
|
||||
maxbuf[i] = 15000;
|
||||
}
|
||||
for (i = 0; i < 1024; i++)
|
||||
{
|
||||
minbuf[i] = -15000;
|
||||
}
|
||||
midx = 0;
|
||||
err_str[0] = 0;
|
||||
sprintf (fsubtype, " ");
|
||||
sprintf (ftype, " ");
|
||||
symbolcnt = 0;
|
||||
rf_mod = 0;
|
||||
numflips = 0;
|
||||
lastsynctype = -1;
|
||||
lastp25type = 0;
|
||||
offset = 0;
|
||||
carrier = 0;
|
||||
for (i = 0; i < 25; i++)
|
||||
{
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
tg[i][j] = 48;
|
||||
}
|
||||
}
|
||||
tgcount = 0;
|
||||
lasttg = 0;
|
||||
lastsrc = 0;
|
||||
nac = 0;
|
||||
errs = 0;
|
||||
errs2 = 0;
|
||||
mbe_file_type = -1;
|
||||
optind = 0;
|
||||
numtdulc = 0;
|
||||
firstframe = 0;
|
||||
sprintf (slot0light, " slot0 ");
|
||||
sprintf (slot1light, " slot1 ");
|
||||
aout_gain = 25;
|
||||
memset (aout_max_buf, 0, sizeof (float) * 200);
|
||||
aout_max_buf_p = aout_max_buf;
|
||||
aout_max_buf_idx = 0;
|
||||
samplesPerSymbol = 10;
|
||||
symbolCenter = 4;
|
||||
sprintf (algid, "________");
|
||||
sprintf (keyid, "________________");
|
||||
currentslot = 0;
|
||||
cur_mp = (mbe_parms *) malloc (sizeof (mbe_parms));
|
||||
prev_mp = (mbe_parms *) malloc (sizeof (mbe_parms));
|
||||
prev_mp_enhanced = (mbe_parms *) malloc (sizeof (mbe_parms));
|
||||
mbe_initMbeParms (cur_mp, prev_mp, prev_mp_enhanced);
|
||||
p25kid = 0;
|
||||
|
||||
output_finished = 0;
|
||||
input_offset = 0;
|
||||
output_offset = 0;
|
||||
input_samples = 0;
|
||||
output_num_samples = 0;
|
||||
output_samples = 0;
|
||||
input_length = 0;
|
||||
output_length = 0;
|
||||
output_buffer = 0;
|
||||
}
|
||||
|
||||
DSDState::~DSDState()
|
||||
{
|
||||
free(prev_mp_enhanced);
|
||||
free(prev_mp);
|
||||
free(cur_mp);
|
||||
free(audio_out_float_buf);
|
||||
free(audio_out_buf);
|
||||
free(dibit_buf);
|
||||
}
|
||||
|
||||
} // namespace dsdplus
|
111
dsdplus/dsd_state.h
Normal file
111
dsdplus/dsd_state.h
Normal file
@ -0,0 +1,111 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DSDPLUS_DSD_STATE_H_
|
||||
#define DSDPLUS_DSD_STATE_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mbelib.h>
|
||||
|
||||
namespace DSDPlus
|
||||
{
|
||||
|
||||
class DSDState
|
||||
{
|
||||
public:
|
||||
DSDState();
|
||||
~DSDState();
|
||||
|
||||
int *dibit_buf;
|
||||
int *dibit_buf_p;
|
||||
int repeat;
|
||||
short *audio_out_buf;
|
||||
short *audio_out_buf_p;
|
||||
float *audio_out_float_buf;
|
||||
float *audio_out_float_buf_p;
|
||||
float audio_out_temp_buf[160];
|
||||
float *audio_out_temp_buf_p;
|
||||
int audio_out_idx;
|
||||
int audio_out_idx2;
|
||||
int center;
|
||||
int jitter;
|
||||
int synctype;
|
||||
int min;
|
||||
int max;
|
||||
int lmid;
|
||||
int umid;
|
||||
int minref;
|
||||
int maxref;
|
||||
int lastsample;
|
||||
int sbuf[128];
|
||||
int sidx;
|
||||
int maxbuf[1024];
|
||||
int minbuf[1024];
|
||||
int midx;
|
||||
char err_str[64];
|
||||
char fsubtype[16];
|
||||
char ftype[16];
|
||||
int symbolcnt;
|
||||
int rf_mod;
|
||||
int numflips;
|
||||
int lastsynctype;
|
||||
int lastp25type;
|
||||
int offset;
|
||||
int carrier;
|
||||
char tg[25][16];
|
||||
int tgcount;
|
||||
int lasttg;
|
||||
int lastsrc;
|
||||
int nac;
|
||||
int errs;
|
||||
int errs2;
|
||||
int mbe_file_type;
|
||||
int optind;
|
||||
int numtdulc;
|
||||
int firstframe;
|
||||
char slot0light[8];
|
||||
char slot1light[8];
|
||||
float aout_gain;
|
||||
float aout_max_buf[200];
|
||||
float *aout_max_buf_p;
|
||||
int aout_max_buf_idx;
|
||||
int samplesPerSymbol;
|
||||
int symbolCenter;
|
||||
char algid[9];
|
||||
char keyid[17];
|
||||
int currentslot;
|
||||
mbe_parms *cur_mp;
|
||||
mbe_parms *prev_mp;
|
||||
mbe_parms *prev_mp_enhanced;
|
||||
int p25kid;
|
||||
|
||||
const float *input_samples;
|
||||
int input_length;
|
||||
int input_offset;
|
||||
|
||||
short *output_buffer;
|
||||
int output_offset;
|
||||
float *output_samples;
|
||||
int output_num_samples;
|
||||
int output_length;
|
||||
int output_finished;
|
||||
};
|
||||
|
||||
} // namespace dsdplus
|
||||
|
||||
#endif /* DSDPLUS_DSD_STATE_H_ */
|
Loading…
Reference in New Issue
Block a user