41int main(
int argc,
char* argv[]) {
42 const char* opt_channels =
"1";
43 const char* opt_input_txt = NULL;
44 const char* opt_output_au = NULL;
49 double opt_freq = 800.0;
50 double opt_dit_period = 80.0;
51 double opt_slope_period = -1.0;
52 uint8_t total_audio_channels;
53 uint8_t select_audio_channels;
56 static struct option long_options[] = {
58 .has_arg = required_argument,
62 .has_arg = required_argument,
66 .has_arg = required_argument,
70 .has_arg = required_argument,
73 {.name =
"dit-period",
74 .has_arg = required_argument,
78 .has_arg = required_argument,
81 {.name = NULL, .has_arg = 0, .flag = NULL, .val = 0},
85 int c = getopt_long(argc, argv,
"B:C:R:S:d:f:", long_options,
89 }
else if (!c && !long_options[opt_idx].flag) {
90 c = long_options[opt_idx].val;
97 opt_bits = strtol(optarg, &endptr, 10);
130 "Invalid number of bits: %s\n"
131 "Supported values: 8, 16, 32/32s/32f "
138 opt_channels = optarg;
141 opt_rate = atoi(optarg);
144 opt_slope_period = strtod(optarg, &endptr);
146 fprintf(stderr,
"Invalid slope period: %s\n",
152 opt_dit_period = strtod(optarg, &endptr);
154 fprintf(stderr,
"Invalid dit period: %s\n",
160 opt_freq = strtod(optarg, &endptr);
162 fprintf(stderr,
"Invalid frequency: %s\n",
173 if ((argc - optind) != 2) {
177 opt_input_txt = argv[optind];
178 opt_output_au = argv[optind + 1];
180 switch (opt_channels[0]) {
185 total_audio_channels = 1;
186 select_audio_channels = 1;
192 total_audio_channels = 2;
193 select_audio_channels = UINT8_MAX;
198 total_audio_channels = 2;
199 select_audio_channels = 1;
204 total_audio_channels = 2;
205 select_audio_channels = 2;
208 printf(
"Unknown channel mode: %s\n", opt_channels);
212 if (opt_slope_period < 0) {
213 opt_slope_period = 0.2 * opt_dit_period;
220 opt_slope_period, opt_rate,
225 total_audio_channels);
227 fprintf(stderr,
"Failed to open output file %s: %s\n",
228 opt_output_au, strerror(-res));
234 double samples[total_audio_channels];
240 for (uint8_t ch = 0; ch < total_audio_channels; ch++) {
241 if (select_audio_channels & (1 << ch)) {
250 &au, total_audio_channels, samples);
252 fprintf(stderr,
"Failed to write audio samples: %s\n",
262 "Failed to close audio output file: %s\n",
void sstvenc_cw_init(struct sstvenc_cw_mod *const cw, const char *text, double amplitude, double frequency, double dit_period, double slope_period, uint32_t sample_rate, uint8_t time_unit)