#ifndef DSD_H #define DSD_H /* * 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 "config.h" #include #include #include #include #define __USE_XOPEN #include #include #include #include #include #include #include #ifdef SOLARIS #include #endif #if defined(BSD) && !defined(__APPLE__) #include #endif #include #include #include #include "p25p1_heuristics.h" #define SAMPLE_RATE_IN 48000 #define SAMPLE_RATE_OUT 8000 #ifdef USE_PORTAUDIO #include "portaudio.h" #define PA_FRAMES_PER_BUFFER 64 //Buffer needs to be large enough to prevent input buffer overruns while DSD is doing other struff (like outputting voice) //else you get skipped samples which result in incomplete/erronous decodes and a mountain of error messages. #define PA_LATENCY_IN 0.500 //Buffer needs to be large enough to prevent output buffer underruns while DSD is doing other stuff (like decoding input) //else you get choppy audio and in 'extreme' cases errors. //Buffer also needs to be as small as possible so we don't have a lot of audio delay. #define PA_LATENCY_OUT 0.100 #endif /* * global variables */ int exitflag; #include "dsd_opts.h" #include "dsd_state.h" #include "dsd_livescanner.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" /* * function prototypes */ void processDMRdata (dsd_opts * opts, dsd_state * state); void processDMRvoice (dsd_opts * opts, dsd_state * state); void processAudio (dsd_opts * opts, dsd_state * state); void writeSynthesizedVoice (dsd_opts * opts, dsd_state * state); void playSynthesizedVoice (dsd_opts * opts, dsd_state * state); void openAudioOutDevice (dsd_opts * opts, int speed); void openAudioInDevice (dsd_opts * opts); int getDibit (dsd_opts * opts, dsd_state * state); int get_dibit_and_analog_signal (dsd_opts * opts, dsd_state * state, int * out_analog_signal); void skipDibit (dsd_opts * opts, dsd_state * state, int count); void saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d); void saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d); int readImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d); int readAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d); void openMbeInFile (dsd_opts * opts, dsd_state * state); void closeMbeOutFile (dsd_opts * opts, dsd_state * state); void openMbeOutFile (dsd_opts * opts, dsd_state * state); void openWavOutFile (dsd_opts * opts, dsd_state * state); void closeWavOutFile (dsd_opts * opts, dsd_state * state); 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); void resumeScan (dsd_opts * opts, dsd_state * state); int getSymbol (dsd_opts * opts, dsd_state * state, int have_sync); void upsample (dsd_state * state, float invalue); void processDSTAR (dsd_opts * opts, dsd_state * state); void processNXDNVoice (dsd_opts * opts, dsd_state * state); void processNXDNData (dsd_opts * opts, dsd_state * state); void processP25lcw (dsd_opts * opts, dsd_state * state, char *lcformat, char *mfid, char *lcinfo); void processHDU (dsd_opts * opts, dsd_state * state); void processLDU1 (dsd_opts * opts, dsd_state * state); void processLDU2 (dsd_opts * opts, dsd_state * state); void processTDU (dsd_opts * opts, dsd_state * state); void processTDULC (dsd_opts * opts, dsd_state * state); void processProVoice (dsd_opts * opts, dsd_state * state); void processX2TDMAdata (dsd_opts * opts, dsd_state * state); void processX2TDMAvoice (dsd_opts * opts, dsd_state * state); void processDSTAR_HD (dsd_opts * opts, dsd_state * state); short dmr_filter(short sample); short nxdn_filter(short sample); #endif // DSD_H