Fix Raw Audio Monitoring

Fix Raw Audio Monitoring
--Still crashes Pulse Audio server on Ubuntu/Linux Mint
--PULSE_LATENCY_MSEC=1000 or high value mitigates problem for brief moment, but still crashes
---Issue with Latency, or maybe writing garbage values to pa_simple_write
General Code Cleanup
Tweak NCURSES Printer
Tweak STDERR Printouts
This commit is contained in:
lwvmobile
2022-04-02 14:24:47 -04:00
committed by GitHub
parent ab29dd8e6a
commit 7c461844ad
12 changed files with 575 additions and 278 deletions

View File

@@ -241,6 +241,7 @@ typedef struct
unsigned int errs1[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4]; /* 8 x errors #1 computed when demodulate the AMBE voice bit of the frame */
unsigned int errs2[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4]; /* 8 x errors #2 computed when demodulate the AMBE voice bit of the frame */
unsigned char AmbeBit[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4][49]; /* 8 x 49 bit of AMBE voice of the frame */
//unsigned char AmbeBit[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4][36];
unsigned char CCHData[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][48];
unsigned int CCHDataHammingOk[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
unsigned char CCHDataCRC[NB_OF_DPMR_VOICE_FRAME_TO_DECODE];
@@ -601,6 +602,11 @@ typedef struct
#define PROVOICE_EA_SYNC "31131311331331111133131311311133"
//LEH dPMR
/* dPMR Frame Sync 1 - 48 bits sequence
* HEX : 57 FF 5F 75 D5 77
* Binary : 0101 0111 1111 1111 0101 1111 0111 0101 1101 0101 0111 0111
* Dibit : 1 1 1 3 3 3 3 3 1 1 3 3 1 3 1 1 3 1 1 1 1 3 1 3 */
#define DPMR_FRAME_SYNC_1 "111333331133131131111313"
/* dPMR Frame Sync 2 - 24 bits sequence
@@ -620,12 +626,14 @@ typedef struct
* Binary : 1111 1101 0101 0101 1111 0101 1101 1111 0111 1111 1101 1101
* Dibit : 3 3 3 1 1 1 1 1 3 3 1 1 3 1 3 3 1 3 3 3 3 1 3 1 */
#define DPMR_FRAME_SYNC_4 "333111113311313313333131"
//#define DPMR_FRAME_SYNC_4 "111333331133131131111313"
/* dPMR Frame Sync 1 to 4 - Inverted */
#define INV_DPMR_FRAME_SYNC_1 "333111113311313313333131"
#define INV_DPMR_FRAME_SYNC_2 "331111313113"
#define INV_DPMR_FRAME_SYNC_3 "311313111133"
#define INV_DPMR_FRAME_SYNC_4 "111333331133131131111313"
//#define INV_DPMR_FRAME_SYNC_4 "333111113311313313333131"
//
/*
@@ -759,7 +767,7 @@ uint8_t CRC8BitdPMR(uint8_t * BufferIn, uint32_t BitLength);
void ConvertAirInterfaceID(uint32_t AI_ID, uint8_t ID[8]);
int32_t GetdPmrColorCode(uint8_t ChannelCodeBit[24]);
//LEH DMR
void ProcessDMREncryption (dsd_opts * opts, dsd_state * state); //consider if this is needed
void ProcessDMR (dsd_opts * opts, dsd_state * state);
void DMRDataFrameProcess(dsd_opts * opts, dsd_state * state);
void DMRVoiceFrameProcess(dsd_opts * opts, dsd_state * state);
//BPTC (Block Product Turbo Code) functions

140
src/dmr_process_voice.c Normal file
View File

@@ -0,0 +1,140 @@
/*
* 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 "dsd.h"
#include "dmr_const.h"
#include "p25p1_check_hdu.h"
//
//
void ProcessDMR (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;
unsigned long long int k;
int x;
k = 0;
if(state->currentslot == 0)
{
TSVoiceSupFrame = &state->TS1SuperFrame;
}
else
{
TSVoiceSupFrame = &state->TS2SuperFrame;
}
//TSVoiceSupFrameL = &state->TS1SuperFrame;
//TSVoiceSupFrameR = &state->TS2SuperFrame;
//
//
for(Frame = 0; Frame < 6; Frame++)
{
/* 1 DMR frame contains 3 AMBE voice samples */
//fprintf (stderr, "\n 1AMBE ");
for(i = 0; i < 3; i++)
{
errs = (int*)&(TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs1[i]);
errs2 = (int*)&(TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs2[i]);
state->errs = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs1[i]; //correct placement
state->errs2 = TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].errs2[i]; //correct placement
mbe_processAmbe2450Dataf (state->audio_out_temp_buf, errs, errs2, state->err_str,
TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i],
state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
/*
if (state->currentslot == 0)
{
errs = (int*)&(TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs1[i]);
errs2 = (int*)&(TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs2[i]);
state->errs = TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs1[i]; //correct placement
state->errs2 = TSVoiceSupFrameL->TimeSlotAmbeVoiceFrame[Frame].errs2[i]; //correct placement
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);
state->debug_audio_errors += *errs2;
//state->debug_audio_errors += *errs2R;
processAudio(opts, state);
playSynthesizedVoice (opts, state);
}
if (state->currentslot == 1)
{
errsR = (int*)&(TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs1[i]);
errs2R = (int*)&(TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs2[i]);
state->errs = TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs1[i]; //correct placement
state->errs2 = TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].errs2[i]; //correct placement
//state->audio_out_temp_bufR = state->audio_out_temp_buf;
mbe_processAmbe2450Dataf (state->audio_out_temp_buf, errsR, errs2R, state->err_strR,
TSVoiceSupFrameR->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i],
state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
state->debug_audio_errors += *errs2R;
processAudio(opts, state);
playSynthesizedVoice (opts, state);
}
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]);
}
if (opts->errorbars == 1)
{
fprintf(stderr, "%s", state->err_str);
}
state->debug_audio_errors += *errs2;
//state->debug_audio_errors += *errs2R;
processAudio(opts, state);
//playSynthesizedVoice (opts, state);
if (opts->wav_out_f != NULL)
{
writeSynthesizedVoice (opts, state);
}
if (opts->audio_out == 1 && opts->p25enc != 1) //play only if not equal to enc value, going to set p25enc to 1 if enc detected??
{
playSynthesizedVoice (opts, state);
}
} /* End for(i = 0; i < 3; i++) */
} /* End for(Frame = 0; Frame < 6; Frame++) */
} /* End ProcessDMREncryption() */
/* End of file */

