mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-20 04:37:26 -05:00
M17 - M17 STR Encoder Nucrses Support;
This commit is contained in:
@@ -785,6 +785,7 @@ typedef struct
|
|||||||
uint8_t m17_meta[16]; //packed meta
|
uint8_t m17_meta[16]; //packed meta
|
||||||
uint8_t m17_enc; //enc type
|
uint8_t m17_enc; //enc type
|
||||||
uint8_t m17_enc_st; //scrambler or data subtye
|
uint8_t m17_enc_st; //scrambler or data subtye
|
||||||
|
int m17encoder_tx; //if TX (encode + decode) M17 Stream is enabled
|
||||||
|
|
||||||
//misc str storage
|
//misc str storage
|
||||||
char str50a[50];
|
char str50a[50];
|
||||||
|
|||||||
@@ -1174,6 +1174,7 @@ initState (dsd_state * state)
|
|||||||
|
|
||||||
state->m17_enc = 0;
|
state->m17_enc = 0;
|
||||||
state->m17_enc_st = 0;
|
state->m17_enc_st = 0;
|
||||||
|
state->m17encoder_tx = 0;
|
||||||
memset(state->m17_meta, 0, sizeof(state->m17_meta));
|
memset(state->m17_meta, 0, sizeof(state->m17_meta));
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2551,6 +2551,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||||||
if (opts->mod_gfsk == 1) printw ("[GFSK]");
|
if (opts->mod_gfsk == 1) printw ("[GFSK]");
|
||||||
printw ( "[%d] \n", (48000*opts->wav_interpolator)/state->samplesPerSymbol);
|
printw ( "[%d] \n", (48000*opts->wav_interpolator)/state->samplesPerSymbol);
|
||||||
printw ("| Decoding: [%s] ", opts->output_name);
|
printw ("| Decoding: [%s] ", opts->output_name);
|
||||||
|
if (opts->m17encoder == 1) printw ("(\\) Toggle TX; ");
|
||||||
if (opts->aggressive_framesync == 0) printw ("CRC/(RAS) ");
|
if (opts->aggressive_framesync == 0) printw ("CRC/(RAS) ");
|
||||||
//debug -- troubleshoot voice tuning after grant on DMR CC, subsequent grant may not tune because tuner isn't available
|
//debug -- troubleshoot voice tuning after grant on DMR CC, subsequent grant may not tune because tuner isn't available
|
||||||
if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1) printw ("Tuner Locked ");
|
if (opts->p25_trunk == 1 && opts->p25_is_tuned == 1) printw ("Tuner Locked ");
|
||||||
@@ -3632,7 +3633,8 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||||||
//keyboard shortcuts - codes same as ascii codes
|
//keyboard shortcuts - codes same as ascii codes
|
||||||
if (c == 27) //esc key, open menu
|
if (c == 27) //esc key, open menu
|
||||||
{
|
{
|
||||||
ncursesMenu (opts, state); //just a quick test
|
if (opts->m17encoder == 0) //don't allow menu if using M17 encoder
|
||||||
|
ncursesMenu (opts, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
//use k and l keys to test tg hold toggles on slots 1 and slots 2
|
//use k and l keys to test tg hold toggles on slots 1 and slots 2
|
||||||
@@ -4366,6 +4368,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->m17encoder == 1 && c == 92) //'\' key - toggle M17 encoder Encode + TX
|
||||||
|
{
|
||||||
|
if (state->m17encoder_tx == 0) state->m17encoder_tx = 1;
|
||||||
|
else state->m17encoder_tx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//anything with an entry box will need the inputs and outputs stopped first
|
//anything with an entry box will need the inputs and outputs stopped first
|
||||||
//so probably just write a function to handle c input, and when c = certain values
|
//so probably just write a function to handle c input, and when c = certain values
|
||||||
//needing an entry box, then stop all of those
|
//needing an entry box, then stop all of those
|
||||||
|
|||||||
79
src/m17.c
79
src/m17.c
@@ -880,6 +880,13 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state)
|
|||||||
//TODO: Cleanup Tons of Unused Arrays and Variables
|
//TODO: Cleanup Tons of Unused Arrays and Variables
|
||||||
//TODO: Switch to M17 Viterbi Decoder?
|
//TODO: Switch to M17 Viterbi Decoder?
|
||||||
|
|
||||||
|
//Enable frame, TX and Ncurses Printer
|
||||||
|
opts->frame_m17 = 1;
|
||||||
|
state->m17encoder_tx = 1;
|
||||||
|
|
||||||
|
if (opts->use_ncurses_terminal == 1)
|
||||||
|
ncursesOpen(opts, state);
|
||||||
|
|
||||||
//User Defined Variables
|
//User Defined Variables
|
||||||
uint8_t can = 7;
|
uint8_t can = 7;
|
||||||
//numerical representation of dst and src after encoding, or special/reserved value
|
//numerical representation of dst and src after encoding, or special/reserved value
|
||||||
@@ -976,7 +983,7 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state)
|
|||||||
|
|
||||||
fprintf (stderr, "M17 Voice Stream Encoding: %ld Samples and %ld Bits Per Frame (3200 bps); ", nsam, nbit);
|
fprintf (stderr, "M17 Voice Stream Encoding: %ld Samples and %ld Bits Per Frame (3200 bps); ", nsam, nbit);
|
||||||
|
|
||||||
//TODO: Make this Ncurses + Transmit Button?
|
|
||||||
while (!exitflag) //while the software is running
|
while (!exitflag) //while the software is running
|
||||||
{
|
{
|
||||||
//read some audio samples from mic and load them into an audio buffer
|
//read some audio samples from mic and load them into an audio buffer
|
||||||
@@ -1246,38 +1253,58 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state)
|
|||||||
//-----------------------------------------
|
//-----------------------------------------
|
||||||
|
|
||||||
//decode stream with the M17STR_debug
|
//decode stream with the M17STR_debug
|
||||||
fprintf (stderr, "\n M17 STR (ENCODER): ");
|
if (state->m17encoder_tx == 1) //when enabled by user key press in ncurses
|
||||||
processM17STR_debug(opts, state, m17_t4s);
|
{
|
||||||
|
|
||||||
//load bits inti a dibit array plus the framesync bits
|
//Enable Carrier, synctype, etc
|
||||||
uint8_t output_dibits[192]; memset (output_dibits, 0, sizeof(output_dibits)); UNUSED(output_dibits);
|
state->carrier = 1;
|
||||||
for (i = 0; i < 8; i++)
|
state->synctype = 8;
|
||||||
output_dibits[i] = (m17_str_fs[i*2+0] << 1) + (m17_str_fs[i*2+1] << 0);
|
fprintf (stderr, "\n M17 STR (ENCODER): ");
|
||||||
|
processM17STR_debug(opts, state, m17_t4s);
|
||||||
|
|
||||||
//load rest of combined frame
|
//load bits inti a dibit array plus the framesync bits
|
||||||
for (i = 0; i < 184; i++)
|
uint8_t output_dibits[192]; memset (output_dibits, 0, sizeof(output_dibits)); UNUSED(output_dibits);
|
||||||
output_dibits[i+8] = (m17_t4s[i*2+0] << 1) + (m17_t4s[i*2+1] << 0);
|
for (i = 0; i < 8; i++)
|
||||||
|
output_dibits[i] = (m17_str_fs[i*2+0] << 1) + (m17_str_fs[i*2+1] << 0);
|
||||||
|
|
||||||
//Start working on converting the bitsream to an audio stream
|
//load rest of combined frame
|
||||||
|
for (i = 0; i < 184; i++)
|
||||||
|
output_dibits[i+8] = (m17_t4s[i*2+0] << 1) + (m17_t4s[i*2+1] << 0);
|
||||||
|
|
||||||
//convert to symbols @ 4800 bps
|
//Start working on converting the bitsream to an audio stream
|
||||||
int output_symbols[192]; memset (output_symbols, 0, sizeof(output_symbols)); UNUSED(output_symbols);
|
|
||||||
for (i = 0; i < 192; i++)
|
|
||||||
output_symbols[i] = symbol_map[output_dibits[i]];
|
|
||||||
|
|
||||||
//debug output symbols
|
//convert to symbols @ 4800 bps
|
||||||
// fprintf (stderr, "\n sym:");
|
int output_symbols[192]; memset (output_symbols, 0, sizeof(output_symbols)); UNUSED(output_symbols);
|
||||||
// for (i = 0; i < 192; i++)
|
for (i = 0; i < 192; i++)
|
||||||
// {
|
output_symbols[i] = symbol_map[output_dibits[i]];
|
||||||
// if (i%24 == 0) fprintf (stderr, "\n");
|
|
||||||
// fprintf (stderr, " %d", output_symbols[i]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
//TODO: symbols to audio
|
//debug output symbols
|
||||||
|
// fprintf (stderr, "\n sym:");
|
||||||
|
// for (i = 0; i < 192; i++)
|
||||||
|
// {
|
||||||
|
// if (i%24 == 0) fprintf (stderr, "\n");
|
||||||
|
// fprintf (stderr, " %d", output_symbols[i]);
|
||||||
|
// }
|
||||||
|
|
||||||
//end by incrementing lich_cnt, reset on 6
|
//TODO: symbols to audio
|
||||||
lich_cnt++;
|
|
||||||
if (lich_cnt == 6) lich_cnt = 0;
|
//end by incrementing lich_cnt, reset on 6
|
||||||
|
lich_cnt++;
|
||||||
|
if (lich_cnt == 6) lich_cnt = 0;
|
||||||
|
|
||||||
|
} //end if (state->m17encoder_tx)
|
||||||
|
|
||||||
|
else //if not tx, reset values, drop carrier and sync
|
||||||
|
{
|
||||||
|
lich_cnt = 0;
|
||||||
|
fsn = 0;
|
||||||
|
state->carrier = 0;
|
||||||
|
state->synctype = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//refresh ncurses printer
|
||||||
|
if (opts->use_ncurses_terminal == 1)
|
||||||
|
ncursesPrinter(opts, state);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user