DSD demod: this is the end of it. f..k off!

pull/6/head
f4exb 2016-04-08 18:14:50 +02:00
rodzic 93b0b91f79
commit 405fa042f9
37 zmienionych plików z 1546 dodań i 838 usunięć

Wyświetl plik

@ -1,10 +1,12 @@
project(dsd)
set(dsd_SOURCES
dmr_const.c
dmr_data.c
dmr_voice.c
dsd_audio.c
dsd_cleanupexit.c
dsd_comp.c
dsd_dibit.c
# dsd_file.c
dsd_filters.c
@ -16,17 +18,23 @@ set(dsd_SOURCES
dsd_opts.c
dsd_symbol.c
dsd_upsample.c
dstar_const.c
dstar_header.c
dstar.c
nxdn_const.c
nxdn_data.c
nxdn_voice.c
nxdn96.c
nxdn96_const.c
p25_lcw.c
p25p1_const.c
p25p1_hdu.c
p25p1_ldu1.c
p25p1_ldu2.c
p25p1_tdulc.c
provoice.c
provoice_const.c
x2tdma_const.c
x2tdma_data.c
x2tdma_voice.c
)
@ -36,6 +44,7 @@ set(dsd_HEADERS
descramble.h
dmr_const.h
dsd_cleanupexit.h
dsd_comp.h
dsd_livescanner.h
dsd_nocarrier.h
dsd_opts.h
@ -68,4 +77,6 @@ add_library(dsd SHARED
target_link_libraries(dsd ${LIBS})
install(TARGETS dsd DESTINATION lib)
install(TARGETS dsd DESTINATION lib)

57
dsd/dmr_const.c 100644
Wyświetl plik

@ -0,0 +1,57 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "dmr_const.h"
/*
* DMR AMBE interleave schedule
*/
const int rW[36] = {
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
const int rX[36] = {
23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
const int rY[36] = {
0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int rZ[36] = {
5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};

Wyświetl plik

@ -15,50 +15,50 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _MAIN
//#ifndef _MAIN
extern const int rW[36];
extern const int rX[36];
extern const int rY[36];
extern const int rZ[36];
#else
/*
* DMR AMBE interleave schedule
*/
const int rW[36] = {
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
//#else
///*
// * DMR AMBE interleave schedule
// */
//const int rW[36] = {
// 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 2,
// 0, 2, 0, 2, 0, 2,
// 0, 2, 0, 2, 0, 2
//};
//
//const int rX[36] = {
// 23, 10, 22, 9, 21, 8,
// 20, 7, 19, 6, 18, 5,
// 17, 4, 16, 3, 15, 2,
// 14, 1, 13, 0, 12, 10,
// 11, 9, 10, 8, 9, 7,
// 8, 6, 7, 5, 6, 4
//};
//
//const int rY[36] = {
// 0, 2, 0, 2, 0, 2,
// 0, 2, 0, 3, 0, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3
//};
//
//const int rZ[36] = {
// 5, 3, 4, 2, 3, 1,
// 2, 0, 1, 13, 0, 12,
// 22, 11, 21, 10, 20, 9,
// 19, 8, 18, 7, 17, 6,
// 16, 5, 15, 4, 14, 3,
// 13, 2, 12, 1, 11, 0
//};
const int rX[36] = {
23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
const int rY[36] = {
0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int rZ[36] = {
5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};
#endif
//#endif

Wyświetl plik

@ -22,7 +22,6 @@
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#define __USE_XOPEN
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
@ -38,8 +37,12 @@
#endif
#include <math.h>
#include <mbelib.h>
#ifdef USE_LIBSNDFILE
#include <sndfile.h>
#endif
#include "dsd_opts.h"
#include "dsd_state.h"
#include "p25p1_heuristics.h"
@ -61,11 +64,7 @@
/*
* global variables
*/
int exitflag;
#include "dsd_opts.h"
#include "dsd_state.h"
#include "dsd_livescanner.h"
//int exitflag; // You just can't have a global here within SDRangel -> moved to state
/*
* Frame sync patterns
@ -105,6 +104,11 @@ int exitflag;
/*
* function prototypes
*/
#ifdef __cplusplus
extern "C" {
#endif
void processDMRdata (dsd_opts * opts, dsd_state * state);
void processDMRvoice (dsd_opts * opts, dsd_state * state);
void processAudio (dsd_opts * opts, dsd_state * state);
@ -130,10 +134,6 @@ void printFrameInfo (dsd_opts * opts, dsd_state * state);
void processFrame (dsd_opts * opts, dsd_state * state);
void printFrameSync (dsd_opts * opts, dsd_state * state, char *frametype, int offset, char *modulation);
int getFrameSync (dsd_opts * opts, dsd_state * state);
int comp (const void *a, const void *b);
void usage ();
void sigfun (int sig);
int main (int argc, char **argv);
void playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv);
void processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24]);
void openSerial (dsd_opts * opts, dsd_state * state);
@ -156,4 +156,8 @@ void processDSTAR_HD (dsd_opts * opts, dsd_state * state);
short dmr_filter(short sample);
short nxdn_filter(short sample);
#ifdef __cplusplus
}
#endif
#endif // DSD_H

Wyświetl plik

@ -30,7 +30,7 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state)
}
#endif
printf ("Exiting.\n");
exit (0);
//exit (0); // You just can't do that within SDRangel
}

19
dsd/dsd_comp.c 100644
Wyświetl plik

@ -0,0 +1,19 @@
/*
* dsd_comp.c
*
* Created on: Apr 8, 2016
* Author: f4exb
*/
#include "dsd_comp.h"
int comp(const void *a, const void *b)
{
if (*((const int *) a) == *((const int *) b))
return 0;
else if (*((const int *) a) < *((const int *) b))
return -1;
else
return 1;
}

13
dsd/dsd_comp.h 100644
Wyświetl plik

@ -0,0 +1,13 @@
/*
* dsd_comp.h
*
* Created on: Apr 8, 2016
* Author: f4exb
*/
#ifndef DSD_DSD_COMP_H_
#define DSD_DSD_COMP_H_
int comp(const void *a, const void *b);
#endif /* DSD_DSD_COMP_H_ */

Wyświetl plik

@ -16,6 +16,7 @@
*/
#include "dsd.h"
#include "dsd_comp.h"
int
getDibit (dsd_opts * opts, dsd_state * state)

Wyświetl plik

@ -18,6 +18,7 @@
#include "dsd.h"
#include "dsd_cleanupexit.h"
#include "dsd_nocarrier.h"
#include "dsd_comp.h"
void
printFrameSync (dsd_opts * opts, dsd_state * state, char *frametype, int offset, char *modulation)
@ -794,7 +795,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
}
}
if (exitflag == 1)
if (state->exitflag == 1) // was moved to state for inclusion in SDRangel. Should not be used anyway (always 0)
{
cleanupAndExit (opts, state);
}

Wyświetl plik

@ -21,51 +21,33 @@
void liveScanner(dsd_opts * opts, dsd_state * state)
{
#ifdef USE_PORTAUDIO
if(opts->audio_in_type == 2)
if (opts->audio_in_fd == -1)
{
PaError err = Pa_StartStream( opts->audio_in_pa_stream );
if( err != paNoError )
if (pthread_mutex_lock(&state->input_mutex))
{
fprintf( stderr, "An error occured while starting the portaudio input stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return;
printf("liveScanner -> Unable to lock mutex\n");
}
}
#endif
while (1)
while (state->dsd_running)
{
noCarrier(opts, state);
state->synctype = getFrameSync(opts, state);
// recalibrate center/umid/lmid
state->center = ((state->max) + (state->min)) / 2;
state->umid = (((state->max) - state->center) * 5 / 8) + state->center;
state->lmid = (((state->min) - state->center) * 5 / 8) + state->center;
while (state->synctype != -1)
while ((state->synctype != -1) && (state->dsd_running))
{
processFrame(opts, state);
#ifdef TRACE_DSD
state->debug_prefix = 'S';
#endif
state->synctype = getFrameSync(opts, state);
#ifdef TRACE_DSD
state->debug_prefix = '\0';
#endif
// recalibrate center/umid/lmid
state->center = ((state->max) + (state->min)) / 2;
state->umid = (((state->max) - state->center) * 5 / 8)
+ state->center;
state->lmid = (((state->min) - state->center) * 5 / 8)
+ state->center;
state->umid = (((state->max) - state->center) * 5 / 8) + state->center;
state->lmid = (((state->min) - state->center) * 5 / 8) + state->center;
}
}
}

Wyświetl plik

@ -25,202 +25,12 @@
#include "dmr_const.h"
#include "provoice_const.h"
#include "git_ver.h"
#include "dsd_nocarrier.h"
#include "dsd_comp.h"
int
comp (const void *a, const void *b)
{
if (*((const int *) a) == *((const int *) b))
return 0;
else if (*((const int *) a) < *((const int *) b))
return -1;
else
return 1;
}
void
noCarrier (dsd_opts * opts, dsd_state * state)
{
state->dibit_buf_p = state->dibit_buf + 200;
memset (state->dibit_buf, 0, sizeof (int) * 200);
if (opts->mbe_out_f != NULL)
{
closeMbeOutFile (opts, state);
}
state->jitter = -1;
state->lastsynctype = -1;
state->carrier = 0;
state->max = 15000;
state->min = -15000;
state->center = 0;
state->err_str[0] = 0;
sprintf (state->fsubtype, " ");
sprintf (state->ftype, " ");
state->errs = 0;
state->errs2 = 0;
state->lasttg = 0;
state->lastsrc = 0;
state->lastp25type = 0;
state->repeat = 0;
state->nac = 0;
state->numtdulc = 0;
sprintf (state->slot0light, " slot0 ");
sprintf (state->slot1light, " slot1 ");
state->firstframe = 0;
if (opts->audio_gain == (float) 0)
{
state->aout_gain = 25;
}
memset (state->aout_max_buf, 0, sizeof (float) * 200);
state->aout_max_buf_p = state->aout_max_buf;
state->aout_max_buf_idx = 0;
sprintf (state->algid, "________");
sprintf (state->keyid, "________________");
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
}
void
initOpts (dsd_opts * opts)
{
opts->onesymbol = 10;
opts->mbe_in_file[0] = 0;
opts->mbe_in_f = NULL;
opts->errorbars = 1;
opts->datascope = 0;
opts->symboltiming = 0;
opts->verbose = 2;
opts->p25enc = 0;
opts->p25lc = 0;
opts->p25status = 0;
opts->p25tg = 0;
opts->scoperate = 15;
sprintf (opts->audio_in_dev, "/dev/audio");
opts->audio_in_fd = -1;
sprintf (opts->audio_out_dev, "/dev/audio");
opts->audio_out_fd = -1;
opts->split = 0;
opts->playoffset = 0;
opts->mbe_out_dir[0] = 0;
opts->mbe_out_file[0] = 0;
opts->mbe_out_f = NULL;
opts->audio_gain = 0;
opts->audio_out = 1;
opts->wav_out_file[0] = 0;
opts->wav_out_f = NULL;
//opts->wav_out_fd = -1;
opts->serial_baud = 115200;
sprintf (opts->serial_dev, "/dev/ttyUSB0");
opts->resume = 0;
opts->frame_dstar = 0;
opts->frame_x2tdma = 1;
opts->frame_p25p1 = 1;
opts->frame_nxdn48 = 0;
opts->frame_nxdn96 = 1;
opts->frame_dmr = 1;
opts->frame_provoice = 0;
opts->mod_c4fm = 1;
opts->mod_qpsk = 1;
opts->mod_gfsk = 1;
opts->uvquality = 3;
opts->inverted_x2tdma = 1; // most transmitter + scanner + sound card combinations show inverted signals for this
opts->inverted_dmr = 0; // most transmitter + scanner + sound card combinations show non-inverted signals for this
opts->mod_threshold = 26;
opts->ssize = 36;
opts->msize = 15;
opts->playfiles = 0;
opts->delay = 0;
opts->use_cosine_filter = 1;
opts->unmute_encrypted_p25 = 0;
}
void
initState (dsd_state * state)
{
int i, j;
state->dibit_buf = malloc (sizeof (int) * 1000000);
state->dibit_buf_p = state->dibit_buf + 200;
memset (state->dibit_buf, 0, sizeof (int) * 200);
state->repeat = 0;
state->audio_out_buf = malloc (sizeof (short) * 1000000);
memset (state->audio_out_buf, 0, 100 * sizeof (short));
state->audio_out_buf_p = state->audio_out_buf + 100;
state->audio_out_float_buf = malloc (sizeof (float) * 1000000);
memset (state->audio_out_float_buf, 0, 100 * sizeof (float));
state->audio_out_float_buf_p = state->audio_out_float_buf + 100;
state->audio_out_idx = 0;
state->audio_out_idx2 = 0;
state->audio_out_temp_buf_p = state->audio_out_temp_buf;
//state->wav_out_bytes = 0;
state->center = 0;
state->jitter = -1;
state->synctype = -1;
state->min = -15000;
state->max = 15000;
state->lmid = 0;
state->umid = 0;
state->minref = -12000;
state->maxref = 12000;
state->lastsample = 0;
for (i = 0; i < 128; i++)
{
state->sbuf[i] = 0;
}
state->sidx = 0;
for (i = 0; i < 1024; i++)
{
state->maxbuf[i] = 15000;
}
for (i = 0; i < 1024; i++)
{
state->minbuf[i] = -15000;
}
state->midx = 0;
state->err_str[0] = 0;
sprintf (state->fsubtype, " ");
sprintf (state->ftype, " ");
state->symbolcnt = 0;
state->rf_mod = 0;
state->numflips = 0;
state->lastsynctype = -1;
state->lastp25type = 0;
state->offset = 0;
state->carrier = 0;
for (i = 0; i < 25; i++)
{
for (j = 0; j < 16; j++)
{
state->tg[i][j] = 48;
}
}
state->tgcount = 0;
state->lasttg = 0;
state->lastsrc = 0;
state->nac = 0;
state->errs = 0;
state->errs2 = 0;
state->mbe_file_type = -1;
state->optind = 0;
state->numtdulc = 0;
state->firstframe = 0;
sprintf (state->slot0light, " slot0 ");
sprintf (state->slot1light, " slot1 ");
state->aout_gain = 25;
memset (state->aout_max_buf, 0, sizeof (float) * 200);
state->aout_max_buf_p = state->aout_max_buf;
state->aout_max_buf_idx = 0;
state->samplesPerSymbol = 10;
state->symbolCenter = 4;
sprintf (state->algid, "________");
sprintf (state->keyid, "________________");
state->currentslot = 0;
state->cur_mp = malloc (sizeof (mbe_parms));
state->prev_mp = malloc (sizeof (mbe_parms));
state->prev_mp_enhanced = malloc (sizeof (mbe_parms));
mbe_initMbeParms (state->cur_mp, state->prev_mp, state->prev_mp_enhanced);
state->p25kid = 0;
}
static void usage ();
static void sigfun (int sig);
static int main (int argc, char **argv);
void
usage ()
@ -287,48 +97,6 @@ usage ()
exit (0);
}
void
liveScanner (dsd_opts * opts, dsd_state * state)
{
if (opts->audio_in_fd == -1)
{
if (pthread_mutex_lock(&state->input_mutex))
{
printf("liveScanner -> Unable to lock mutex\n");
}
}
while (1)
{
noCarrier (opts, state);
state->synctype = getFrameSync (opts, state);
// recalibrate center/umid/lmid
state->center = ((state->max) + (state->min)) / 2;
state->umid = (((state->max) - state->center) * 5 / 8) + state->center;
state->lmid = (((state->min) - state->center) * 5 / 8) + state->center;
while (state->synctype != -1)
{
processFrame (opts, state);
state->synctype = getFrameSync (opts, state);
// recalibrate center/umid/lmid
state->center = ((state->max) + (state->min)) / 2;
state->umid = (((state->max) - state->center) * 5 / 8) + state->center;
state->lmid = (((state->min) - state->center) * 5 / 8) + state->center;
}
}
}
void
cleanupAndExit (dsd_opts * opts, dsd_state * state)
{
noCarrier (opts, state);
if (opts->wav_out_f != NULL)
{
closeWavOutFile (opts, state);
}
printf ("Exiting.\n");
exit (0);
}
void
sigfun (int sig)
{

Wyświetl plik

@ -102,6 +102,14 @@ typedef struct
int unmute_encrypted_p25;
} dsd_opts;
#ifdef __cplusplus
extern "C" {
#endif
void initOpts (dsd_opts * opts);
#ifdef __cplusplus
}
#endif
#endif /* INCLUDE_DSD_OPTS_H_ */

Wyświetl plik

@ -111,6 +111,8 @@ void initState(dsd_state * state)
state->debug_header_errors = 0;
state->debug_header_critical_errors = 0;
state->exitflag = 0;
#ifdef TRACE_DSD
state->debug_sample_index = 0;
state->debug_label_file = NULL;

Wyświetl plik

@ -88,22 +88,48 @@ typedef struct
mbe_parms *prev_mp_enhanced;
int p25kid;
pthread_mutex_t input_mutex;
pthread_cond_t input_ready;
const float *input_samples;
int input_length;
int input_offset;
unsigned int debug_audio_errors;
unsigned int debug_header_errors;
unsigned int debug_header_critical_errors;
pthread_mutex_t output_mutex;
pthread_cond_t output_ready;
short *output_buffer;
int output_offset;
float *output_samples;
int output_num_samples;
int output_length;
int output_finished;
// Last dibit read
int last_dibit;
// Heuristics state data for +P5 signals
P25Heuristics p25_heuristics;
// Heuristics state data for -P5 signals
P25Heuristics inv_p25_heuristics;
int exitflag; // the former global that cannot be a global within SDRangel and is not of much use with it anyway
// New from original DSD for in-memory processing support with SDRangel:
pthread_mutex_t input_mutex; //!< mutex to communicate with input thread
pthread_cond_t input_ready; //!< signals that input demodulator samples are available for processing
const short *input_samples; //!< demodulator samples
int input_length; //!< 0: data not ready, >0: data ready for this amount of demodulator samples
int input_offset; //!< consumer pointer
pthread_mutex_t output_mutex; //!< mutex to communicate with output (audio) thread
pthread_cond_t output_ready; //!< signals that output audio samples are ready
short *output_buffer; //!< Output of decoder single S16LE
int output_offset; //!< producer pointer
short *output_samples; //!< L+R channels S16LE ready for writing to audio FIFO
int output_num_samples; //!< Number of L+R samples available in the above buffer
int output_length; //!< L+R buffer size (fixed)
int output_finished; //!< 0: not ready, 1: ready
int dsd_running; //!< True while DSD thread is running
} dsd_state;
#ifdef __cplusplus
extern "C" {
#endif
void initState (dsd_state * state);
#ifdef __cplusplus
}
#endif
#endif /* INCLUDE_DSD_STATE_H_ */

