kopia lustrzana https://github.com/kgoba/ft8_lib
[RFC] Enable usage of externally supplied 'TONES DATA'
Motivation: Currently, ft8_lib cannot encode free-text messages. Usage: ``` $ ft8code "U09TUNQUC9ZH" ... 3140652 00545736465273610247324500636 3140652 55505324500472027752070701676 3140652 ``` ``` $ export DEBUG_TONES_DATA="3140652 00545736465273610247324500636 3140652 55505324500472027752070701676 3140652" $ ./gen_ft8 "U09TUNQUC9ZH" compatible.wav Note: DEBUG_TONES_DATA is set! Using it to generate the WAVE file... FSK tones: 3140652005457364652736102473245006363140652555053245004720277520707016763140652 ``` WSJT-X then decodes the generated compatible.wav file just fine.pull/39/head
rodzic
50ee0c0636
commit
86eee8928b
|
@ -1,3 +1,5 @@
|
||||||
|
#define _POSIX_C_SOURCE 199309L
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -120,6 +120,7 @@ int main(int argc, char** argv)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t tones[128]; // Array of 79 tones (symbols)
|
||||||
const char* message = argv[1];
|
const char* message = argv[1];
|
||||||
const char* wav_path = argv[2];
|
const char* wav_path = argv[2];
|
||||||
float frequency = 1000.0;
|
float frequency = 1000.0;
|
||||||
|
@ -128,6 +129,15 @@ int main(int argc, char** argv)
|
||||||
frequency = atof(argv[3]);
|
frequency = atof(argv[3]);
|
||||||
}
|
}
|
||||||
bool is_ft4 = (argc > 4) && (0 == strcmp(argv[4], "-ft4"));
|
bool is_ft4 = (argc > 4) && (0 == strcmp(argv[4], "-ft4"));
|
||||||
|
int num_tones = (is_ft4) ? FT4_NN : FT8_NN;
|
||||||
|
float symbol_period = (is_ft4) ? FT4_SYMBOL_PERIOD : FT8_SYMBOL_PERIOD;
|
||||||
|
float symbol_bt = (is_ft4) ? FT4_SYMBOL_BT : FT8_SYMBOL_BT;
|
||||||
|
float slot_time = (is_ft4) ? FT4_SLOT_TIME : FT8_SLOT_TIME;
|
||||||
|
|
||||||
|
if(getenv("DEBUG_TONES_DATA")) {
|
||||||
|
printf("Note: DEBUG_TONES_DATA is set! Using it to generate the WAVE file...\n");
|
||||||
|
goto DEBUG_TONES_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
// First, pack the text data into binary message
|
// First, pack the text data into binary message
|
||||||
ftx_message_t msg;
|
ftx_message_t msg;
|
||||||
|
@ -146,13 +156,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
int num_tones = (is_ft4) ? FT4_NN : FT8_NN;
|
|
||||||
float symbol_period = (is_ft4) ? FT4_SYMBOL_PERIOD : FT8_SYMBOL_PERIOD;
|
|
||||||
float symbol_bt = (is_ft4) ? FT4_SYMBOL_BT : FT8_SYMBOL_BT;
|
|
||||||
float slot_time = (is_ft4) ? FT4_SLOT_TIME : FT8_SLOT_TIME;
|
|
||||||
|
|
||||||
// Second, encode the binary message as a sequence of FSK tones
|
// Second, encode the binary message as a sequence of FSK tones
|
||||||
uint8_t tones[num_tones]; // Array of 79 tones (symbols)
|
|
||||||
if (is_ft4)
|
if (is_ft4)
|
||||||
{
|
{
|
||||||
ft4_encode(msg.payload, tones);
|
ft4_encode(msg.payload, tones);
|
||||||
|
@ -162,6 +166,18 @@ int main(int argc, char** argv)
|
||||||
ft8_encode(msg.payload, tones);
|
ft8_encode(msg.payload, tones);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG_TONES_DATA:
|
||||||
|
if(getenv("DEBUG_TONES_DATA")) {
|
||||||
|
char *tmp = getenv("DEBUG_TONES_DATA");
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < strlen(tmp); i++) {
|
||||||
|
if (tmp[i] == ' ')
|
||||||
|
continue;
|
||||||
|
tones[j++] = tmp[i] - '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("FSK tones: ");
|
printf("FSK tones: ");
|
||||||
for (int j = 0; j < num_tones; ++j)
|
for (int j = 0; j < num_tones; ++j)
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue