From fa73feded20dfc3a22d1003bdcf5792d6e1ab49a Mon Sep 17 00:00:00 2001 From: Alex Mirea Date: Tue, 9 Apr 2013 22:50:45 +0300 Subject: [PATCH 1/2] version 1.6.0 See http://forums.radioreference.com/digital-voice-decoding-software/256111- dsd-1-6-closed-fork-open-source.html#post1884783 --- CHANGELOG | 18 ++++++++++++++++-- README | 4 ++-- dsd.h | 1 + dsd_dibit.c | 5 +++++ dsd_frame.c | 12 ++++++------ dsd_frame_sync.c | 5 +++++ dsd_main.c | 3 ++- dsd_symbol.c | 38 ++++++++++++++++++++++++++++++++++++++ p25p1_hdu.c | 2 ++ p25p1_ldu1.c | 5 ++++- p25p1_ldu2.c | 5 ++++- 11 files changed, 85 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index da71e08..259b236 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,21 @@ +1.6.0 + New features: + Auto mutes P25 encrypted signals by default. + Raised cosine filters. + + Fixed bugs: + Changed the crazy dibit buffer which filled for ever until it + ran out of allocated memory then caused a segmentation error. The + buffer is now allowed to fill to 90% before being returned to the + initial pointer value where it over writes the old samples, it + seems to work ok and no segmentation errors now. + Input level is now calculated differently, before when it reported 50% + the soundcard would be fully overloaded. With the new method aim for 30% inlvl. + 1.4.1 New features: - Several new sync types for existing formats now recognized: - Decodes voice from NXDN 4800 (6.25kHz) signals + Several new sync types for existing formats now recognized: + Decodes voice from NXDN 4800 (6.25kHz) signals Decodes voice from NXDN 9600 (12.5kHz) repeater output Decodes voice from DMR/MotoTRBO simplex/repeater input Decodes voice from X2-TDMA simplex/repeater input diff --git a/README b/README index 909f404..bfa61e3 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Digital Speech Decoder 1.4 +Digital Speech Decoder 1.6.0 Copyright (C) 2010 DSD Author GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0) @@ -19,7 +19,7 @@ PERFORMANCE OF THIS SOFTWARE. synthesis requires mbelib, which is a separate package. DSD 1.4.1 requires mbelib 1.1 or later. - Supported formats in version 1.4.1: + Supported formats in version 1.6.0: P25 Phase 1 Widely deployed radio standard used in public safety and amateur radio. diff --git a/dsd.h b/dsd.h index c96515d..2373a3a 100644 --- a/dsd.h +++ b/dsd.h @@ -159,6 +159,7 @@ typedef struct mbe_parms *cur_mp; mbe_parms *prev_mp; mbe_parms *prev_mp_enhanced; + int p25kid; } dsd_state; /* diff --git a/dsd_dibit.c b/dsd_dibit.c index 5ebcbd1..ffa4540 100644 --- a/dsd_dibit.c +++ b/dsd_dibit.c @@ -177,6 +177,11 @@ getDibit (dsd_opts * opts, dsd_state * state) state->sidx++; } + if (state->dibit_buf_p > state->dibit_buf + 900000) + { + state->dibit_buf_p = state->dibit_buf + 200; + } + // determine dibit state if ((state->synctype == 6) || (state->synctype == 14)) { diff --git a/dsd_frame.c b/dsd_frame.c index 393ac17..4923dd1 100644 --- a/dsd_frame.c +++ b/dsd_frame.c @@ -23,7 +23,7 @@ printFrameInfo (dsd_opts * opts, dsd_state * state) int level; - level = (int) (((float) state->max / (float) 32768) * (float) 100); + level = (int) state->max / 164; if (opts->verbose > 0) { printf ("inlvl: %2i%% ", level); @@ -73,7 +73,7 @@ processFrame (dsd_opts * opts, dsd_state * state) { if (opts->verbose > 0) { - level = (int) (((float) state->max / (float) 32768) * (float) 100); + level = (int) state->max / 164; printf ("inlvl: %2i%% ", level); } } @@ -96,7 +96,7 @@ processFrame (dsd_opts * opts, dsd_state * state) { if (opts->verbose > 0) { - level = (int) (((float) state->max / (float) 32768) * (float) 100); + level = (int) state->max / 164; printf ("inlvl: %2i%% ", level); } } @@ -118,7 +118,7 @@ processFrame (dsd_opts * opts, dsd_state * state) { if (opts->verbose > 0) { - level = (int) (((float) state->max / (float) 32768) * (float) 100); + level = (int) state->max / 164; printf ("inlvl: %2i%% ", level); } } @@ -140,7 +140,7 @@ processFrame (dsd_opts * opts, dsd_state * state) { if (opts->verbose > 0) { - level = (int) (((float) state->max / (float) 32768) * (float) 100); + level = (int) state->max / 164; printf ("inlvl: %2i%% ", level); } } @@ -194,7 +194,7 @@ processFrame (dsd_opts * opts, dsd_state * state) { if (opts->verbose > 0) { - level = (int) (((float) state->max / (float) 32768) * (float) 100); + level = (int) state->max / 164; printf ("inlvl: %2i%% ", level); } } diff --git a/dsd_frame_sync.c b/dsd_frame_sync.c index 9f1ea88..b2aa950 100644 --- a/dsd_frame_sync.c +++ b/dsd_frame_sync.c @@ -152,6 +152,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state) lastt++; } + if (state->dibit_buf_p > state->dibit_buf + 900000) + { + state->dibit_buf_p = state->dibit_buf + 200; + } + //determine dibit state if (symbol > 0) { diff --git a/dsd_main.c b/dsd_main.c index 27d520a..9a12711 100644 --- a/dsd_main.c +++ b/dsd_main.c @@ -216,6 +216,7 @@ initState (dsd_state * state) 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; } void @@ -334,7 +335,7 @@ main (int argc, char **argv) char versionstr[25]; mbe_printVersion (versionstr); - printf ("Digital Speech Decoder 1.4.1\n"); + printf ("Digital Speech Decoder 1.6.0\n"); printf ("mbelib version %s\n", versionstr); initOpts (&opts); diff --git a/dsd_symbol.c b/dsd_symbol.c index 6827378..b8fd812 100644 --- a/dsd_symbol.c +++ b/dsd_symbol.c @@ -80,6 +80,44 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) } result = read (opts->audio_in_fd, &sample, 2); + { + #define NZEROS 60 + #define GAIN 7.423339364e+00 + + static float xv[NZEROS+1]; + + static float xcoeffs[] = + { -0.0083649323, -0.0265444850, -0.0428141462, -0.0537571943, + -0.0564141052, -0.0489161045, -0.0310068662, -0.0043393881, + +0.0275375106, +0.0595423283, +0.0857543325, +0.1003565948, + +0.0986944931, +0.0782804830, +0.0395670487, -0.0136691535, + -0.0744390415, -0.1331834575, -0.1788967208, -0.2005995448, + -0.1889627181, -0.1378439993, -0.0454976231, +0.0847488694, + +0.2444859269, +0.4209222342, +0.5982295474, +0.7593684540, + +0.8881539892, +0.9712773915, +0.9999999166, +0.9712773915, + +0.8881539892, +0.7593684540, +0.5982295474, +0.4209222342, + +0.2444859269, +0.0847488694, -0.0454976231, -0.1378439993, + -0.1889627181, -0.2005995448, -0.1788967208, -0.1331834575, + -0.0744390415, -0.0136691535, +0.0395670487, +0.0782804830, + +0.0986944931, +0.1003565948, +0.0857543325, +0.0595423283, + +0.0275375106, -0.0043393881, -0.0310068662, -0.0489161045, + -0.0564141052, -0.0537571943, -0.0428141462, -0.0265444850, + -0.0083649323, + }; + + float sum; int i; + + for (i = 0; i < NZEROS; i++) + xv[i] = xv[i+1]; + + xv[NZEROS] = sample; // unfiltered sample in + sum = 0.0; + + for (i = 0; i <= NZEROS; i++) + sum += (xcoeffs[i] * xv[i]); + + sample = sum / GAIN; // filtered sample out + } if ((sample > state->max) && (have_sync == 1) && (state->rf_mod == 0)) { sample = state->max; diff --git a/p25p1_hdu.c b/p25p1_hdu.c index abf8c8d..2f0f3f9 100644 --- a/p25p1_hdu.c +++ b/p25p1_hdu.c @@ -258,6 +258,8 @@ processHDU (dsd_opts * opts, dsd_state * state) skipDibit (opts, state, 160); + state->p25kid = strtol(kid, NULL, 2); + if (opts->p25enc == 1) { algidhex = strtol (algid, NULL, 2); diff --git a/p25p1_ldu1.c b/p25p1_ldu1.c index 6a6379a..a8a2f2f 100644 --- a/p25p1_ldu1.c +++ b/p25p1_ldu1.c @@ -77,7 +77,10 @@ processLDU1 (dsd_opts * opts, dsd_state * state) y++; z++; } - processMbeFrame (opts, state, imbe_fr, NULL, NULL); + if (state->p25kid == 0) + { + processMbeFrame (opts, state, imbe_fr, NULL, NULL); + } // skip over non imbe data sometimes between frames if ((i < 4) || (i == 8)) diff --git a/p25p1_ldu2.c b/p25p1_ldu2.c index fe6b193..85ba279 100644 --- a/p25p1_ldu2.c +++ b/p25p1_ldu2.c @@ -80,7 +80,10 @@ processLDU2 (dsd_opts * opts, dsd_state * state) y++; z++; } - processMbeFrame (opts, state, imbe_fr, NULL, NULL); + if (state->p25kid == 0) + { + processMbeFrame (opts, state, imbe_fr, NULL, NULL); + } // skip over non imbe data sometimes between frames if ((i < 5) || (i == 8)) From 20271c6df57dacbaed3f2255a8230f44f58bd3ae Mon Sep 17 00:00:00 2001 From: Alex Mirea Date: Wed, 10 Apr 2013 09:05:56 +0300 Subject: [PATCH 2/2] new options to control filters and P25 encrypted signals I have added the -l and -pu options. --- README | 4 +++- dsd.h | 2 ++ dsd_main.c | 16 ++++++++++++++-- dsd_symbol.c | 7 +++++-- p25p1_ldu1.c | 2 +- p25p1_ldu2.c | 2 +- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/README b/README index bfa61e3..cf396aa 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Digital Speech Decoder 1.6.0 +Digital Speech Decoder 1.6.0 with P25 & DMR Filter Copyright (C) 2010 DSD Author GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0) @@ -455,10 +455,12 @@ Decoder options -fp Decode only ProVoice* -fr Decode only DMR/MOTOTRBO -fx Decode only X2-TDMA + -l Disable Filters (not recommended) -ma Auto-select modulation optimizations (default) -mc Use only C4FM modulation optimizations -mg Use only GFSK modulation optimizations -mq Use only QPSK modulation optimizations + -pu Unmute Encrypted P25 -u Unvoiced speech quality (default=3) -xx Expect non-inverted X2-TDMA signal -xr Expect inverted DMR/MOTOTRBO signal diff --git a/dsd.h b/dsd.h index 2373a3a..f2ff8ea 100644 --- a/dsd.h +++ b/dsd.h @@ -93,6 +93,8 @@ typedef struct int msize; int playfiles; int delay; + int disable_filters; + int unmute_encrypted_p25; } dsd_opts; typedef struct diff --git a/dsd_main.c b/dsd_main.c index 9a12711..ec28d4c 100644 --- a/dsd_main.c +++ b/dsd_main.c @@ -128,6 +128,8 @@ initOpts (dsd_opts * opts) opts->msize = 15; opts->playfiles = 0; opts->delay = 0; + opts->disable_filters = 0; + opts->unmute_encrypted_p25 = 0; } void @@ -262,10 +264,12 @@ usage () printf (" -fp Decode only ProVoice*\n"); printf (" -fr Decode only DMR/MOTOTRBO\n"); printf (" -fx Decode only X2-TDMA\n"); + printf (" -l Disable Filters (not recommended)\n"); printf (" -ma Auto-select modulation optimizations (default)\n"); printf (" -mc Use only C4FM modulation optimizations\n"); printf (" -mg Use only GFSK modulation optimizations\n"); printf (" -mq Use only QPSK modulation optimizations\n"); + printf (" -pu Unmute Encrypted P25\n"); printf (" -u Unvoiced speech quality (default=3)\n"); printf (" -xx Expect non-inverted X2-TDMA signal\n"); printf (" -xr Expect inverted DMR/MOTOTRBO signal\n"); @@ -335,7 +339,7 @@ main (int argc, char **argv) char versionstr[25]; mbe_printVersion (versionstr); - printf ("Digital Speech Decoder 1.6.0\n"); + printf ("Digital Speech Decoder 1.6.0 with P25 & DMR Filter\n"); printf ("mbelib version %s\n", versionstr); initOpts (&opts); @@ -344,7 +348,7 @@ main (int argc, char **argv) exitflag = 0; signal (SIGINT, sigfun); - while ((c = getopt (argc, argv, "hep:qstv:z:i:o:d:g:nw:B:C:R:f:m:u:x:A:S:M:r")) != -1) + while ((c = getopt (argc, argv, "hep:qstv:z:i:o:d:g:nw:B:C:R:f:m:u:x:A:S:M:r:l")) != -1) { opterr = 0; switch (c) @@ -373,6 +377,10 @@ main (int argc, char **argv) { opts.p25tg = 1; } + else if (optarg[0] == 'u') + { + opts.unmute_encrypted_p25 = 1; + } break; case 'q': opts.errorbars = 0; @@ -649,6 +657,10 @@ main (int argc, char **argv) opts.datascope = 0; state.optind = optind; break; + case 'l': + opts.disable_filters = 1; + printf ("DMR & P25 Filter Disabled\n"); + break; default: usage (); exit (0); diff --git a/dsd_symbol.c b/dsd_symbol.c index b8fd812..81aed25 100644 --- a/dsd_symbol.c +++ b/dsd_symbol.c @@ -80,7 +80,9 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) } result = read (opts->audio_in_fd, &sample, 2); - { + + if (opts->disable_filters == 0) + { #define NZEROS 60 #define GAIN 7.423339364e+00 @@ -117,7 +119,8 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync) sum += (xcoeffs[i] * xv[i]); sample = sum / GAIN; // filtered sample out - } + } + if ((sample > state->max) && (have_sync == 1) && (state->rf_mod == 0)) { sample = state->max; diff --git a/p25p1_ldu1.c b/p25p1_ldu1.c index a8a2f2f..fd6abe8 100644 --- a/p25p1_ldu1.c +++ b/p25p1_ldu1.c @@ -77,7 +77,7 @@ processLDU1 (dsd_opts * opts, dsd_state * state) y++; z++; } - if (state->p25kid == 0) + if (state->p25kid == 0 || opts->unmute_encrypted_p25 == 1) { processMbeFrame (opts, state, imbe_fr, NULL, NULL); } diff --git a/p25p1_ldu2.c b/p25p1_ldu2.c index 85ba279..a0f8fbb 100644 --- a/p25p1_ldu2.c +++ b/p25p1_ldu2.c @@ -80,7 +80,7 @@ processLDU2 (dsd_opts * opts, dsd_state * state) y++; z++; } - if (state->p25kid == 0) + if (state->p25kid == 0 || opts->unmute_encrypted_p25 == 1) { processMbeFrame (opts, state, imbe_fr, NULL, NULL); }