Wyświetl plik

@ -18,262 +18,299 @@
#include "dsd.h"
#include "dsd_cleanupexit.h"
int
getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
int getSymbol(dsd_opts * opts, dsd_state * state, int have_sync)
{
short sample;
int i, sum, symbol, count;
ssize_t result;
short sample;
int i, sum, symbol, count;
ssize_t result;
sum = 0;
count = 0;
for (i = 0; i < state->samplesPerSymbol; i++)
sum = 0;
count = 0;
for (i = 0; i < state->samplesPerSymbol; i++)
{
// timing control
if ((i == 0) && (have_sync == 0))
// timing control
if ((i == 0) && (have_sync == 0))
{
if (state->samplesPerSymbol == 20)
if (state->samplesPerSymbol == 20)
{
if ((state->jitter >= 7) && (state->jitter <= 10))
if ((state->jitter >= 7) && (state->jitter <= 10))
{
i--;
i--;
}
else if ((state->jitter >= 11) && (state->jitter <= 14))
else if ((state->jitter >= 11) && (state->jitter <= 14))
{
i++;
i++;
}
}
else if (state->rf_mod == 1)
else if (state->rf_mod == 1)
{
if ((state->jitter >= 0) && (state->jitter < state->symbolCenter))
if ((state->jitter >= 0) && (state->jitter < state->symbolCenter))
{
i++; // fall back
i++; // fall back
}
else if ((state->jitter > state->symbolCenter) && (state->jitter < 10))
else if ((state->jitter > state->symbolCenter) && (state->jitter < 10))
{
i--; // catch up
i--; // catch up
}
}
else if (state->rf_mod == 2)
else if (state->rf_mod == 2)
{
if ((state->jitter >= state->symbolCenter - 1) && (state->jitter <= state->symbolCenter))
if ((state->jitter >= state->symbolCenter - 1) && (state->jitter <= state->symbolCenter))
{
i--;
i--;
}
else if ((state->jitter >= state->symbolCenter + 1) && (state->jitter <= state->symbolCenter + 2))
else if ((state->jitter >= state->symbolCenter + 1) && (state->jitter <= state->symbolCenter + 2))
{
i++;
i++;
}
}
else if (state->rf_mod == 0)
else if (state->rf_mod == 0)
{
if ((state->jitter > 0) && (state->jitter <= state->symbolCenter))
if ((state->jitter > 0) && (state->jitter <= state->symbolCenter))
{
i--; // catch up
i--; // catch up
}
else if ((state->jitter > state->symbolCenter) && (state->jitter < state->samplesPerSymbol))
else if ((state->jitter > state->symbolCenter) && (state->jitter < state->samplesPerSymbol))
{
i++; // fall back
i++; // fall back
}
}
state->jitter = -1;
state->jitter = -1;
}
if(opts->audio_in_type == 0) {
if (opts->audio_in_fd == -1)
// get sample in and push samples out
if (opts->audio_in_type == 0)
{
if (opts->audio_in_fd == -1)
{
while (state->input_length == 0)
while (state->input_length == 0)
{
// If the buffer is empty, wait for more samples to arrive.
if (pthread_cond_wait(&state->input_ready, &state->input_mutex))
// If the buffer is empty, wait for more samples to arrive.
if (pthread_cond_wait(&state->input_ready, &state->input_mutex))
{
printf("getSymbol -> Error waiting for condition\n");
printf("getSymbol -> Error waiting for input condition\n");
}
}
// Get the next sample from the buffer, converting from float to short.
sample = (short) (state->input_samples[state->input_offset++] * 32768);
if (state->input_offset == state->input_length)
// Get the next sample from the buffer
sample = state->input_samples[state->input_offset++];
if (state->input_offset == state->input_length) // all available samples have been read
{
int i;
int i;
// We've reached the end of the buffer. Wait for more next time.
state->input_length = 0;
// We've reached the end of the buffer. Wait for more next time.
state->input_length = 0;
if (pthread_mutex_lock(&state->output_mutex))
// make output samples availabele
if (pthread_mutex_lock(&state->output_mutex))
{
printf("Unable to lock mutex\n");
printf("Unable to lock output mutex\n");
}
state->output_num_samples = state->output_offset;
if (state->output_num_samples > state->output_length) {
state->output_num_samples = state->output_length;
}
for (i = 0; i < state->output_length - state->output_num_samples; i++)
{
state->output_samples[i] = 0;
}
for (; i < state->output_length; i++)
{
state->output_samples[i] = state->output_buffer[i - (state->output_length - state->output_num_samples)] / 32768.0;
}
state->output_offset -= state->output_num_samples;
for (i = 0; i < state->output_offset; i++)
{
state->output_buffer[i] = state->output_buffer[i + state->output_num_samples];
}
state->output_finished = 1;
state->output_num_samples = state->output_offset;
// Wake up general_work
if (pthread_cond_signal(&state->output_ready))
// GNUradio drivel
// if (state->output_num_samples > state->output_length)
// {
// state->output_num_samples = state->output_length;
// }
//
// for (i = 0; i < state->output_length - state->output_num_samples; i++)
// {
// state->output_samples[i] = 0;
// }
//
// for (; i < state->output_length; i++)
// {
// state->output_samples[i] = state->output_buffer[i - (state->output_length - state->output_num_samples)] / 32768.0;
// }
//
// state->output_offset -= state->output_num_samples;
//
// for (i = 0; i < state->output_offset; i++)
// {
// state->output_buffer[i] = state->output_buffer[i + state->output_num_samples];
// }
if (state->output_num_samples > state->output_length)
{
printf("Unable to signal\n");
fprintf(stderr, "WARNING: audio buffer over-run! Truncating output");
state->output_num_samples = state->output_length;
}
if (pthread_mutex_unlock(&state->output_mutex))
for (i = 0; i < state->output_num_samples; i++)
{
printf("Unable to unlock mutex\n");
state->output_samples[2*i] = state->output_buffer[i]; // L channel
state->output_samples[2*i+1] = state->output_buffer[i]; // R channel
}
state->output_finished = 1;
// Wake up audio out thread
if (pthread_cond_signal(&state->output_ready))
{
printf("Unable to signal output ready\n");
}
if (pthread_mutex_unlock(&state->output_mutex))
{
printf("Unable to unlock output mutex\n");
}
}
}
else
else
{
result = read (opts->audio_in_fd, &sample, 2);
result = read(opts->audio_in_fd, &sample, 2);
}
}
}
#ifdef USE_LIBSNDFILE
else {
result = sf_read_short(opts->audio_in_file, &sample, 1);
if(result == 0) {
cleanupAndExit (opts, state);
}
}
else
{
result = sf_read_short(opts->audio_in_file, &sample, 1);
if(result == 0)
{
cleanupAndExit (opts, state);
}
}
#endif
// printf("res: %zd\n, offset: %lld", result, sf_seek(opts->audio_in_file, 0, SEEK_CUR));
if (opts->use_cosine_filter)
{
if (state->lastsynctype >= 10 && state->lastsynctype <= 13)
sample = dmr_filter(sample);
else if (state->lastsynctype == 8 || state->lastsynctype == 9 ||
state->lastsynctype == 16 || state->lastsynctype == 17)
sample = nxdn_filter(sample);
}
// printf("res: %zd\n, offset: %lld", result, sf_seek(opts->audio_in_file, 0, SEEK_CUR));
if ((sample > state->max) && (have_sync == 1) && (state->rf_mod == 0))
// process sample
if (opts->use_cosine_filter)
{
sample = state->max;
}
else if ((sample < state->min) && (have_sync == 1) && (state->rf_mod == 0))
{
sample = state->min;
}
if (sample > state->center)
{
if (state->lastsample < state->center)
if (state->lastsynctype >= 10 && state->lastsynctype <= 13)
{
state->numflips += 1;
sample = dmr_filter(sample);
}
if (sample > (state->maxref * 1.25))
else if (state->lastsynctype == 8 || state->lastsynctype == 9
|| state->lastsynctype == 16 || state->lastsynctype == 17)
{
if (state->lastsample < (state->maxref * 1.25))
sample = nxdn_filter(sample);
}
}
if ((sample > state->max) && (have_sync == 1) && (state->rf_mod == 0))
{
sample = state->max;
}
else if ((sample < state->min) && (have_sync == 1) && (state->rf_mod == 0))
{
sample = state->min;
}
if (sample > state->center)
{
if (state->lastsample < state->center)
{
state->numflips += 1;
}
if (sample > (state->maxref * 1.25))
{
if (state->lastsample < (state->maxref * 1.25))
{
state->numflips += 1;
state->numflips += 1;
}
if ((state->jitter < 0) && (state->rf_mod == 1))
if ((state->jitter < 0) && (state->rf_mod == 1))
{ // first spike out of place
state->jitter = i;
state->jitter = i;
}
if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1))
if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1))
{
printf ("O");
printf("O");
}
}
else
else
{
if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1))
if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1))
{
printf ("+");
printf("+");
}
if ((state->jitter < 0) && (state->lastsample < state->center) && (state->rf_mod != 1))
if ((state->jitter < 0) && (state->lastsample < state->center) && (state->rf_mod != 1))
{ // first transition edge
state->jitter = i;
state->jitter = i;
}
}
}
else
else
{ // sample < 0
if (state->lastsample > state->center)
if (state->lastsample > state->center)
{
state->numflips += 1;
state->numflips += 1;
}
if (sample < (state->minref * 1.25))
if (sample < (state->minref * 1.25))
{
if (state->lastsample > (state->minref * 1.25))
if (state->lastsample > (state->minref * 1.25))
{
state->numflips += 1;
state->numflips += 1;
}
if ((state->jitter < 0) && (state->rf_mod == 1))
if ((state->jitter < 0) && (state->rf_mod == 1))
{ // first spike out of place
state->jitter = i;
state->jitter = i;
}
if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1))
if ((opts->symboltiming == 1) && (have_sync == 0)
&& (state->lastsynctype != -1))
{
printf ("X");
printf("X");
}
}
else
else
{
if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1))
if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1))
{
printf ("-");
printf("-");
}
if ((state->jitter < 0) && (state->lastsample > state->center) && (state->rf_mod != 1))
if ((state->jitter < 0) && (state->lastsample > state->center) && (state->rf_mod != 1))
{ // first transition edge
state->jitter = i;
state->jitter = i;
}
}
}
if (state->samplesPerSymbol == 20)
if (state->samplesPerSymbol == 20)
{
if ((i >= 9) && (i <= 11))
if ((i >= 9) && (i <= 11))
{
sum += sample;
count++;
sum += sample;
count++;
}
}
if (state->samplesPerSymbol == 5)
if (state->samplesPerSymbol == 5)
{
if (i == 2)
if (i == 2)
{
sum += sample;
count++;
sum += sample;
count++;
}
}
else
else
{
if (((i >= state->symbolCenter - 1) && (i <= state->symbolCenter + 2) && (state->rf_mod == 0)) || (((i == state->symbolCenter) || (i == state->symbolCenter + 1)) && (state->rf_mod != 0)))
if (((i >= state->symbolCenter - 1) && (i <= state->symbolCenter + 2) && (state->rf_mod == 0)) || (((i == state->symbolCenter) || (i == state->symbolCenter + 1)) && (state->rf_mod != 0)))
{
sum += sample;
count++;
sum += sample;
count++;
}
}
state->lastsample = sample;
}
symbol = (sum / count);
if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1))
state->lastsample = sample;
} // for (i = 0; i < state->samplesPerSymbol; i++)
symbol = (sum / count);
if ((opts->symboltiming == 1) && (have_sync == 0) && (state->lastsynctype != -1))
{
if (state->jitter >= 0)
if (state->jitter >= 0)
{
printf (" %i\n", state->jitter);
printf(" %i\n", state->jitter);
}
else
else
{
printf ("\n");
printf("\n");
}
}
state->symbolcnt++;
return (symbol);
state->symbolcnt++;
return (symbol);
}

