aboutsummaryrefslogtreecommitdiff
path: root/unittest/freedv_700d_comptx.c
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2025-07-25 10:17:14 +0300
committerMarin Ivanov <[email protected]>2026-01-18 20:09:26 +0200
commit0168586485e6310c598713c911b1dec5618d61a1 (patch)
tree6aabc2a12ef8fef70683f5389bea00f948015f77 /unittest/freedv_700d_comptx.c
Initial commitHEADmaster
* codec2 cut-down version 1.2.0 * Remove codebook and generation of sources * remove c2dec c2enc binaries * prepare for emscripten
Diffstat (limited to 'unittest/freedv_700d_comptx.c')
-rw-r--r--unittest/freedv_700d_comptx.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/unittest/freedv_700d_comptx.c b/unittest/freedv_700d_comptx.c
new file mode 100644
index 0000000..9f66c76
--- /dev/null
+++ b/unittest/freedv_700d_comptx.c
@@ -0,0 +1,44 @@
+/*---------------------------------------------------------------------------*\
+
+ freedv_comptx.c
+
+ Complex valued Tx to support ctests.
+
+\*---------------------------------------------------------------------------*/
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "freedv_api.h"
+
+int main(int argc, char *argv[]) {
+ struct freedv *freedv;
+
+ freedv = freedv_open(FREEDV_MODE_700D);
+ assert(freedv != NULL);
+
+ /* handy functions to set buffer sizes */
+ int n_speech_samples = freedv_get_n_speech_samples(freedv);
+ short speech_in[n_speech_samples];
+ int n_nom_modem_samples = freedv_get_n_nom_modem_samples(freedv);
+ COMP mod_out[n_nom_modem_samples];
+ short mod_out_short[2 * n_nom_modem_samples];
+
+ /* OK main loop --------------------------------------- */
+
+ while (fread(speech_in, sizeof(short), n_speech_samples, stdin) ==
+ n_speech_samples) {
+ freedv_comptx(freedv, mod_out, speech_in);
+ for (int i = 0; i < n_nom_modem_samples; i++) {
+ mod_out_short[2 * i] = mod_out[i].real;
+ mod_out_short[2 * i + 1] = mod_out[i].imag;
+ }
+ fwrite(mod_out_short, sizeof(short), 2 * n_nom_modem_samples, stdout);
+ }
+
+ freedv_close(freedv);
+
+ return 0;
+}