diff options
Diffstat (limited to 'unittest/freedv_700d_comptx.c')
| -rw-r--r-- | unittest/freedv_700d_comptx.c | 44 |
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; +} |