123
dsd/dstar_const.c 100644
Wyświetl plik

@ -0,0 +1,123 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* dstar interleave experiments
*/
#include "dstar_const.h"
const int dW[72] = {
// 0-11
0, 0,
3, 2,
1, 1,
0, 0,
1, 1,
0, 0,
// 12-23
3, 2,
1, 1,
3, 2,
1, 1,
0, 0,
3, 2,
// 24-35
0, 0,
3, 2,
1, 1,
0, 0,
1, 1,
0, 0,
// 36-47
3, 2,
1, 1,
3, 2,
1, 1,
0, 0,
3, 2,
// 48-59
0, 0,
3, 2,
1, 1,
0, 0,
1, 1,
0, 0,
// 60-71
3, 2,
1, 1,
3, 3,
2, 1,
0, 0,
3, 3,
};
const int dX[72] = {
// 0-11
10, 22,
11, 9,
10, 22,
11, 23,
8, 20,
9, 21,
// 12-23
10, 8,
9, 21,
8, 6,
7, 19,
8, 20,
9, 7,
// 24-35
6, 18,
7, 5,
6, 18,
7, 19,
4, 16,
5, 17,
// 36-47
6, 4,
5, 17,
4, 2,
3, 15,
4, 16,
5, 3,
// 48-59
2, 14,
3, 1,
2, 14,
3, 15,
0, 12,
1, 13,
// 60-71
2, 0,
1, 13,
0, 12,
10, 11,
0, 12,
1, 13,
};