View File

@@ -306,18 +306,18 @@ void ProcessDataData(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint
for(i = 0; i < 16; i++)
{
CRCExtracted = CRCExtracted << 1;
//CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 72] & 1);
CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 80] & 1); //80-96 for PI header
CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 72] & 1);
//CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 80] & 1); //80-96 for PI header
}
//Look into whether or not we need to run these CRC checks for this header information
//and see if its applied the same or differently
/* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */
//CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
//CRCExtracted = CRCExtracted ^ 0x6969;
/* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
/* Convert corrected 12 bytes into 96 bits */
@@ -332,6 +332,18 @@ void ProcessDataData(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint
DmrDataBit[j + 6] = (DmrDataByte[i] >> 1) & 0x01;
DmrDataBit[j + 7] = (DmrDataByte[i] >> 0) & 0x01;
}
//test
if((IrrecoverableErrors == 0) && CRCCorrect)
{
fprintf (stderr, "\n(Data CRC Okay)");
}
else if((IrrecoverableErrors == 0))
{
fprintf (stderr, "\n(Data FEC Okay)");
}
else fprintf (stderr, ("\n(Data CRC Fail, FEC Fail)"));
//
if (DmrDataByte[0] == 0x43)
{
@@ -904,20 +916,31 @@ void Process12Data(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_
for(i = 0; i < 16; i++)
{
CRCExtracted = CRCExtracted << 1;
//CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 72] & 1);
CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 80] & 1); //80-96 for PI header
CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 72] & 1);
//CRCExtracted = CRCExtracted | (uint32_t)(DmrDataBit[i + 80] & 1); //80-96 for PI header
}
//Look into whether or not we need to run these CRC checks for this header information
//and see if its applied the same or differently
/* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */
//CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
//CRCExtracted = CRCExtracted ^ 0x6969;
/* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
//test
if((IrrecoverableErrors == 0) && CRCCorrect)
{
fprintf (stderr, "\n(1/2 Rate CRC Okay)");
}
else if((IrrecoverableErrors == 0))
{
fprintf (stderr, "\n(1/2 Rate FEC Okay)");
}
else fprintf (stderr, ("\n(1/2 Rate CRC Fail, FEC Fail)"));
/* Convert corrected 12 bytes into 96 bits */
for(i = 0, j = 0; i < 12; i++, j+=8)
{
@@ -939,7 +962,7 @@ void Process12Data(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_
//ARS?
if ( (state->dmr_12_rate_sf[0] & 0x3F) == 0x0C)
{
fprintf (stderr, "\n Source: ");
fprintf (stderr, "\n Source:");
fprintf (stderr, " %03d.%03d.%03d.%03d", (state->dmr_12_rate_sf[0] & 0x3F), state->dmr_12_rate_sf[1], state->dmr_12_rate_sf[2], state->dmr_12_rate_sf[3]); //strip first two bits off 1st byte
fprintf (stderr, " [%08d]", (state->dmr_12_rate_sf[1] <<16 ) + (state->dmr_12_rate_sf[2] << 8) + state->dmr_12_rate_sf[3] );
fprintf (stderr, " - Port %05d", (state->dmr_12_rate_sf[8] << 8) + state->dmr_12_rate_sf[9]);
@@ -1093,11 +1116,22 @@ void ProcessCSBK(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t
//and see if its applied the same or differently
/* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */
//CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
//CRCExtracted = CRCExtracted ^ 0x6969;
CRCExtracted = CRCExtracted ^ 0x6969;
/* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
//test
if((IrrecoverableErrors == 0) && CRCCorrect)
{
fprintf (stderr, "\n(CSBK CRC Okay)");
}
else if((IrrecoverableErrors == 0))
{
fprintf (stderr, "\n(CSBK FEC Okay)");
}
else fprintf (stderr, ("\n(CSBK CRC Fail, FEC Fail)"));
/* Convert corrected 12 bytes into 96 bits */
for(i = 0, j = 0; i < 12; i++, j+=8)
@@ -1247,8 +1281,9 @@ void ProcessCSBK(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t
//possible Site identifier, CSBK Aloha?
if (csbk_o == 0x19) //DmrDataByte[0] == 0x99?
{
fprintf (stderr, "\n Site ID %d-%d.%d", (DmrDataByte[2] & 0xF0 >> 4), DmrDataByte[2] & 0xF, DmrDataByte[3]);
fprintf (stderr, " DCC %d", DmrDataByte[1]);
fprintf (stderr, "\n CSBK Aloha?");
//fprintf (stderr, "\n Site ID %d-%d.%d", (DmrDataByte[2] & 0xF0 >> 4), DmrDataByte[2] & 0xF, DmrDataByte[3]);
//fprintf (stderr, " DCC %d", DmrDataByte[1]);
//sprintf ( state->dmr_callsign[0], "Site ID %d-%d.%d", (DmrDataByte[2] & 0xF0 >> 4), DmrDataByte[2] & 0xF, DmrDataByte[3]);
//sprintf(state->dmr_branding, " TIII "); //?? one of these next two seems to be on both types, maybe its a TIII thing?
}
@@ -1363,11 +1398,11 @@ void ProcessDmrPIHeader(dsd_opts * opts, dsd_state * state, uint8_t info[196], u
//and see if its applied the same or differently
/* Apply the CRC mask (see DMR standard B.3.12 Data Type CRC Mask) */
//CRCExtracted = CRCExtracted ^ 0x969696; //does this mask get applied here though for PI?
//CRCExtracted = CRCExtracted ^ 0x6969;
CRCExtracted = CRCExtracted ^ 0x6969;
/* Check/correct the full link control data and compute the Reed-Solomon (12,9) CRC */
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x969696);
//CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
CRCCorrect = ComputeAndCorrectFullLinkControlCrc(DmrDataByte, &CRCComputed, 0x6969);
/* Convert corrected 12 bytes into 96 bits */
for(i = 0, j = 0; i < 12; i++, j+=8)
@@ -1390,6 +1425,18 @@ void ProcessDmrPIHeader(dsd_opts * opts, dsd_state * state, uint8_t info[196], u
{
fprintf (stderr, "\n DMR PI Header ALG ID: 0x%02X KEY ID: 0x%02X MI: 0x%08X", state->payload_algid, state->payload_keyid, state->payload_mi);
}
//test
if((IrrecoverableErrors == 0) && CRCCorrect)
{
fprintf (stderr, " (PI CRC Okay)");
}
else if((IrrecoverableErrors == 0))
{
fprintf (stderr, "( PI FEC Okay)");
}
else fprintf (stderr, (" (PI CRC Fail, FEC Fail)"));
}
void ProcessDmrVoiceLcHeader(dsd_opts * opts, dsd_state * state, uint8_t info[196], uint8_t syncdata[48], uint8_t SlotType[20])

View File

@@ -637,8 +637,8 @@ void processDMRvoice (dsd_opts * opts, dsd_state * state)
/* Perform the SYNC DMR data embedded decoding */
ProcessVoiceBurstSync(opts, state);
/* Perform the DMR encryption decoding */
ProcessDMREncryption(opts, state);
/* Perform the DMR voice decoding */
ProcessDMR(opts, state);
/* Print DMR frame (if needed) */
//DMRVoiceFrameProcess(opts, state); //HERE HERE, was enabled, disabled so I could build

View File

@@ -36,11 +36,11 @@ void openPulseOutput(dsd_opts * opts)
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)
if (opts->frame_dmr == 1 && opts->audio_in_type != 3)
//ss
if (opts->monitor_input_audio == 1)
//if (opts->frame_dmr == 1 && opts->audio_in_type != 3)
{
//opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD FME", PA_STREAM_PLAYBACK, NULL, "Raw Audio Out", &ss, NULL, NULL, NULL);
opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD-FME", PA_STREAM_PLAYBACK, NULL, "Raw Audio", &ss, NULL, NULL, NULL);
//opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD FME", PA_STREAM_PLAYBACK, NULL, "DMR/MOTOTRBO Right", &ss, NULL, NULL, NULL);
}
@@ -57,9 +57,9 @@ void openPulseOutput(dsd_opts * opts)
void openPulseInput(dsd_opts * opts)
{
//zz.format = PA_SAMPLE_S16NE;
//zz.channels = opts->pulse_raw_in_channels;
//zz.rate = opts->pulse_raw_rate_in; //48000
zz.format = PA_SAMPLE_S16NE;
zz.channels = opts->pulse_raw_in_channels;
zz.rate = opts->pulse_raw_rate_in; //48000
cc.format = PA_SAMPLE_S16NE;
cc.channels = opts->pulse_digi_in_channels;
@@ -68,93 +68,32 @@ void openPulseInput(dsd_opts * opts)
//zz
if (opts->monitor_input_audio == 1)
{
//opts->pulse_raw_dev_in = pa_simple_new(NULL, "DSD FME", PA_STREAM_RECORD, NULL, "Raw Audio In", &zz, NULL, NULL, NULL);
//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, opts->output_name, &cc, NULL, NULL, NULL);
}
void playRawAudio(dsd_opts * opts, dsd_state * state) {
//playRawAudio may be obsoleted now that I can run these correctly right inside of dsd_symbol
void playRawAudio(dsd_opts * opts, dsd_state * state)
{
short obuf, outl, i, sample2, something;
something = state->samplesPerSymbol / 1; //1 for buffer steal loops, 5 for rtl loop
//something = 1;
if (opts->audio_in_type == 0 && opts->audio_out_type == 0){ //hack, but might as well for this particular type since its nearly perfect
for (i=0; i < something; i++){
//read (opts->audio_in_fd, &sample2, 2); //reading here seems to get same speed as gfsk modulation
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
//pa_simple_read(opts->pulse_raw_dev_in, &state->pulse_raw_out_buffer, 2, NULL );
//obuf = state->pulse_raw_out_buffer / 4; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
//obuf = state->input_sample_buffer;
obuf = state->pulse_raw_out_buffer;
//obuf = state->pulse_raw_out_buffer;
//write (opts->audio_out_fd, (void*)&obuf, 2);
pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, 2, NULL);
//pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, 2, NULL);
//pa_simple_write(opts->pulse_digi_dev_out, (void*)&obuf, 2, NULL);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
}
}
#ifdef USE_PORTAUDIO
if (opts->audio_in_type == 2 && opts->audio_out_type == 0){ //hack, but might as well for this particular type since its nearly perfect
for (i=0; i < something * 5; i++){ //not sure if this should be 'something' or something * 5 like is was with OSS
//Pa_ReadStream( opts->audio_in_pa_stream, &sample2, 1 ); //reading here seems to get same speed as gfsk modulation
obuf = state->pulse_raw_out_buffer;
//obuf = sample2 / 4; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
//write (opts->audio_out_fd, (void*)&obuf, 2);
pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, 2, NULL);
}
}
if (opts->audio_in_type == 0 && opts->audio_out_type == 2){ //hack, but might as well for this particular type since its nearly perfect
for (i=0; i < something; i++){
//read (opts->audio_in_fd, &sample2, 2); //reading here seems to get same speed as gfsk modulation
//pa_simple_read(opts->pulse_raw_dev_in, &sample2, 2, NULL );
//obuf = sample2 / 4; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
obuf = state->pulse_raw_out_buffer;
Pa_StartStream( opts->audio_out_pa_stream ); //no promises this work
Pa_WriteStream( opts->audio_out_pa_stream, (void*)&obuf, 2); //no promises this work
}
}
if (opts->audio_in_type == 2 && opts->audio_out_type == 2){ //hack, but might as well for this particular type since its nearly perfect
for (i=0; i < something * 5; i++){ //not sure if this should be 'something' or something * 5 like is was with OSS
//Pa_ReadStream( opts->audio_in_pa_stream, &sample2, 1 ); //reading here seems to get same speed as gfsk modulation
//obuf = sample2 / 4; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
obuf = state->pulse_raw_out_buffer;
Pa_StartStream( opts->audio_out_pa_stream ); //no promises this work
Pa_WriteStream( opts->audio_out_pa_stream, (void*)&obuf, 2); //no promises this work
}
}
#endif
something = state->samplesPerSymbol / 5; //change to 5 for rtl samples, flips back to 1 up top next loop
//something = 1;
if (opts->audio_in_type == 1 || opts->audio_in_type == 3){ //only plays at 83% and sounds like s sadly, but can't get samples directly from sdr when its already being polled for samples
//also, can't get samples from stdin more than once either it seems, unless I borked it when I tried it earlier, so lumping it in here as well
for (i=0; i < something; i++)
{
obuf = state->input_sample_buffer; //dividing here 'quietens' it down a little bit, helps with clicking and clipping
outl = sizeof(obuf) ; //obuf length, I think its always equal to 2
if (opts->audio_out_type == 0){
//write (opts->audio_out_fd, (void*)&obuf, outl);
pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, outl, NULL);
//fprintf (stderr,"writing samples");
}
#ifdef USE_PORTAUDIO //no idea if this method will work, since I can't test it
if (opts->audio_out_type == 2){
short err;
err = Pa_IsStreamActive( opts->audio_out_pa_stream );
if(err == 0)
{
err = Pa_StartStream( opts->audio_out_pa_stream );
if( err != paNoError ){
fprintf (stderr,"Can't Start PA Stream");
}
err = Pa_WriteStream( opts->audio_out_pa_stream, (void*)&obuf, outl );
if( err != paNoError ){
fprintf (stderr,"Can't Write PA Stream");
}
}
}
#endif
} // end for loop
} //end if statement
} //end playRawAudio

View File

@@ -83,10 +83,14 @@ saveAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
b = b + ambe_d[k];
k++;
}
if (opts->payload == 1) //make opt variable later on to toggle this
if (opts->payload == 1 && i < 6) //make opt variable later on to toggle this
{
fprintf (stderr, "[%02X] ", b);
}
if (opts->payload == 1 && i == 6) //7th octet should only contain 1 bit? value will be either 0x00 or 0x80?
{
fprintf (stderr, "[%02X] ", b & 0x80); //7th octet should only contain 1 bit?
}
fputc (b, opts->mbe_out_f);
}
@@ -181,10 +185,14 @@ readAmbe2450Data (dsd_opts * opts, dsd_state * state, char *ambe_d)
b = b & 255;
k++;
}
if (opts->payload == 1) //make opt variable later on to toggle this
if (opts->payload == 1 && i < 6) //make opt variable later on to toggle this
{
fprintf (stderr, "[%02X] ", x);
}
if (opts->payload == 1 && i == 6) //7th octet should only contain 1 bit? value will be either 0x00 or 0x80?
{
fprintf (stderr, "[%02X] ", x & 0x80); //7th octet should only contain 1 bit?
}
}
if (opts->payload == 1)
{

View File

@@ -253,8 +253,10 @@ processFrame (dsd_opts * opts, dsd_state * state)
else if ((state->synctype == 21) || (state->synctype == 25))
{
/* dPMR Frame Sync 2 */
fprintf(stderr, "dPMR Frame sync 2 ");
{
//for (short o = 0; o < 2; o++)
//{
fprintf(stderr, "dPMR Frame sync 2 ");
//state->rf_mod = GFSK_MODE;
state->nac = 0;
state->lastsrc = 0;
@@ -268,14 +270,16 @@ processFrame (dsd_opts * opts, dsd_state * state)
}
}
state->nac = 0;
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
sprintf(state->fsubtype, " VOICE ");
processdPMRvoice (opts, state);
if ((opts->mbe_out_dir[0] != 0) && (opts->mbe_out_f == NULL))
{
openMbeOutFile (opts, state);
}
sprintf(state->fsubtype, " VOICE ");
processdPMRvoice (opts, state);
//}
return;
}
}
else if ((state->synctype == 22) || (state->synctype == 26))
{

View File

@@ -188,6 +188,13 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
lidx = 0;
lastt = 0;
state->numflips = 0;
//move ncursesPrinter outside of the sync loop, causes weird lag inside the loop
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
if ((opts->symboltiming == 1) && (state->carrier == 1))
{
fprintf (stderr,"\nSymbol Timing:\n");
@@ -195,18 +202,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
}
while (sync == 0)
{
//fprintf (stderr,"now=%d\n", now); //okay, so this is incrementing as expected
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
/*
if (opts->reset_state == 1 && state->carrier == 0)
{
resetState (state);
}
*/
t++;
symbol = getSymbol (opts, state, 0);
@@ -594,7 +590,82 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
}
}
*/
// lwvmobile dPMR sync
strncpy(synctest, (synctest_p - 23), 24);
strncpy(synctest12, (synctest_p - 11), 12);
if(opts->frame_dpmr == 1)
{
if (opts->inverted_dpmr == 0)
{
if(strcmp(synctest, DPMR_FRAME_SYNC_1) == 0)
{
fprintf (stderr, "DPMR_FRAME_SYNC_1\n");
}
if(strcmp(synctest12, DPMR_FRAME_SYNC_2) == 0)
{
fprintf (stderr, "DPMR_FRAME_SYNC_2\n");
state->carrier = 1;
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
sprintf(state->ftype, "dPMR ");
if (opts->errorbars == 1)
{
printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 21;
return (21);
}
if(strcmp(synctest12, DPMR_FRAME_SYNC_3) == 0)
{
fprintf (stderr, "DPMR_FRAME_SYNC_3\n");
}
if(strcmp(synctest, DPMR_FRAME_SYNC_4) == 0)
{
fprintf (stderr, "DPMR_FRAME_SYNC_4\n");
}
}
if (opts->inverted_dpmr == 1)
{
if(strcmp(synctest, INV_DPMR_FRAME_SYNC_1) == 0)
{
fprintf (stderr, "INV_DPMR_FRAME_SYNC_1\n");
}
if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_2) == 0)
{
fprintf (stderr, "INV_DPMR_FRAME_SYNC_2\n");
state->carrier = 1;
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2;
sprintf(state->ftype, "dPMR ");
if (opts->errorbars == 1)
{
printFrameSync (opts, state, "-dPMR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 25;
return (25);
}
if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_3) == 0)
{
fprintf (stderr, "INV_DPMR_FRAME_SYNC_3\n");
}
if(strcmp(synctest, INV_DPMR_FRAME_SYNC_4) == 0)
{
fprintf (stderr, "INV_DPMR_FRAME_SYNC_4\n");
}
}
}
//LEH dPMR
/*
if(opts->frame_dpmr == 1)
{
strncpy(synctest, (synctest_p - 23), 24);
@@ -604,11 +675,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
{
if (opts->inverted_dpmr == 0)
{
//fprintf(stderr, "DPMR_FRAME_SYNC_1\n"); // TODO : To be removed
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;
@@ -619,28 +690,28 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation);
}
/* The next part of the superframe will normally be the first part */
//The next part of the superframe will normally be the first part
//opts->dPMR_next_part_of_superframe = 1;
state->lastsynctype = 20;
return (20);
}
else
{
state->lastsynctype = 20;
}
} /* End if (opts->inverted_dpmr == 0) */
//}
//else
//{
// state->lastsynctype = 20;
//}
} //End if (opts->inverted_dpmr == 0)
}
else if(strcmp(synctest12, DPMR_FRAME_SYNC_2) == 0)
if(strcmp(synctest12, DPMR_FRAME_SYNC_2) == 0)
{
if (opts->inverted_dpmr == 0)
{
//fprintf(stderr, "DPMR_FRAME_SYNC_2\n"); // TODO : To be removed
fprintf(stderr, "DPMR_FRAME_SYNC_2\n"); // TODO : To be removed
// TODO : Modif 2019-01-04
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;
@@ -655,18 +726,18 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->lastsynctype = 21;
return (21);
// TODO : Modif 2019-01-04
}
else
{
state->lastsynctype = 21;
}
//}
//else
//{
// state->lastsynctype = 21;
//}
}
}
else if(strcmp(synctest12, DPMR_FRAME_SYNC_3) == 0)
{
if (opts->inverted_dpmr == 0)
{
//fprintf(stderr, "DPMR_FRAME_SYNC_3\n"); // TODO : To be removed
//if (opts->inverted_dpmr == 0)
//{
fprintf(stderr, "DPMR_FRAME_SYNC_3\n"); // TODO : To be removed
if ((state->lastsynctype == 20) || (state->lastsynctype == 21) ||
(state->lastsynctype == 22) || (state->lastsynctype == 23))
@@ -681,16 +752,16 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation);
}
/* The next part of the superframe will normally be the first part */
//The next part of the superframe will normally be the first part
//opts->dPMR_next_part_of_superframe = 1;
state->lastsynctype = 22;
return (22);
}
else
{
state->lastsynctype = 22;
}
//}
//else
//{
// state->lastsynctype = 22;
//}
}
}
if(strcmp(synctest, DPMR_FRAME_SYNC_4) == 0)
@@ -699,9 +770,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;
@@ -712,26 +783,26 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+dPMR ", synctest_pos + 1, modulation);
}
/* The next part of the superframe will normally be the first part */
//The next part of the superframe will normally be the first part
//opts->dPMR_next_part_of_superframe = 1;
state->lastsynctype = 23;
return (23);
}
else
{
state->lastsynctype = 23;
}
//}
//else
//{
// state->lastsynctype = 23;
//}
}
}
else if(strcmp(synctest, INV_DPMR_FRAME_SYNC_1) == 0)
if(strcmp(synctest, INV_DPMR_FRAME_SYNC_1) == 0)
{
if (opts->inverted_dpmr)
if (opts->inverted_dpmr == 1)
{
//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))
{
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))
//{
state->carrier = 1;
state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2;
@@ -743,22 +814,22 @@ 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)
if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_2) == 0)
{
if (opts->inverted_dpmr)
if (opts->inverted_dpmr == 1)
{
//fprintf(stderr, "DPMR_FRAME_SYNC_2\n"); // TODO : To be removed
fprintf(stderr, "INV_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;
@@ -770,22 +841,22 @@ 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)
if(strcmp(synctest12, INV_DPMR_FRAME_SYNC_3) == 0)
{
if (opts->inverted_dpmr)
if (opts->inverted_dpmr == 1)
{
//fprintf(stderr, "INV_DPMR_FRAME_SYNC_3\n"); // TODO : To be removed
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;
@@ -797,22 +868,22 @@ 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)
{
if (opts->inverted_dpmr)
if (opts->inverted_dpmr == 1)
{
//fprintf(stderr, "INV_DPMR_FRAME_SYNC_4\n"); // TODO : To be removed
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;
@@ -825,21 +896,22 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->lastsynctype = 27;
return (27);
}
else
{
state->lastsynctype = 27;
}
}
//else
//{
// state->lastsynctype = 27;
//}
//}
}
else
{
/* No dPMR frame sync detected */
}
} /* End if(opts->frame_dpmr == 1) */
//else
//{
// No dPMR frame sync detected
//}
} // End if(opts->frame_dpmr == 1)
*/
//
//LEH dPMR
/* //testing frame syncs here for better performance
//testing frame syncs here for better performance
/*
if(opts->frame_dpmr == 1)
{
strncpy(synctest, (synctest_p - 23), 24);
@@ -1126,6 +1198,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+DMR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 10;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (10);
}
else
@@ -1141,6 +1218,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1;
}
state->lastsynctype = 11;
if ( opts->monitor_input_audio == 1)
{
pa_simple_drain(opts->pulse_raw_dev_out, NULL);
}
return (11);
}
}
@@ -1161,6 +1242,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+DMR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 10;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (10);
}
else
@@ -1176,6 +1262,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1;
}
state->lastsynctype = 11;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (11);
}
} /* End if(strcmp (synctest, DMR_DIRECT_MODE_TS1_DATA_SYNC) == 0) */
@@ -1196,6 +1287,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+DMR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 10;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (10);
}
else
@@ -1211,6 +1307,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1;
}
state->lastsynctype = 11;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (11);
}
} /* End if(strcmp (synctest, DMR_DIRECT_MODE_TS2_DATA_SYNC) == 0) */
@@ -1245,6 +1346,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-DMR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 13;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (13);
}
}
@@ -1269,6 +1375,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1;
}
state->lastsynctype = 12;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (12);
}
else
@@ -1304,6 +1415,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->firstframe = 1;
}
state->lastsynctype = 12;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (12);
}
else
@@ -1315,6 +1431,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-DMR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 13;
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (13);
}
} //End if(strcmp (synctest, DMR_DIRECT_MODE_TS2_VOICE_SYNC) == 0)
@@ -1338,9 +1459,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-ProVoice ", synctest_pos + 1, modulation);
}
state->lastsynctype = 14;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (14);
}
@@ -1357,9 +1479,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-ProVoice ", synctest_pos + 1, modulation);
}
state->lastsynctype = 15;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (15);
}
@@ -1385,6 +1508,11 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
{
//sprintf (state->ftype, " NXDN48 ");
sprintf (state->ftype, "NXDN48 "); //get rid of spaces
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
if (opts->errorbars == 1)
{
//printFrameSync (opts, state, " +NXDN48 ", synctest_pos + 1, modulation);
@@ -1394,16 +1522,18 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
else
{
sprintf (state->ftype, "NXDN96");
if ( opts->monitor_input_audio == 1)
{
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
if (opts->errorbars == 1)
{
printFrameSync (opts, state, " +NXDN96 ", synctest_pos + 1, modulation);
}
}
state->lastsynctype = 8;
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (8);
}
else
@@ -1443,9 +1573,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
}
}
state->lastsynctype = 9;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (9);
}
@@ -1484,9 +1615,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
}
}
state->lastsynctype = 16;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (16);
}
@@ -1526,9 +1658,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
}
}
state->lastsynctype = 17;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (17);
}
@@ -1555,9 +1688,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+D-STAR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 6;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (6);
}
@@ -1574,9 +1708,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-D-STAR ", synctest_pos + 1, modulation);
}
state->lastsynctype = 7;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (7);
}
@@ -1593,9 +1728,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "+D-STAR_HD ", synctest_pos + 1, modulation);
}
state->lastsynctype = 18;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (18);
}
@@ -1612,9 +1748,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "-D-STAR_HD ", synctest_pos + 1, modulation);
}
state->lastsynctype = 19;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (19);
}
@@ -1635,11 +1772,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(+P25p1) ", synctest_pos + 1, modulation);
}
state->lastsynctype = -1;
//do we want ncursesPrinter here??
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (0);
}
else if ((state->lastsynctype == 1) && ((state->lastp25type == 1) || (state->lastp25type == 2)))
@@ -1654,10 +1787,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(-P25p1) ", synctest_pos + 1, modulation);
}
state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (1);
}
else if ((state->lastsynctype == 3) && ((strcmp (synctest, X2TDMA_BS_VOICE_SYNC) != 0) || (strcmp (synctest, X2TDMA_MS_VOICE_SYNC) != 0)))
@@ -1672,10 +1802,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(-X2-TDMA) ", synctest_pos + 1, modulation);
}
state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (3);
}
else if ((state->lastsynctype == 4) && ((strcmp (synctest, X2TDMA_BS_DATA_SYNC) != 0) || (strcmp (synctest, X2TDMA_MS_DATA_SYNC) != 0)))
@@ -1690,10 +1817,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(+X2-TDMA) ", synctest_pos + 1, modulation);
}
state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1)
{
ncursesPrinter(opts, state);
}
return (4);
}
else if ((state->lastsynctype == 11) && ((strcmp (synctest, DMR_BS_VOICE_SYNC) != 0) || (strcmp (synctest, DMR_MS_VOICE_SYNC) != 0)))
@@ -1708,9 +1832,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(-DMR) ", synctest_pos + 1, modulation);
}
state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (11);
}
@@ -1726,9 +1851,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
printFrameSync (opts, state, "(+DMR) ", synctest_pos + 1, modulation);
}
state->lastsynctype = -1;
if (opts->use_ncurses_terminal == 1)
if ( opts->monitor_input_audio == 1)
{
ncursesPrinter(opts, state);
//pa_simple_drain(opts->pulse_raw_dev_out, NULL);
pa_simple_flush(opts->pulse_raw_dev_out, NULL);
}
return (12);
}
@@ -1751,18 +1877,22 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
synctest_pos = 0;
synctest_p = synctest_buf;
noCarrier (opts, state);
}
if (state->lastsynctype != 1)
{
if (synctest_pos >= 1800)
{
if ((opts->errorbars == 1) && (opts->verbose > 1) && (state->carrier == 1))
{
fprintf (stderr,"Sync: no sync\n");
fprintf (stderr,"Press CTRL + C to close.\n"); //Kindly remind user to double tap CTRL + C
}
}
noCarrier (opts, state);
/*
if (opts->reset_state == 1)
{
@@ -1775,7 +1905,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
if ( opts->monitor_input_audio == 1 && (time(NULL) - now) > 1 ) //okay, still something going on, still doing the read part for some reason
//if ( opts->monitor_input_audio == 1)
{
playRawAudio(opts, state); //this is on line 21 in dsd_audio.c
//playRawAudio(opts, state); //this is on line 21 in dsd_audio.c
}
}

View File

@@ -190,6 +190,7 @@ initOpts (dsd_opts * opts)
opts->rtl_volume_multiplier = 1; //set multipler from rtl sample to 'boost volume'
opts->rtl_udp_port = 6020; //set UDP port for RTL remote
opts->rtl_bandwidth = 12; //changed recommended default to 12, 24 for ProVoice
opts->rtlsdr_ppm_error = 0; //initialize ppm with 0 value; bug reported by N.
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_digi_rate_in = 48000;
@@ -438,14 +439,16 @@ void
liveScanner (dsd_opts * opts, dsd_state * state)
{
//need to use this area to configure audio rates for different sources if not pulse
if (opts->audio_in_type == 1) //if stdin, switch to 8000 and single channel audio
{
opts->pulse_digi_rate_out = 8000; //stdin needs 8000 output, could have sworn this was working with 48000
opts->pulse_digi_out_channels = 1;
opts->pulse_raw_rate_out = 8000;
opts->pulse_raw_rate_out = 48000;
opts->pulse_raw_out_channels = 1;
fprintf (stderr, "STDIN Audio Rate Out set to 8000 Khz/1 Channel \n");
}
#ifdef USE_PORTAUDIO
if(opts->audio_in_type == 2)
{
@@ -464,7 +467,7 @@ if (opts->audio_in_type == 1) //if stdin, switch to 8000 and single channel audi
{
opts->pulse_digi_rate_out = 8000; //if rtl, switch to 8000 and 1 channel
opts->pulse_digi_out_channels = 1;
opts->pulse_raw_rate_out = 8000;
opts->pulse_raw_rate_out = 48000;
opts->pulse_raw_out_channels = 1;
fprintf (stderr, "RTL Audio Rate Out set to 8000 Khz/1 Channel \n");
open_rtlsdr_stream(opts);
@@ -476,16 +479,20 @@ if (opts->audio_in_type == 0){
if (opts->audio_out_type == 0){
openPulseOutput(opts);
}
//openPulse(opts);
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);
@@ -734,7 +741,10 @@ main (int argc, char **argv)
case 'K':
sscanf (optarg, "%lld", &state.K);
state.K = ( ((state.K & 0xFF0F) << 32 ) + (state.K << 16) + state.K );
if (state.K > 256)
{
state.K = 256;
}
break;
case 'G': //Set rtl device gain
@@ -763,18 +773,8 @@ main (int argc, char **argv)
case 'W': //monitor_input_audio if no sync
opts.monitor_input_audio = 1;
fprintf (stderr,"Monitor Source Audio Enabled.\n");
//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_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_raw_in_channels = 1;
//opts.pulse_raw_out_channels = 1;
//opts.pulse_digi_in_channels = 1; //2
//opts.pulse_digi_out_channels = 1; //2
fprintf (stderr," Monitor Source Audio may cause decoding issues.\n");
fprintf (stderr," Don't Run Monitor Source Audio with Ncurses Terminal.\n");
opts.use_ncurses_terminal = 0; //may not set depends on when -N and -W are first and second
fprintf (stderr,"Monitoring Source Audio when carrier present and No Sync Detected.\n");
fprintf (stderr," - May cause Pulse Audio Server to crash on some systems.\n");
break;
case 'N':
@@ -1141,7 +1141,7 @@ main (int argc, char **argv)
if (opts.use_ncurses_terminal == 1)
{
ncursesOpen();
ncursesPrinter(&opts, &state);
//ncursesPrinter(&opts, &state);
}
if (opts.resume > 0)
@@ -1231,7 +1231,7 @@ main (int argc, char **argv)
}
if (opts.use_ncurses_terminal == 1){
ncursesClose ();
//ncursesClose ();
}
cleanupAndExit (&opts, &state);

View File

@@ -47,7 +47,9 @@ playMbeFiles (dsd_opts * opts, dsd_state * state, int argc, char **argv)
if (opts->audio_out == 1)
{
playSynthesizedVoice (opts, state);
}
}
else if (state->mbe_file_type == 1)

View File

@@ -275,6 +275,10 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
{
printw ("| Pulse Audio Output [%i] kHz [%i] Channel\n", opts->pulse_digi_rate_out/1000, opts->pulse_digi_out_channels);
}
if (opts->monitor_input_audio == 1)
{
printw ("| Monitoring Source Audio when carrier present and No Sync Detected\n");
}
if (opts->mbe_out_dir[0] != 0)
{
printw ("| Writing MBE data files to directory %s\n", opts->mbe_out_dir);
@@ -441,8 +445,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
//printw ("| DCC: [%i] FID: [%02X]\n", dcc, state->dmr_fid);
//attron(COLOR_PAIR(3));
printw ("| DCC: [%2i] FID: [%02X] SOP: [%02X] ", dcc, state->dmr_fid, state->dmr_so);
//if(state->payload_mi == 0 && state->dmr_so & 0x40)
if(state->payload_mi == 0 && state->dmr_so == 0x40)
if(state->payload_mi == 0 && state->dmr_so & 0x40)
//if(state->payload_mi == 0 && state->dmr_so == 0x40)
{
attron(COLOR_PAIR(5));
printw ("**BP** ");
@@ -450,8 +454,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
attroff(COLOR_PAIR(5));
attron(COLOR_PAIR(3));
}
//if(state->payload_keyid > 0 && state->dmr_so & 0x40)
if(state->payload_keyid > 0 && state->dmr_so == 0x40)
if(state->payload_keyid > 0 && state->dmr_so & 0x40)
//if(state->payload_keyid > 0 && state->dmr_so == 0x40)
{
attron(COLOR_PAIR(5));
printw (" ALG: [0x%02X] KEY [0x%02X] MI [0x%08X]", state->payload_algid, state->payload_keyid, state->payload_mi);
@@ -459,11 +463,11 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
attroff(COLOR_PAIR(5));
attron(COLOR_PAIR(3));
}
//if(state->K > 0 && state->dmr_so & 0x40)
if(state->K > 0 && state->dmr_so == 0x40)
if(state->K > 0 && state->payload_keyid == 0 && state->dmr_so & 0x40)
//if(state->K > 0 && state->dmr_so == 0x40)
{
attron(COLOR_PAIR(5));
//printw ("K 0x[%12llX]", state->K); //seems to get reset in ncurses for some reason? some bigger issue perhaps? other strange issues occur too with provoice
printw ("BPK [%3d]", state->K);
attroff(COLOR_PAIR(5));
attron(COLOR_PAIR(3));
}

View File

@@ -84,10 +84,21 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
if(opts->audio_in_type == 0)
{
pa_simple_read(opts->pulse_digi_dev_in, &sample, 2, NULL );
state->pulse_raw_out_buffer = sample; //steal raw out buffer sample here?
//look into how processAudio handles playback, not sure if latency issues, or garbage sample values crash pulse when written
if (opts->monitor_input_audio == 1 && state->lastsynctype == -1 && sample < 32767 && sample > -32767)
{
state->pulse_raw_out_buffer = sample; //steal raw out buffer sample here?
pa_simple_write(opts->pulse_raw_dev_out, (void*)&state->pulse_raw_out_buffer, 2, NULL);
}
}
else if (opts->audio_in_type == 1) {
result = sf_read_short(opts->audio_in_file, &sample, 1);
if (opts->monitor_input_audio == 1 && state->lastsynctype == -1 && sample < 32767 && sample > -32767)
{
state->pulse_raw_out_buffer = sample; //steal raw out buffer sample here?
pa_simple_write(opts->pulse_raw_dev_out, (void*)&state->pulse_raw_out_buffer, 2, NULL);
}
if(result == 0) {
cleanupAndExit (opts, state);
}
@@ -111,7 +122,11 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
#ifdef USE_RTLSDR
// TODO: need to read demodulated stream here
get_rtlsdr_sample(&sample);
//state->pulse_raw_out_buffer = sample;
if (opts->monitor_input_audio == 1 && state->lastsynctype == -1 && sample < 32767 && sample > -32767)
{
state->pulse_raw_out_buffer = sample; //steal raw out buffer sample here?
pa_simple_write(opts->pulse_raw_dev_out, (void*)&state->pulse_raw_out_buffer, 2, NULL);
}
#endif
}