diff --git a/include/dsd.h b/include/dsd.h index 8f9a744..e7423e7 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -42,8 +42,9 @@ #include "p25p1_heuristics.h" -#include //PULSE AUDIO -#include //PULSE AUDIO +#include //PULSE AUDIO +#include //PULSE AUDIO +//#include //PUlSE AUDIO #define SAMPLE_RATE_IN 48000 //48000 #define SAMPLE_RATE_OUT 8000 //8000, @@ -348,7 +349,7 @@ typedef struct int use_ncurses_terminal; int reset_state; int payload; - + char output_name[1024]; //LEH DMR Stuff int EncryptionMode; @@ -367,12 +368,20 @@ typedef struct int repeat; short *audio_out_buf; short *audio_out_buf_p; + short *audio_out_bufR; + short *audio_out_buf_pR; float *audio_out_float_buf; float *audio_out_float_buf_p; + float *audio_out_float_bufR; + float *audio_out_float_buf_pR; float audio_out_temp_buf[160]; float *audio_out_temp_buf_p; + float audio_out_temp_bufR[160]; + float *audio_out_temp_buf_pR; int audio_out_idx; int audio_out_idx2; + int audio_out_idxR; + int audio_out_idx2R; //int wav_out_bytes; int center; int jitter; @@ -391,6 +400,8 @@ typedef struct int midx; char err_str[64]; //actual error errorbars char err_buf[64]; //make copy of err_str for comparison, only have string print when strcmp is different?? + char err_strR[64]; + char err_bufR[64]; char fsubtype[16]; char ftype[16]; int symbolcnt; diff --git a/src/dmr_encryption.c b/src/dmr_encryption.c index afb8e5a..21122df 100644 --- a/src/dmr_encryption.c +++ b/src/dmr_encryption.c @@ -25,8 +25,12 @@ void ProcessDMREncryption (dsd_opts * opts, dsd_state * state) uint32_t i, j; uint32_t Frame; TimeSlotVoiceSuperFrame_t * TSVoiceSupFrame = NULL; + TimeSlotVoiceSuperFrame_t * TSVoiceSupFrameL = NULL; + TimeSlotVoiceSuperFrame_t * TSVoiceSupFrameR = NULL; int *errs; int *errs2; + int *errsR; + int *errs2R; /* * Currently encryption is not supported in this public version... @@ -42,6 +46,11 @@ void ProcessDMREncryption (dsd_opts * opts, dsd_state * state) TSVoiceSupFrame = &state->TS2SuperFrame; } + TSVoiceSupFrameL = &state->TS1SuperFrame; + TSVoiceSupFrameR = &state->TS2SuperFrame; + + + /* Apply encryption here * * A DMR superframe = 6 frames x 3 AMBE voice sample of 49 bits each @@ -84,6 +93,24 @@ void ProcessDMREncryption (dsd_opts * opts, dsd_state * state) TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i], state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); + //errs = (int*)&(TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs1[i]); + //errs2 = (int*)&(TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs2[i]); + //state->errs = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs1[i]; //correct placement + //state->errs2 = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs2[i]; //correct placement + + //errsR = (int*)&(TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs1[i]); + //errs2R = (int*)&(TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs2[i]); + //state->errs = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs1[i]; //correct placement + //state->errs2 = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs2[i]; //correct placement + //state->audio_out_temp_bufR = state->audio_out_temp_buf; + //mbe_processAmbe2450Dataf (state->audio_out_temp_buf, errs, errs2, state->err_str, + // TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i], + // state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); + + //mbe_processAmbe2450Dataf (state->audio_out_temp_bufR, errsR, errs2R, state->err_strR, + // TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i], + // state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); + if (opts->mbe_out_f != NULL) { saveAmbe2450Data (opts, state, TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i]); @@ -94,6 +121,7 @@ void ProcessDMREncryption (dsd_opts * opts, dsd_state * state) } state->debug_audio_errors += *errs2; + //state->debug_audio_errors += *errs2R; processAudio(opts, state); diff --git a/src/dpmr_voice.c b/src/dpmr_voice.c index c7e4ae8..eaf935f 100644 --- a/src/dpmr_voice.c +++ b/src/dpmr_voice.c @@ -129,12 +129,18 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) x++; y++; z++; + } - //processMbeFrame (opts, state, NULL, ambe_fr[j], NULL); //HERE HERE + //processMbeFrame (opts, state, NULL, ambe_fr2, NULL); //HERE HERE + #ifdef DPMR_DUMP fprintf(stderr, " "); #endif } + //processMbeFrame (opts, state, NULL, ambe_fr[0], NULL); //HERE HERE + //processMbeFrame (opts, state, NULL, ambe_fr[1], NULL); //HERE HERE + //processMbeFrame (opts, state, NULL, ambe_fr[2], NULL); //HERE HERE + //processMbeFrame (opts, state, NULL, ambe_fr[3], NULL); //HERE HERE /* First CC (Channel Code) - 24 bit */ k = 0; @@ -207,6 +213,8 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) #endif ambe_fr[j + 4][*w][*x] = (1 & (dibit >> 1)); // bit 1 ambe_fr[j + 4][*y][*z] = (1 & dibit); // bit 0 + //ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1 + //ambe_fr2[*y][*z] = (1 & dibit); // bit 0 //TCH[j + 4][k] = (1 & (dibit >> 1)); // bit 1 //TCH[j + 4][k + 1] = (1 & dibit); // bit 0 state->dPMRVoiceFS2Frame.RawVoiceBit[j + 4][k] = (1 & (dibit >> 1)); // bit 1 @@ -217,12 +225,16 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) y++; z++; } + //processMbeFrame (opts, state, NULL, ambe_fr2, NULL); #ifdef DPMR_DUMP fprintf(stderr, " "); #endif } - + //processMbeFrame (opts, state, NULL, ambe_fr[4], NULL); //HERE HERE + //processMbeFrame (opts, state, NULL, ambe_fr[5], NULL); //HERE HERE + //processMbeFrame (opts, state, NULL, ambe_fr[6], NULL); //HERE HERE + //processMbeFrame (opts, state, NULL, ambe_fr[7], NULL); //HERE HERE #ifdef dPMR_PRINT_DEBUG_INFO fprintf(stderr, "\n"); @@ -595,6 +607,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) /* Voice frame detected */ VoiceFrameFlag = 1; + /* Check if the voice frame contains attached data */ if((state->dPMRVoiceFS2Frame.CommunicationMode[i] == 5) && state->dPMRVoiceFS2Frame.CCHDataCrcOk[i]) { @@ -618,7 +631,8 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) if(VoiceFrameFlag) { /* There is 4 AMBE voice sample per voice frame (= 8 per superframe) */ - for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++) + //for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++) + for(i = 0; i < (8); i++) { /* Apply ECC 1 to the AMBE frames */ state->dPMRVoiceFS2Frame.errs1[i] = (unsigned int)mbe_eccAmbe3600x2450C0(ambe_fr[i]); @@ -626,47 +640,100 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) /* Demodulate the AMBE frames */ mbe_demodulateAmbe3600x2450Data(ambe_fr[i]); + //mbe_demodulateAmbe3600x2400Data(ambe_fr[i]); /* Apply ECC 2 to the AMBE frames and get the 49 bit of the voice sample */ state->dPMRVoiceFS2Frame.errs2[i] += (unsigned int)mbe_eccAmbe3600x2450Data(ambe_fr[i], (char *)state->dPMRVoiceFS2Frame.AmbeBit[i]); + //processMbeFrame (opts, state, NULL, ambe_fr[i], NULL); //HERE HERE + //processMbeFrame (opts, state, NULL, state->dPMRVoiceFS2Frame.AmbeBit[i], NULL); //HERE HERE } } /* End if(VoiceFrameFlag && !AttachedDataFlag) */ - /* Check if the voice frame to play is encrypted */ - if(opts->dPMR_curr_frame_is_encrypted) + //for 1 to 8 and then VoiceFrameFlag + /* + for(i = 0; i < (8); i++) { - /* Encryption is not supported in the public version */ - ScramblerKey = 0; - } - else - { - /* The frame is unencrypted, - * so set the scrambler key to 0 */ - ScramblerKey = 0; - } - - - /* Play only voice frame */ - if(VoiceFrameFlag) - { - -#ifdef dPMR_PRINT_DEBUG_INFO - fprintf(stderr, "Voice frame to play\n"); -#endif /* dPMR_PRINT_DEBUG_INFO */ - /* There is 4 AMBE voice sample per voice frame (so 2 x 4 = 8 per superframe) */ - for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++) + if(VoiceFrameFlag) { + //processMbeFrame (opts, state, NULL, ambe_fr[i], NULL); //HERE HERE + // errs = (uint32_t*)&(state->dPMRVoiceFS2Frame.errs1[i]); errs2 = (uint32_t*)&(state->dPMRVoiceFS2Frame.errs2[i]); state->errs = state->dPMRVoiceFS2Frame.errs1[i]; state->errs2 = state->dPMRVoiceFS2Frame.errs2[i]; - //sounds like choppy shit, but .amb file playback is acceptable, so investigate why this doesn't work properly - mbe_processAmbe2450Dataf (state->audio_out_temp_buf, (int *)errs, (int *)errs2, state->err_str, - (char *)state->dPMRVoiceFS2Frame.AmbeBit[i], + //processMbeFrame (opts, state, NULL, (char *)state->dPMRVoiceFS2Frame.AmbeBit[i], NULL); //HERE HERE + + mbe_processAmbe2450Dataf (state->audio_out_temp_buf, errs, errs2, state->err_str, + state->dPMRVoiceFS2Frame.AmbeBit[i], state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); - //mbe_processAmbe2450Data ((short *) state->audio_out_temp_buf_p, (int *)errs, (int *)errs2, state->err_str, + if (opts->mbe_out_f != NULL) + { + //saveAmbe2450Data (opts, state, (char *)state->dPMRVoiceFS2Frame.AmbeBit[i]); + } + if (opts->errorbars == 1) + { + fprintf(stderr, "%s", state->err_str); + } + + state->debug_audio_errors += *errs2; + + processAudio(opts, state); + + if (opts->wav_out_f != NULL) + { + writeSynthesizedVoice (opts, state); + } + + if (opts->audio_out == 1) + { + //Play the AMBE Frames + playSynthesizedVoice (opts, state); + } + } + } + */ + + //Check if the voice frame to play is encrypted + if(opts->dPMR_curr_frame_is_encrypted) + { + //Encryption is not supported in the public version + ScramblerKey = 0; + } + else + { + //The frame is unencrypted, + //so set the scrambler key to 0 + ScramblerKey = 0; + } + + + //Play only voice frame + + if(VoiceFrameFlag) + { + +#ifdef dPMR_PRINT_DEBUG_INFO + fprintf(stderr, "Voice frame to play\n"); +#endif //dPMR_PRINT_DEBUG_INFO + //There is 4 AMBE voice sample per voice frame (so 2 x 4 = 8 per superframe) + for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++) //is this backwards, shouldn't we run this first, and then voice frame after? + { + + errs = (uint32_t*)&(state->dPMRVoiceFS2Frame.errs1[i]); + errs2 = (uint32_t*)&(state->dPMRVoiceFS2Frame.errs2[i]); + state->errs = state->dPMRVoiceFS2Frame.errs1[i]; + state->errs2 = state->dPMRVoiceFS2Frame.errs2[i]; + // + //processMbeFrame (opts, state, NULL, ambe_fr2, NULL); + + //sounds like choppy shit, but .amb file playback is acceptable, so investigate why this doesn't work properly + mbe_processAmbe2450Dataf (state->audio_out_temp_buf, errs, errs2, state->err_str, + state->dPMRVoiceFS2Frame.AmbeBit[i], + state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); + + //mbe_processAmbe2450Dataf (state->audio_out_temp_buf_p, (int *)errs, (int *)errs2, state->err_str, // (char *)state->dPMRVoiceFS2Frame.AmbeBit[i], // state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); if (opts->mbe_out_f != NULL) @@ -689,16 +756,16 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) if (opts->audio_out == 1) { - /* Play the AMBE Frames */ + //Play the AMBE Frames playSynthesizedVoice (opts, state); } - } /* End for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++) */ - } /* End if(VoiceFrameFlag) */ + } //End for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++) + } //End if(VoiceFrameFlag) else { #ifdef dPMR_PRINT_DEBUG_INFO fprintf(stderr, "Data frame, don't play it !\n"); -#endif /* dPMR_PRINT_DEBUG_INFO */ +#endif //dPMR_PRINT_DEBUG_INFO } if (opts->errorbars == 1) @@ -708,7 +775,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) #ifdef dPMR_PRINT_DEBUG_INFO - /* Display the CCH content */ + //Display the CCH content for(i = 0; i < NB_OF_DPMR_VOICE_FRAME_TO_DECODE; i++) { fprintf(stderr, "i = %u - ", i); @@ -722,17 +789,19 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state) else fprintf(stderr, "CRC ERROR"); fprintf(stderr, "\n"); } -#endif /* dPMR_PRINT_DEBUG_INFO */ +#endif //dPMR_PRINT_DEBUG_INFO - /* Print sPMR frame (if needed) */ + //Print sPMR frame (if needed) //dPMRVoiceFrameProcess(opts, state); //HERE HERE disabled to build -} /* End processdPMRvoice() */ + +} //End processdPMRvoice() /* Scrambler used for dPMR transmission (different of the * voice encryption scrambler), see ETSI TS 102 658 chapter * 7.3 for the polynomial description. * It is a X^9 + X^5 + 1 polynomial. */ + void ScrambledPMRBit(uint32_t * LfsrValue, uint8_t * BufferIn, uint8_t * BufferOut, uint32_t NbOfBitToScramble) { uint8_t S[9] = {0}; diff --git a/src/dsd_audio.c b/src/dsd_audio.c index 9712f70..5b203bc 100644 --- a/src/dsd_audio.c +++ b/src/dsd_audio.c @@ -21,6 +21,8 @@ pa_sample_spec ss; pa_sample_spec tt; pa_sample_spec zz; pa_sample_spec cc; +//pa_channel_map channel_map; + void openPulseOutput(dsd_opts * opts) { @@ -33,7 +35,7 @@ void openPulseOutput(dsd_opts * opts) tt.channels = opts->pulse_digi_out_channels; //doing tests with 2 channels at 22050 for 44100 audio default in pulse tt.rate = opts->pulse_digi_rate_out; //48000, switches to 8000 when using RTL dongle //fprintf (stderr,"digi rate out = %d\n", opts->pulse_digi_rate_out); - + //pa_channel_map_init_stereo(&channel_map); //ss if (opts->monitor_input_audio == 1) { @@ -41,8 +43,13 @@ void openPulseOutput(dsd_opts * opts) } //tt - opts->pulse_digi_dev_out = pa_simple_new(NULL, "DSD FME", PA_STREAM_PLAYBACK, NULL, "Digi Audio Out", &tt, NULL, NULL, NULL); - + pa_channel_map* left = 0; //NULL and 0 are same in this context + pa_channel_map* right = 0; //NULL and 0 are same in this context + //pa_channel_map* right; + //pa_channel_map_init(right); + opts->pulse_digi_dev_out = pa_simple_new(NULL, "DSD-FME", PA_STREAM_PLAYBACK, NULL, opts->output_name, &tt, left, NULL, NULL); + //opts->pulse_digi_dev_out = pa_simple_new(NULL, "DSD FME", PA_STREAM_PLAYBACK, NULL, "Digi Audio Out LEFT", &tt, left, NULL, NULL); + //opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD-FME", PA_STREAM_PLAYBACK, NULL, "Digi Audio Out RIGHT", &tt, right, NULL, NULL); } void openPulseInput(dsd_opts * opts) @@ -62,7 +69,7 @@ void openPulseInput(dsd_opts * opts) //opts->pulse_raw_dev_in = pa_simple_new(NULL, "DSD FME", PA_STREAM_RECORD, NULL, "Raw Audio In", &zz, NULL, NULL, NULL); } //cc - opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD FME", PA_STREAM_RECORD, NULL, "Audio In", &cc, NULL, NULL, NULL); + opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD-FME", PA_STREAM_RECORD, NULL, opts->output_name, &cc, NULL, NULL, NULL); } @@ -161,6 +168,7 @@ processAudio (dsd_opts * opts, dsd_state * state) // detect max level max = 0; state->audio_out_temp_buf_p = state->audio_out_temp_buf; + //state->audio_out_temp_buf_pR = state->audio_out_temp_bufR; for (n = 0; n < 160; n++) { aout_abs = fabsf (*state->audio_out_temp_buf_p); @@ -169,15 +177,24 @@ processAudio (dsd_opts * opts, dsd_state * state) max = aout_abs; } state->audio_out_temp_buf_p++; + //state->audio_out_temp_buf_pR++; } *state->aout_max_buf_p = max; + //*state->aout_max_buf_pR = max; state->aout_max_buf_p++; + //state->aout_max_buf_pR++; state->aout_max_buf_idx++; + //state->aout_max_buf_idxR++; if (state->aout_max_buf_idx > 24) { state->aout_max_buf_idx = 0; state->aout_max_buf_p = state->aout_max_buf; } + //if (state->aout_max_buf_idxR > 24) + // { + // state->aout_max_buf_idxR = 0; + // state->aout_max_buf_pR = state->aout_max_bufR; + // } // lookup max history for (i = 0; i < 25; i++) @@ -412,6 +429,20 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state) //pa_simple_write(opts->pulse_raw_dev_out, (void*)&state->pulse_raw_out_buffer, 2, NULL); } + + //two slot audio testing, still need to seperate channels first internally, but this will play them out on left and RIGHT + /* + if(state->currentslot == 0) + { + pa_simple_write(opts->pulse_digi_dev_out, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2), NULL); //Yay! It works. + } + if(state->currentslot == 1) + { + pa_simple_write(opts->pulse_raw_dev_out, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2), NULL); //Yay! It works. + //pa_simple_write(opts->pulse_raw_dev_out, (state->audio_out_buf_pR - state->audio_out_idxR), (state->audio_out_idxR * 2), NULL); //Yay! It works. + } + */ + pa_simple_write(opts->pulse_digi_dev_out, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2), NULL); //Yay! It works. state->audio_out_idx = 0; } diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c index 44c6fd1..7bfba83 100644 --- a/src/dsd_frame_sync.c +++ b/src/dsd_frame_sync.c @@ -612,9 +612,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { //fprintf(stderr, "DPMR_FRAME_SYNC_1\n"); // TODO : To be removed - if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || - (state->lastsynctype == 22) || (state->lastsynctype == 23)) - { + //if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || + // (state->lastsynctype == 22) || (state->lastsynctype == 23)) + //{ state->carrier = 1; state->offset = synctest_pos; state->max = ((state->max) + lmax) / 2; @@ -630,11 +630,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state) state->lastsynctype = 20; return (20); - } - else - { - state->lastsynctype = 20; - } + //} + //else + //{ + // state->lastsynctype = 20; + //} } /* End if (opts->inverted_dpmr == 0) */ } else if(strcmp(synctest12, DPMR_FRAME_SYNC_2) == 0) @@ -674,9 +674,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { //fprintf(stderr, "DPMR_FRAME_SYNC_3\n"); // TODO : To be removed - if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || - (state->lastsynctype == 22) || (state->lastsynctype == 23)) - { + //if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || + // (state->lastsynctype == 22) || (state->lastsynctype == 23)) + //{ state->carrier = 1; state->offset = synctest_pos; state->max = ((state->max) + lmax) / 2; @@ -692,11 +692,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state) state->lastsynctype = 22; return (22); - } - else - { - state->lastsynctype = 22; - } + //} + //else + //{ + // state->lastsynctype = 22; + //} } } if(strcmp(synctest, DPMR_FRAME_SYNC_4) == 0) @@ -705,9 +705,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { //fprintf(stderr, "DPMR_FRAME_SYNC_4\n"); // TODO : To be removed - if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || - (state->lastsynctype == 22) || (state->lastsynctype == 23)) - { + //if ((state->lastsynctype == 20) || (state->lastsynctype == 21) || + // (state->lastsynctype == 22) || (state->lastsynctype == 23)) + //{ state->carrier = 1; state->offset = synctest_pos; state->max = ((state->max) + lmax) / 2; @@ -723,11 +723,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state) state->lastsynctype = 23; return (23); - } - else - { - state->lastsynctype = 23; - } + //} + //else + //{ + // state->lastsynctype = 23; + //} } } else if(strcmp(synctest, INV_DPMR_FRAME_SYNC_1) == 0) @@ -735,9 +735,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state) if (opts->inverted_dpmr) { //fprintf(stderr, "INV_DPMR_FRAME_SYNC_1\n"); // TODO : To be removed - if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || - (state->lastsynctype == 26) || (state->lastsynctype == 27)) - { + //if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || + // (state->lastsynctype == 26) || (state->lastsynctype == 27)) + //{ state->carrier = 1; state->offset = synctest_pos; state->max = ((state->max) + lmax) / 2; @@ -749,11 +749,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state) } state->lastsynctype = 24; return (24); - } - else - { - state->lastsynctype = 24; - } + //} + //else + //{ + // state->lastsynctype = 24; + //} } } else if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_2) == 0) @@ -762,9 +762,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { //fprintf(stderr, "DPMR_FRAME_SYNC_2\n"); // TODO : To be removed - if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || - (state->lastsynctype == 26) || (state->lastsynctype == 27)) - { + //if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || + // (state->lastsynctype == 26) || (state->lastsynctype == 27)) + //{ state->carrier = 1; state->offset = synctest_pos; state->max = ((state->max) + lmax) / 2; @@ -776,11 +776,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state) } state->lastsynctype = 25; return (25); - } - else - { - state->lastsynctype = 25; - } + //} + //else + //{ + // state->lastsynctype = 25; + //} } } else if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_3) == 0) @@ -789,9 +789,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { //fprintf(stderr, "INV_DPMR_FRAME_SYNC_3\n"); // TODO : To be removed - if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || - (state->lastsynctype == 26) || (state->lastsynctype == 27)) - { + //if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || + // (state->lastsynctype == 26) || (state->lastsynctype == 27)) + //{ state->carrier = 1; state->offset = synctest_pos; state->max = ((state->max) + lmax) / 2; @@ -803,11 +803,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state) } state->lastsynctype = 26; return (26); - } - else - { - state->lastsynctype = 26; - } + //} + //else + //{ + // state->lastsynctype = 26; + //} } } if(strcmp(synctest, INV_DPMR_FRAME_SYNC_4) == 0) @@ -816,9 +816,9 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { //fprintf(stderr, "INV_DPMR_FRAME_SYNC_4\n"); // TODO : To be removed - if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || - (state->lastsynctype == 26) || (state->lastsynctype == 27)) - { + //if ((state->lastsynctype == 24) || (state->lastsynctype == 25) || + // (state->lastsynctype == 26) || (state->lastsynctype == 27)) + //{ state->carrier = 1; state->offset = synctest_pos; state->max = ((state->max) + lmax) / 2; @@ -830,11 +830,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state) } state->lastsynctype = 27; return (27); - } - else - { - state->lastsynctype = 27; - } + //} + //else + //{ + // state->lastsynctype = 27; + //} } } else diff --git a/src/dsd_main.c b/src/dsd_main.c index 7dbe392..3f2c82f 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -95,6 +95,7 @@ noCarrier (dsd_opts * opts, dsd_state * state) state->min = -15000; state->center = 0; state->err_str[0] = 0; + state->err_strR[0] = 0; sprintf (state->fsubtype, " "); sprintf (state->ftype, " "); state->errs = 0; @@ -190,14 +191,15 @@ initOpts (dsd_opts * opts) opts->rtl_udp_port = 6020; //set UDP port for RTL remote opts->rtl_bandwidth = 12; //changed recommended default to 12, 24 for ProVoice opts->pulse_raw_rate_in = 48000; - opts->pulse_raw_rate_out = 48000; //doing tests with 2 channels at 24000 for 48000 audio default in pulse + opts->pulse_raw_rate_out = 24000; //doing tests with 2 channels at 24000 for 48000 audio default in pulse opts->pulse_digi_rate_in = 48000; - opts->pulse_digi_rate_out = 24000; //need to copy this to rtl type in and change rate out to 8000 + opts->pulse_digi_rate_out = 48000; //need to copy this to rtl type in and change rate out to 8000 opts->pulse_raw_in_channels = 1; - opts->pulse_raw_out_channels = 1; + opts->pulse_raw_out_channels = 2; opts->pulse_digi_in_channels = 1; //2 - opts->pulse_digi_out_channels = 2; - + opts->pulse_digi_out_channels = 1; //2 + //opts->output_name = "DSD-FME"; + sprintf (opts->output_name, " "); opts->pulse_flush = 1; //set 0 to flush, 1 for flushed opts->use_ncurses_terminal = 0; //ncurses terminal disabled by default, call with -N opts->payload = 0; //initialize with 0 so can pass == 0 arguments @@ -217,14 +219,23 @@ initState (dsd_state * state) memset (state->dibit_buf, 0, sizeof (int) * 200); state->repeat = 0; state->audio_out_buf = malloc (sizeof (short) * 1000000); + state->audio_out_bufR = malloc (sizeof (short) * 1000000); memset (state->audio_out_buf, 0, 100 * sizeof (short)); + memset (state->audio_out_bufR, 0, 100 * sizeof (short)); state->audio_out_buf_p = state->audio_out_buf + 100; + state->audio_out_buf_pR = state->audio_out_buf + 100; state->audio_out_float_buf = malloc (sizeof (float) * 1000000); + state->audio_out_float_bufR = malloc (sizeof (float) * 1000000); memset (state->audio_out_float_buf, 0, 100 * sizeof (float)); + memset (state->audio_out_float_bufR, 0, 100 * sizeof (float)); state->audio_out_float_buf_p = state->audio_out_float_buf + 100; + state->audio_out_float_buf_pR = state->audio_out_float_bufR + 100; state->audio_out_idx = 0; state->audio_out_idx2 = 0; + state->audio_out_idxR = 0; + state->audio_out_idx2R = 0; state->audio_out_temp_buf_p = state->audio_out_temp_buf; + state->audio_out_temp_buf_pR = state->audio_out_temp_bufR; //state->wav_out_bytes = 0; state->center = 0; state->jitter = -1; @@ -251,6 +262,7 @@ initState (dsd_state * state) } state->midx = 0; state->err_str[0] = 0; + state->err_strR[0] = 0; sprintf (state->fsubtype, " "); sprintf (state->ftype, " "); state->symbolcnt = 0; @@ -821,6 +833,7 @@ main (int argc, char **argv) opts.frame_dmr = 1; opts.frame_dpmr = 0; //borrow from LEH opts.frame_provoice = 0; //turn it on, doesn't work due to symbol rate difference + sprintf (opts.output_name, "Auto Detect"); } else if (optarg[0] == 'd') { @@ -832,6 +845,7 @@ main (int argc, char **argv) opts.frame_dmr = 0; opts.frame_dpmr = 0; //borrow from LEH opts.frame_provoice = 0; + sprintf (opts.output_name, "D-STAR"); fprintf (stderr,"Decoding only D-STAR frames.\n"); } else if (optarg[0] == 'x') @@ -844,6 +858,7 @@ main (int argc, char **argv) opts.frame_dmr = 0; opts.frame_dpmr = 0; //borrow from LEH opts.frame_provoice = 0; + sprintf (opts.output_name, "X2-TDMA"); fprintf (stderr,"Decoding only X2-TDMA frames.\n"); } else if (optarg[0] == 'p') @@ -862,6 +877,7 @@ main (int argc, char **argv) opts.mod_qpsk = 0; opts.mod_gfsk = 1; state.rf_mod = 2; + sprintf (opts.output_name, "ProVoice"); fprintf (stderr,"Setting symbol rate to 9600 / second\n"); fprintf (stderr,"Enabling only GFSK modulation optimizations.\n"); fprintf (stderr,"Decoding only ProVoice frames.\n"); @@ -880,6 +896,7 @@ main (int argc, char **argv) opts.mod_c4fm = 1; //Phase 1 only uses C4FM, right? opts.mod_qpsk = 0; state.rf_mod = 0; // + sprintf (opts.output_name, "P25P1"); fprintf (stderr,"Decoding only P25 Phase 1 frames.\n"); } else if (optarg[0] == 'i') @@ -899,6 +916,7 @@ main (int argc, char **argv) opts.mod_qpsk = 0; opts.mod_gfsk = 0; //was 1 with others on zero state.rf_mod = 0; //was 2 + sprintf (opts.output_name, "NXDN48"); //opts.symboltiming = 2400; //NXDN48 uses 2400 symbol rate fprintf (stderr,"Setting symbol rate to 2400 / second\n"); fprintf (stderr,"Enabling only C4FM modulation optimizations.\n"); @@ -918,6 +936,7 @@ main (int argc, char **argv) opts.mod_qpsk = 0; opts.mod_gfsk = 0; //was 1 state.rf_mod = 0; //was 2 + sprintf (opts.output_name, "NXDN96"); fprintf (stderr,"Enabling only C4FM modulation optimizations.\n"); fprintf (stderr,"Decoding only NXDN 9600 baud frames.\n"); } @@ -935,6 +954,7 @@ main (int argc, char **argv) opts.mod_qpsk = 0; opts.mod_gfsk = 0; // state.rf_mod = 0; // + sprintf (opts.output_name, "DMR/MOTOTRBO"); fprintf (stderr,"Decoding only DMR/MOTOTRBO frames.\n"); } else if (optarg[0] == 'm') @@ -952,7 +972,8 @@ main (int argc, char **argv) opts.mod_c4fm = 1; opts.mod_qpsk = 0; opts.mod_gfsk = 0; - state.rf_mod = 0; + state.rf_mod = 0; //garbage value to keep jitter in check? + sprintf (opts.output_name, "dPMR"); //opts.pulse_digi_rate_in = 48000; //opts.pulse_digi_rate_out = 48000; //need to copy this to rtl type in and change rate out to 8000 //opts.pulse_digi_in_channels = 1; diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index 052a7e0..fb4904f 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -374,7 +374,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if (lls == 12 || lls == 13) //DMR Voice Types { //printw ("| DCC: [%i] FID: [%02X]\n", dcc, state->dmr_fid); - printw ("| DCC: [%i] MFID: [%02X] SOP: [%X] \n", dcc, state->dmr_fid, state->dmr_so); + printw ("| DCC: [%i] FID: [%02X] SOP: [%X] \n", dcc, state->dmr_fid, state->dmr_so); printw ("| TID: [%i] RID: [%i]", tg, rd); if(state->dmr_so & 0x80) //1000 0000 { @@ -403,7 +403,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) } printw("\n"); //printw ("%s ", state->slot0light); - printw ("| SLOT 0 "); + printw ("| SLOT 1 "); if (state->currentslot == 0) //find out how to tell when slot0 has voice { s0last = "Voice"; @@ -412,7 +412,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) printw ("%s ", s0last); //printw ("%s ", state->slot1light); - printw ("SLOT 1 "); + printw ("SLOT 2 "); if (state->currentslot == 1) //find out how to tell when slot1 has voice { s1last = "Voice"; @@ -457,7 +457,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) printw("\n"); //printw ("%s ", state->slot0light); - printw ("| SLOT 0 "); + printw ("| SLOT 1 "); if (state->currentslot == 0) //find out how to tell when slot0 has voice { s0last = "Data "; @@ -468,7 +468,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) } printw ("%s ", s0last); //printw ("%s ", state->slot1light); - printw ("SLOT 1 "); + printw ("SLOT 2 "); if (state->currentslot == 1) //find out how to tell when slot1 has voice { s1last = "Data ";