Wyświetl plik

@ -16,114 +16,114 @@
*/
/*
* dstar interleave experiments
* dstar interleave experiments
*/
#ifndef _MAIN
//#ifndef _MAIN
extern const int dW[72];
extern const int dX[72];
#else
const int dW[72] = {
//#else
//const int dW[72] = {
//
// // 0-11
// 0, 0,
// 3, 2,
// 1, 1,
// 0, 0,
// 1, 1,
// 0, 0,
//
// // 12-23
// 3, 2,
// 1, 1,
// 3, 2,
// 1, 1,
// 0, 0,
// 3, 2,
//
// // 24-35
// 0, 0,
// 3, 2,
// 1, 1,
// 0, 0,
// 1, 1,
// 0, 0,
//
// // 36-47
// 3, 2,
// 1, 1,
// 3, 2,
// 1, 1,
// 0, 0,
// 3, 2,
//
// // 48-59
// 0, 0,
// 3, 2,
// 1, 1,
// 0, 0,
// 1, 1,
// 0, 0,
//
// // 60-71
// 3, 2,
// 1, 1,
// 3, 3,
// 2, 1,
// 0, 0,
// 3, 3,
//};
//const int dX[72] = {
//
// // 0-11
// 10, 22,
// 11, 9,
// 10, 22,
// 11, 23,
// 8, 20,
// 9, 21,
//
// // 12-23
// 10, 8,
// 9, 21,
// 8, 6,
// 7, 19,
// 8, 20,
// 9, 7,
//
// // 24-35
// 6, 18,
// 7, 5,
// 6, 18,
// 7, 19,
// 4, 16,
// 5, 17,
//
// // 36-47
// 6, 4,
// 5, 17,
// 4, 2,
// 3, 15,
// 4, 16,
// 5, 3,
//
// // 48-59
// 2, 14,
// 3, 1,
// 2, 14,
// 3, 15,
// 0, 12,
// 1, 13,
//
// // 60-71
// 2, 0,
// 1, 13,
// 0, 12,
// 10, 11,
// 0, 12,
// 1, 13,
//};
// 0-11
0, 0,
3, 2,
1, 1,
0, 0,
1, 1,
0, 0,
// 12-23
3, 2,
1, 1,
3, 2,
1, 1,
0, 0,
3, 2,
// 24-35
0, 0,
3, 2,
1, 1,
0, 0,
1, 1,
0, 0,
// 36-47
3, 2,
1, 1,
3, 2,
1, 1,
0, 0,
3, 2,
// 48-59
0, 0,
3, 2,
1, 1,
0, 0,
1, 1,
0, 0,
// 60-71
3, 2,
1, 1,
3, 3,
2, 1,
0, 0,
3, 3,
};
const int dX[72] = {
// 0-11
10, 22,
11, 9,
10, 22,
11, 23,
8, 20,
9, 21,
// 12-23
10, 8,
9, 21,
8, 6,
7, 19,
8, 20,
9, 7,
// 24-35
6, 18,
7, 5,
6, 18,
7, 19,
4, 16,
5, 17,
// 36-47
6, 4,
5, 17,
4, 2,
3, 15,
4, 16,
5, 3,
// 48-59
2, 14,
3, 1,
2, 14,
3, 15,
0, 12,
1, 13,
// 60-71
2, 0,
1, 13,
0, 12,
10, 11,
0, 12,
1, 13,
};
#endif
//#endif

Wyświetl plik

@ -35,10 +35,10 @@ processNXDN96 (dsd_opts * opts, dsd_state * state)
{
for (j = 0; j < 4; j++)
{
w = nW;
x = nX;
y = nY;
z = nZ;
w = n96W;
x = n96X;
y = n96Y;
z = n96Z;
for (i = 0; i < 36; i++)
{
dibit = getDibit (opts, state);
@ -62,10 +62,10 @@ processNXDN96 (dsd_opts * opts, dsd_state * state)
{
for (j = 0; j < 3; j++) // we skip the last voice frame until frame sync can work with < 24 symbols
{
w = nW;
x = nX;
y = nY;
z = nZ;
w = n96W;
x = n96X;
y = n96Y;
z = n96Z;
for (i = 0; i < 36; i++)
{
dibit = getDibit (opts, state);

55
dsd/nxdn96_const.c 100644
Wyświetl plik

@ -0,0 +1,55 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* NXDN AMBE interleave schedule
*/
#include "nxdn96_const.h"
const int n96W[36] = { 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
const int n96X[36] = { 23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
const int n96Y[36] = { 0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int n96Z[36] = { 5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};

Wyświetl plik

@ -19,44 +19,44 @@
* NXDN AMBE interleave schedule
*/
#ifndef _MAIN
extern const int nW[36];
extern const int nX[36];
extern const int nY[36];
extern const int nZ[36];
//#ifndef _MAIN
extern const int n96W[36];
extern const int n96X[36];
extern const int n96Y[36];
extern const int n96Z[36];
#else
//#else
//
//const int nW[36] = { 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 2,
// 0, 2, 0, 2, 0, 2,
// 0, 2, 0, 2, 0, 2
//};
//
//const int nX[36] = { 23, 10, 22, 9, 21, 8,
// 20, 7, 19, 6, 18, 5,
// 17, 4, 16, 3, 15, 2,
// 14, 1, 13, 0, 12, 10,
// 11, 9, 10, 8, 9, 7,
// 8, 6, 7, 5, 6, 4
//};
//
//const int nY[36] = { 0, 2, 0, 2, 0, 2,
// 0, 2, 0, 3, 0, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3
//};
//
//const int nZ[36] = { 5, 3, 4, 2, 3, 1,
// 2, 0, 1, 13, 0, 12,
// 22, 11, 21, 10, 20, 9,
// 19, 8, 18, 7, 17, 6,
// 16, 5, 15, 4, 14, 3,
// 13, 2, 12, 1, 11, 0
//};
const int nW[36] = { 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
const int nX[36] = { 23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
const int nY[36] = { 0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int nZ[36] = { 5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};
#endif
//#endif

58
dsd/nxdn_const.c 100644
Wyświetl plik

@ -0,0 +1,58 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "nxdn_const.h"
/*
* pseudorandom bit sequence
*/
const char nxdnpr[145] = { 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1 };
/*
* NXDN AMBE interleave schedule
*/
const int nW[36] = { 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
const int nX[36] = { 23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
const int nY[36] = { 0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int nZ[36] = { 5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};

Wyświetl plik

@ -15,52 +15,52 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _MAIN
//#ifndef _MAIN
extern const int nW[36];
extern const int nX[36];
extern const int nY[36];
extern const int nZ[36];
extern const char nxdnpr[145];
#else
/*
* pseudorandom bit sequence
*/
const char nxdnpr[145] = { 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1 };
//#else
///*
// * pseudorandom bit sequence
// */
//const char nxdnpr[145] = { 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1 };
//
///*
// * NXDN AMBE interleave schedule
// */
//const int nW[36] = { 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 2,
// 0, 2, 0, 2, 0, 2,
// 0, 2, 0, 2, 0, 2
//};
//
//const int nX[36] = { 23, 10, 22, 9, 21, 8,
// 20, 7, 19, 6, 18, 5,
// 17, 4, 16, 3, 15, 2,
// 14, 1, 13, 0, 12, 10,
// 11, 9, 10, 8, 9, 7,
// 8, 6, 7, 5, 6, 4
//};
//
//const int nY[36] = { 0, 2, 0, 2, 0, 2,
// 0, 2, 0, 3, 0, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3
//};
//
//const int nZ[36] = { 5, 3, 4, 2, 3, 1,
// 2, 0, 1, 13, 0, 12,
// 22, 11, 21, 10, 20, 9,
// 19, 8, 18, 7, 17, 6,
// 16, 5, 15, 4, 14, 3,
// 13, 2, 12, 1, 11, 0
//};
/*
* NXDN AMBE interleave schedule
*/
const int nW[36] = { 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
const int nX[36] = { 23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
const int nY[36] = { 0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int nZ[36] = { 5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};
#endif
//#endif

82
dsd/p25p1_const.c 100644
Wyświetl plik

@ -0,0 +1,82 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "p25p1_const.h"
/*
* P25 Phase1 IMBE interleave schedule
*/
const int iW[72] = {
0, 2, 4, 1, 3, 5,
0, 2, 4, 1, 3, 6,
0, 2, 4, 1, 3, 6,
0, 2, 4, 1, 3, 6,
0, 2, 4, 1, 3, 6,
0, 2, 4, 1, 3, 6,
0, 2, 5, 1, 3, 6,
0, 2, 5, 1, 3, 6,
0, 2, 5, 1, 3, 7,
0, 2, 5, 1, 3, 7,
0, 2, 5, 1, 4, 7,
0, 3, 5, 2, 4, 7
};
const int iX[72] = {
22, 20, 10, 20, 18, 0,
20, 18, 8, 18, 16, 13,
18, 16, 6, 16, 14, 11,
16, 14, 4, 14, 12, 9,
14, 12, 2, 12, 10, 7,
12, 10, 0, 10, 8, 5,
10, 8, 13, 8, 6, 3,
8, 6, 11, 6, 4, 1,
6, 4, 9, 4, 2, 6,
4, 2, 7, 2, 0, 4,
2, 0, 5, 0, 13, 2,
0, 21, 3, 21, 11, 0
};
const int iY[72] = {
1, 3, 5, 0, 2, 4,
1, 3, 6, 0, 2, 4,
1, 3, 6, 0, 2, 4,
1, 3, 6, 0, 2, 4,
1, 3, 6, 0, 2, 4,
1, 3, 6, 0, 2, 5,
1, 3, 6, 0, 2, 5,
1, 3, 6, 0, 2, 5,
1, 3, 6, 0, 2, 5,
1, 3, 7, 0, 2, 5,
1, 4, 7, 0, 3, 5,
2, 4, 7, 1, 3, 5
};
const int iZ[72] = {
21, 19, 1, 21, 19, 9,
19, 17, 14, 19, 17, 7,
17, 15, 12, 17, 15, 5,
15, 13, 10, 15, 13, 3,
13, 11, 8, 13, 11, 1,
11, 9, 6, 11, 9, 14,
9, 7, 4, 9, 7, 12,
7, 5, 2, 7, 5, 10,
5, 3, 0, 5, 3, 8,
3, 1, 5, 3, 1, 6,
1, 14, 3, 1, 22, 4,
22, 12, 1, 22, 20, 2
};

Wyświetl plik

@ -15,75 +15,75 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _MAIN
//#ifndef _MAIN
extern const int iW[72];
extern const int iX[72];
extern const int iY[72];
extern const int iZ[72];
#else
/*
* P25 Phase1 IMBE interleave schedule
*/
const int iW[72] = {
0, 2, 4, 1, 3, 5,
0, 2, 4, 1, 3, 6,
0, 2, 4, 1, 3, 6,
0, 2, 4, 1, 3, 6,
0, 2, 4, 1, 3, 6,
0, 2, 4, 1, 3, 6,
0, 2, 5, 1, 3, 6,
0, 2, 5, 1, 3, 6,
0, 2, 5, 1, 3, 7,
0, 2, 5, 1, 3, 7,
0, 2, 5, 1, 4, 7,
0, 3, 5, 2, 4, 7
};
const int iX[72] = {
22, 20, 10, 20, 18, 0,
20, 18, 8, 18, 16, 13,
18, 16, 6, 16, 14, 11,
16, 14, 4, 14, 12, 9,
14, 12, 2, 12, 10, 7,
12, 10, 0, 10, 8, 5,
10, 8, 13, 8, 6, 3,
8, 6, 11, 6, 4, 1,
6, 4, 9, 4, 2, 6,
4, 2, 7, 2, 0, 4,
2, 0, 5, 0, 13, 2,
0, 21, 3, 21, 11, 0
};
const int iY[72] = {
1, 3, 5, 0, 2, 4,
1, 3, 6, 0, 2, 4,
1, 3, 6, 0, 2, 4,
1, 3, 6, 0, 2, 4,
1, 3, 6, 0, 2, 4,
1, 3, 6, 0, 2, 5,
1, 3, 6, 0, 2, 5,
1, 3, 6, 0, 2, 5,
1, 3, 6, 0, 2, 5,
1, 3, 7, 0, 2, 5,
1, 4, 7, 0, 3, 5,
2, 4, 7, 1, 3, 5
};
const int iZ[72] = {
21, 19, 1, 21, 19, 9,
19, 17, 14, 19, 17, 7,
17, 15, 12, 17, 15, 5,
15, 13, 10, 15, 13, 3,
13, 11, 8, 13, 11, 1,
11, 9, 6, 11, 9, 14,
9, 7, 4, 9, 7, 12,
7, 5, 2, 7, 5, 10,
5, 3, 0, 5, 3, 8,
3, 1, 5, 3, 1, 6,
1, 14, 3, 1, 22, 4,
22, 12, 1, 22, 20, 2
};
#endif
//#else
///*
// * P25 Phase1 IMBE interleave schedule
// */
//
//const int iW[72] = {
// 0, 2, 4, 1, 3, 5,
// 0, 2, 4, 1, 3, 6,
// 0, 2, 4, 1, 3, 6,
// 0, 2, 4, 1, 3, 6,
// 0, 2, 4, 1, 3, 6,
// 0, 2, 4, 1, 3, 6,
// 0, 2, 5, 1, 3, 6,
// 0, 2, 5, 1, 3, 6,
// 0, 2, 5, 1, 3, 7,
// 0, 2, 5, 1, 3, 7,
// 0, 2, 5, 1, 4, 7,
// 0, 3, 5, 2, 4, 7
//};
//
//const int iX[72] = {
// 22, 20, 10, 20, 18, 0,
// 20, 18, 8, 18, 16, 13,
// 18, 16, 6, 16, 14, 11,
// 16, 14, 4, 14, 12, 9,
// 14, 12, 2, 12, 10, 7,
// 12, 10, 0, 10, 8, 5,
// 10, 8, 13, 8, 6, 3,
// 8, 6, 11, 6, 4, 1,
// 6, 4, 9, 4, 2, 6,
// 4, 2, 7, 2, 0, 4,
// 2, 0, 5, 0, 13, 2,
// 0, 21, 3, 21, 11, 0
//};
//
//const int iY[72] = {
// 1, 3, 5, 0, 2, 4,
// 1, 3, 6, 0, 2, 4,
// 1, 3, 6, 0, 2, 4,
// 1, 3, 6, 0, 2, 4,
// 1, 3, 6, 0, 2, 4,
// 1, 3, 6, 0, 2, 5,
// 1, 3, 6, 0, 2, 5,
// 1, 3, 6, 0, 2, 5,
// 1, 3, 6, 0, 2, 5,
// 1, 3, 7, 0, 2, 5,
// 1, 4, 7, 0, 3, 5,
// 2, 4, 7, 1, 3, 5
//};
//
//const int iZ[72] = {
// 21, 19, 1, 21, 19, 9,
// 19, 17, 14, 19, 17, 7,
// 17, 15, 12, 17, 15, 5,
// 15, 13, 10, 15, 13, 3,
// 13, 11, 8, 13, 11, 1,
// 11, 9, 6, 11, 9, 14,
// 9, 7, 4, 9, 7, 12,
// 7, 5, 2, 7, 5, 10,
// 5, 3, 0, 5, 3, 8,
// 3, 1, 5, 3, 1, 6,
// 1, 14, 3, 1, 22, 4,
// 22, 12, 1, 22, 20, 2
//};
//#endif

Wyświetl plik

@ -0,0 +1,76 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "provoice_const.h"
/*
* ProVoice IMBE interleave schedule
*/
const int pW[142] = {
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 3, 4, 5, 6,
1, 2, 3, 4, 5, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
1, 2, 3, 4, 5, 6,
1, 2, 3, 4, 5,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 4, 5, 6,
1, 2, 3, 4, 5, 6,
1, 2, 3, 4, 6
};
const int pX[142] = {
18, 18, 17, 16, 7, 21,
15, 15, 14, 13, 4, 18,
12, 12, 11, 10, 1, 15,
9, 9, 8, 7, 13, 12,
6, 6, 5, 4, 10, 9,
3, 3, 2, 1, 7, 6,
0, 0, 22, 13, 4, 3,
21, 20, 19, 10, 1, 0,
17, 17, 16, 15, 6, 20,
14, 14, 13, 12, 3, 17,
11, 11, 10, 9, 0, 14,
8, 8, 7, 6, 12, 11,
5, 5, 4, 3, 9, 8,
2, 2, 1, 0, 6, 5,
23, 22, 21, 12, 3, 2,
20, 19, 18, 9, 0,
16, 16, 15, 14, 5, 19,
13, 13, 12, 11, 2, 16,
10, 10, 9, 8, 14, 13,
7, 7, 6, 5, 11, 10,
4, 4, 3, 2, 8, 7,
1, 1, 0, 14, 5, 4,
22, 21, 20, 11, 2, 1,
19, 18, 17, 8, 22
};

Wyświetl plik

@ -15,67 +15,67 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _MAIN
//#ifndef _MAIN
extern const int pW[142];
extern const int pX[142];
#else
/*
* ProVoice IMBE interleave schedule
*/
const int pW[142] = {
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 3, 4, 5, 6,
1, 2, 3, 4, 5, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
1, 2, 3, 4, 5, 6,
1, 2, 3, 4, 5,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 4, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 3, 5, 6,
0, 1, 2, 4, 5, 6,
1, 2, 3, 4, 5, 6,
1, 2, 3, 4, 6
};
const int pX[142] = {
18, 18, 17, 16, 7, 21,
15, 15, 14, 13, 4, 18,
12, 12, 11, 10, 1, 15,
9, 9, 8, 7, 13, 12,
6, 6, 5, 4, 10, 9,
3, 3, 2, 1, 7, 6,
0, 0, 22, 13, 4, 3,
21, 20, 19, 10, 1, 0,
17, 17, 16, 15, 6, 20,
14, 14, 13, 12, 3, 17,
11, 11, 10, 9, 0, 14,
8, 8, 7, 6, 12, 11,
5, 5, 4, 3, 9, 8,
2, 2, 1, 0, 6, 5,
23, 22, 21, 12, 3, 2,
20, 19, 18, 9, 0,
16, 16, 15, 14, 5, 19,
13, 13, 12, 11, 2, 16,
10, 10, 9, 8, 14, 13,
7, 7, 6, 5, 11, 10,
4, 4, 3, 2, 8, 7,
1, 1, 0, 14, 5, 4,
22, 21, 20, 11, 2, 1,
19, 18, 17, 8, 22
};
#endif
//#else
///*
// * ProVoice IMBE interleave schedule
// */
//
//const int pW[142] = {
// 0, 1, 2, 3, 4, 6,
// 0, 1, 2, 3, 4, 6,
// 0, 1, 2, 3, 4, 6,
// 0, 1, 2, 3, 5, 6,
// 0, 1, 2, 3, 5, 6,
// 0, 1, 2, 3, 5, 6,
// 0, 1, 3, 4, 5, 6,
// 1, 2, 3, 4, 5, 6,
// 0, 1, 2, 3, 4, 6,
// 0, 1, 2, 3, 4, 6,
// 0, 1, 2, 3, 4, 6,
// 0, 1, 2, 3, 5, 6,
// 0, 1, 2, 3, 5, 6,
// 0, 1, 2, 3, 5, 6,
// 1, 2, 3, 4, 5, 6,
// 1, 2, 3, 4, 5,
// 0, 1, 2, 3, 4, 6,
// 0, 1, 2, 3, 4, 6,
// 0, 1, 2, 3, 5, 6,
// 0, 1, 2, 3, 5, 6,
// 0, 1, 2, 3, 5, 6,
// 0, 1, 2, 4, 5, 6,
// 1, 2, 3, 4, 5, 6,
// 1, 2, 3, 4, 6
//};
//
//const int pX[142] = {
// 18, 18, 17, 16, 7, 21,
// 15, 15, 14, 13, 4, 18,
// 12, 12, 11, 10, 1, 15,
// 9, 9, 8, 7, 13, 12,
// 6, 6, 5, 4, 10, 9,
// 3, 3, 2, 1, 7, 6,
// 0, 0, 22, 13, 4, 3,
// 21, 20, 19, 10, 1, 0,
// 17, 17, 16, 15, 6, 20,
// 14, 14, 13, 12, 3, 17,
// 11, 11, 10, 9, 0, 14,
// 8, 8, 7, 6, 12, 11,
// 5, 5, 4, 3, 9, 8,
// 2, 2, 1, 0, 6, 5,
// 23, 22, 21, 12, 3, 2,
// 20, 19, 18, 9, 0,
// 16, 16, 15, 14, 5, 19,
// 13, 13, 12, 11, 2, 16,
// 10, 10, 9, 8, 14, 13,
// 7, 7, 6, 5, 11, 10,
// 4, 4, 3, 2, 8, 7,
// 1, 1, 0, 14, 5, 4,
// 22, 21, 20, 11, 2, 1,
// 19, 18, 17, 8, 22
//};
//#endif

54
dsd/x2tdma_const.c 100644
Wyświetl plik

@ -0,0 +1,54 @@
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* X2TDMA AMBE interleave schedule
*/
#include "x2tdma_const.h"
const int aW[36] = { 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
const int aX[36] = { 23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
const int aY[36] = { 0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int aZ[36] = { 5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};

Wyświetl plik

@ -19,44 +19,44 @@
* X2TDMA AMBE interleave schedule
*/
#ifndef _MAIN
//#ifndef _MAIN
extern const int aW[36];
extern const int aX[36];
extern const int aY[36];
extern const int aZ[36];
#else
const int aW[36] = { 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
const int aX[36] = { 23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
const int aY[36] = { 0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int aZ[36] = { 5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};
#endif
//#else
//
//const int aW[36] = { 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 1,
// 0, 1, 0, 1, 0, 2,
// 0, 2, 0, 2, 0, 2,
// 0, 2, 0, 2, 0, 2
//};
//
//const int aX[36] = { 23, 10, 22, 9, 21, 8,
// 20, 7, 19, 6, 18, 5,
// 17, 4, 16, 3, 15, 2,
// 14, 1, 13, 0, 12, 10,
// 11, 9, 10, 8, 9, 7,
// 8, 6, 7, 5, 6, 4
//};
//
//const int aY[36] = { 0, 2, 0, 2, 0, 2,
// 0, 2, 0, 3, 0, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3,
// 1, 3, 1, 3, 1, 3
//};
//
//const int aZ[36] = { 5, 3, 4, 2, 3, 1,
// 2, 0, 1, 13, 0, 12,
// 22, 11, 21, 10, 20, 9,
// 19, 8, 18, 7, 17, 6,
// 16, 5, 15, 4, 14, 3,
// 13, 2, 12, 1, 11, 0
//};
//
//#endif

Wyświetl plik

@ -4,12 +4,14 @@ set(dsddemod_SOURCES
dsddemod.cpp
dsddemodgui.cpp
dsddemodplugin.cpp
dsddecoder.cpp
)
set(dsddemod_HEADERS
dsddemod.h
dsddemodgui.h
dsddemodplugin.h
dsddecoder.h
)
set(dsddemod_FORMS
@ -18,7 +20,9 @@ set(dsddemod_FORMS
include_directories(
.
../../../dsd
${CMAKE_CURRENT_BINARY_DIR}
${LIBMBE_INCLUDE_DIR}
)
#include(${QT_USE_FILE})
@ -37,6 +41,8 @@ add_library(demoddsd SHARED
target_link_libraries(demoddsd
${QT_LIBRARIES}
sdrbase
dsd
${LIBMBE_LIBRARY}
)
qt5_use_modules(demoddsd Core Widgets OpenGL Multimedia)

Wyświetl plik

@ -0,0 +1,169 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 F4EXB //
// written by Edouard Griffiths //
// //
// 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 <QtGlobal>
#include "dsddecoder.h"
#include "dsd_livescanner.h"
DSDDecoder::DSDDecoder()
{
initOpts(&m_dsdParams.opts);
initState(&m_dsdParams.state);
m_dsdParams.opts.split = 1;
m_dsdParams.opts.playoffset = 0;
m_dsdParams.opts.delay = 0;
m_dsdParams.opts.audio_in_type = 0;
m_dsdParams.opts.audio_out_type = 0;
// Initialize with auto-detect:
m_dsdParams.opts.frame_dstar = 1;
m_dsdParams.opts.frame_x2tdma = 1;
m_dsdParams.opts.frame_p25p1 = 1;
m_dsdParams.opts.frame_nxdn48 = 0;
m_dsdParams.opts.frame_nxdn96 = 1;
m_dsdParams.opts.frame_dmr = 1;
m_dsdParams.opts.frame_provoice = 0;
m_dsdParams.opts.uvquality = 3; // This is gr-dsd default
m_dsdParams.opts.verbose = 2; // This is gr-dsd default
m_dsdParams.opts.errorbars = 1; // This is gr-dsd default
// Initialize with auto detection of modulation optimization:
m_dsdParams.opts.mod_c4fm = 1;
m_dsdParams.opts.mod_qpsk = 1;
m_dsdParams.opts.mod_gfsk = 1;
m_dsdParams.state.rf_mod = 0;
// Initialize the conditions
if(pthread_cond_init(&m_dsdParams.state.input_ready, NULL))
{
qCritical("DSDDecoder::DSDDecoder: Unable to initialize input condition");
}
if(pthread_cond_init(&m_dsdParams.state.output_ready, NULL))
{
qCritical("DSDDecoder::DSDDecoder: Unable to initialize output condition");
}
m_dsdParams.state.input_length = 0;
m_dsdParams.state.input_offset = 0;
// Lock output mutex
if (pthread_mutex_lock(&m_dsdParams.state.output_mutex))
{
qCritical("DSDDecoder::DSDDecoder: Unable to lock output mutex");
}
m_dsdParams.state.output_buffer = (short *) malloc(1<<18); // Raw output buffer with single S16LE samples @ 8k (max: 128 kS)
m_dsdParams.state.output_offset = 0;
if (m_dsdParams.state.output_buffer == NULL)
{
qCritical("DSDDecoder::DSDDecoder: Unable to allocate output raw buffer.");
}
m_dsdParams.state.output_samples = (short *) malloc(1<<19); // Audio output buffer with L+R S16LE samples (max: 128 kS)
m_dsdParams.state.output_length = 1<<19; // the buffer size fixed
if (m_dsdParams.state.output_samples == NULL)
{
qCritical("DSDDecoder::DSDDecoder: Unable to allocate audio L+R buffer.");
}
m_dsdThread = pthread_self(); // dummy initialization
m_dsdParams.state.dsd_running = 0; // wait for start()
}
DSDDecoder::~DSDDecoder()
{
stop();
// Unlock output mutex
if (pthread_mutex_unlock(&m_dsdParams.state.output_mutex))
{
qCritical("DSDDecoder::~DSDDecoder: Unable to unlock output mutex");
}
free(m_dsdParams.state.output_samples);
free(m_dsdParams.state.output_buffer);
}
void DSDDecoder::setInBuffer(const short *inBuffer)
{
m_dsdParams.state.input_samples = inBuffer;
}
void DSDDecoder::pushSamples(int nbSamples)
{
if (pthread_mutex_lock(&m_dsdParams.state.input_mutex))
{
qCritical("DSDDecoder::pushSamples: Unable to lock input mutex");
}
m_dsdParams.state.input_length = nbSamples;
m_dsdParams.state.input_offset = 0;
if (pthread_cond_signal(&m_dsdParams.state.input_ready))
{
qCritical("DSDDecoder::pushSamples: Unable to signal input ready");
}
if (pthread_mutex_unlock(&m_dsdParams.state.input_mutex))
{
qCritical("DSDDecoder::pushSamples: Unable to unlock input mutex");
}
}
void DSDDecoder::start()
{
if (m_dsdParams.state.dsd_running == 1)
{
m_dsdParams.state.dsd_running = 0;
if (pthread_join(m_dsdThread, NULL)) {
qCritical("DSDDecoder::start: error joining DSD thread. Not starting");
return;
}
}
m_dsdParams.state.dsd_running = 1;
if (pthread_create(&m_dsdThread, NULL, &run_dsd, &m_dsdParams))
{
qCritical("DSDDecoder::start: Unable to spawn DSD thread");
}
}
void DSDDecoder::stop()
{
if (m_dsdParams.state.dsd_running == 1)
{
m_dsdParams.state.dsd_running = 0;
if (pthread_join(m_dsdThread, NULL)) {
qCritical("DSDDecoder::stop: error joining DSD thread. Not starting");
}
}
}
void* DSDDecoder::run_dsd (void *arg)
{
dsd_params *params = (dsd_params *) arg;
liveScanner(&params->opts, &params->state);
return NULL;
}

Wyświetl plik

@ -0,0 +1,53 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 F4EXB //
// written by Edouard Griffiths //
// //
// 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 PLUGINS_CHANNEL_DEMODDSD_DSDDECODER_H_
#define PLUGINS_CHANNEL_DEMODDSD_DSDDECODER_H_
#include "dsd.h"
class DSDDecoder
{
public:
DSDDecoder();
~DSDDecoder();
void setInBuffer(const short *inBuffer);
void pushSamples(int nbSamples); // Push this amount of samples to the DSD decoder thread
void start();
void stop();
static void* run_dsd (void *arg);
private:
typedef struct
{
dsd_opts opts;
dsd_state state;
} dsd_params;
dsd_params m_dsdParams;
// dsd_opts m_dsdOpts;
// dsd_state m_dsdState;
pthread_t m_dsdThread;
};
#endif /* PLUGINS_CHANNEL_DEMODDSD_DSDDECODER_H_ */

Wyświetl plik

@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// Copyright (C) 2015 F4EXB //
// written by Edouard Griffiths //
// //
// 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 //
@ -41,10 +41,14 @@ DSDDemod::DSDDemod(SampleSink* sampleSink) :
m_fmExcursion(24),
m_settingsMutex(QMutex::Recursive),
m_scope(sampleSink),
m_scopeEnabled(true)
m_scopeEnabled(true),
m_dsdDecoder()
{
setObjectName("DSDDemod");
m_dsdInBuffer = new qint16[1<<18]; // 128 k Samples is the maximum size of all input devices sample buffers (Airspy or HackRF) = 2^(17+1) for 2 byte samples
m_dsdDecoder.setInBuffer(m_dsdInBuffer);
m_config.m_inputSampleRate = 96000;
m_config.m_inputFrequencyOffset = 0;
m_config.m_rfBandwidth = 100;
@ -72,6 +76,7 @@ DSDDemod::DSDDemod(SampleSink* sampleSink) :
DSDDemod::~DSDDemod()
{
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
delete[] m_dsdInBuffer;
}
void DSDDemod::configure(MessageQueue* messageQueue,
@ -98,6 +103,7 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
Complex ci;
m_settingsMutex.lock();
m_dsdInCount = 0;
m_scopeSampleBuffer.clear();
for (SampleVector::const_iterator it = begin; it != end; ++it)
@ -141,8 +147,9 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
sample = 0;
}
Sample s(demod, 0.0);
Sample s(sample, 0.0);
m_scopeSampleBuffer.push_back(s);
m_dsdInBuffer[m_dsdInCount++] = sample;
m_audioBuffer[m_audioBufferFill].l = sample;
m_audioBuffer[m_audioBufferFill].r = sample;
@ -177,6 +184,11 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
m_audioBufferFill = 0;
}
if (m_dsdInCount > 0)
{
m_dsdDecoder.pushSamples(m_dsdInCount);
}
if((m_scope != 0) && (m_scopeEnabled))
{
m_scope->feed(m_scopeSampleBuffer.begin(), m_scopeSampleBuffer.end(), true); // true = real samples for what it's worth
@ -189,10 +201,12 @@ void DSDDemod::start()
{
m_audioFifo.clear();
m_phaseDiscri.reset();
m_dsdDecoder.start();
}
void DSDDemod::stop()
{
m_dsdDecoder.stop();
}
bool DSDDemod::handleMessage(const Message& cmd)

Wyświetl plik

@ -1,3 +1,20 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 F4EXB //
// written by Edouard Griffiths //
// //
// 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 INCLUDE_DSDDEMOD_H
#define INCLUDE_DSDDEMOD_H
@ -14,6 +31,7 @@
#include "dsp/afsquelch.h"
#include "audio/audiofifo.h"
#include "util/message.h"
#include "dsddecoder.h"
class DSDDemodGUI;
@ -154,6 +172,8 @@ private:
Real m_fmExcursion;
qint16 *m_dsdInBuffer; //!< Input buffer for DSD decoder process
int m_dsdInCount;
SampleVector m_scopeSampleBuffer;
AudioVector m_audioBuffer;
uint m_audioBufferFill;
@ -162,6 +182,7 @@ private:
SampleSink* m_scope;
bool m_scopeEnabled;
DSDDecoder m_dsdDecoder;
DSDDemodGUI *m_dsdDemodGUI;
QMutex m_settingsMutex;

Wyświetl plik

@ -1,3 +1,20 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 F4EXB //
// written by Edouard Griffiths //
// //
// 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 <QDockWidget>
#include <QMainWindow>
#include <QDebug>

Wyświetl plik

@ -1,3 +1,20 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 F4EXB //
// written by Edouard Griffiths //
// //
// 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 INCLUDE_DSDDEMODGUI_H
#define INCLUDE_DSDDEMODGUI_H

Wyświetl plik

@ -1,3 +1,20 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 F4EXB //
// written by Edouard Griffiths //
// //
// 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 <QtPlugin>
#include <QAction>
#include "plugin/pluginapi.h"

Wyświetl plik

@ -1,3 +1,20 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 F4EXB //
// written by Edouard Griffiths //
// //
// 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 INCLUDE_DSDDEMODLUGIN_H
#define INCLUDE_DSDDEMODLUGIN_H