diff options
| author | drowe67 <[email protected]> | 2023-07-20 08:59:48 +0930 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-20 08:59:48 +0930 |
| commit | 06d4c11e699b0351765f10398abb4f663a984f36 (patch) | |
| tree | 33e22af0814c5b6c3d676f096ae8c2ac8a3ed9f0 /unittest/t48_8.c | |
| parent | 6588e77f38bdebd7adffe091b22e7760d95d0ccb (diff) | |
| parent | 4d6c143c0abec15e1d6ed1fd95d36f80e6cb7df8 (diff) | |
Merge pull request #3 from drowe67/dr-cleanup21.2.0
Cleanup Part 2
Diffstat (limited to 'unittest/t48_8.c')
| -rw-r--r-- | unittest/t48_8.c | 129 |
1 files changed, 61 insertions, 68 deletions
diff --git a/unittest/t48_8.c b/unittest/t48_8.c index 2e277a3..88aa929 100644 --- a/unittest/t48_8.c +++ b/unittest/t48_8.c @@ -18,94 +18,87 @@ #include <assert.h> #include <math.h> -#include <stdlib.h> #include <stdio.h> +#include <stdlib.h> + #include "codec2_fdmdv.h" -#define N8 180 /* processing buffer size at 8 kHz */ -#define N48 (N8*FDMDV_OS_48) -#define MEM8 FDMDV_OS_TAPS_48_8K -#define FRAMES 50 -#define TWO_PI 6.283185307 -#define FS 48000 +#define N8 180 /* processing buffer size at 8 kHz */ +#define N48 (N8 * FDMDV_OS_48) +#define MEM8 FDMDV_OS_TAPS_48_8K +#define FRAMES 50 +#define TWO_PI 6.283185307 +#define FS 48000 #define SINE int main() { - float in8k[MEM8 + N8]; - short in8k_short[N8]; - float out48k[N48]; - short out48k_short[N48]; - FILE *f48; - - float in48k[FDMDV_OS_TAPS_48K + N48]; - float out8k[N48]; - short out8k_short[N8]; - FILE *f8, *f8in; - - int i,f,t,t1; - float freq = 800.0; - - f48 = fopen("out48.raw", "wb"); - assert(f48 != NULL); - f8 = fopen("out8.raw", "wb"); - assert(f8 != NULL); - f8in = fopen("in8.raw", "wb"); - assert(f8in != NULL); - - /* clear filter memories */ - - for(i=0; i<MEM8; i++) - in8k[i] = 0.0; - for(i=0; i<FDMDV_OS_TAPS_48K; i++) - in48k[i] = 0.0; - - t = t1 = 0; - for(f=0; f<FRAMES; f++) { - + float in8k[MEM8 + N8]; + short in8k_short[N8]; + float out48k[N48]; + short out48k_short[N48]; + FILE *f48; + + float in48k[FDMDV_OS_TAPS_48K + N48]; + float out8k[N48]; + short out8k_short[N8]; + FILE *f8, *f8in; + + int i, f, t, t1; + float freq = 800.0; + + f48 = fopen("out48.raw", "wb"); + assert(f48 != NULL); + f8 = fopen("out8.raw", "wb"); + assert(f8 != NULL); + f8in = fopen("in8.raw", "wb"); + assert(f8in != NULL); + + /* clear filter memories */ + + for (i = 0; i < MEM8; i++) in8k[i] = 0.0; + for (i = 0; i < FDMDV_OS_TAPS_48K; i++) in48k[i] = 0.0; + + t = t1 = 0; + for (f = 0; f < FRAMES; f++) { #ifdef DC - for(i=0; i<N8; i++) - in8k[MEM8+i] = 16000.0; + for (i = 0; i < N8; i++) in8k[MEM8 + i] = 16000.0; #endif #ifdef SINE - for(i=0; i<N8; i++,t++) - in8k[MEM8+i] = 16000.0*cos(TWO_PI*t*freq/(FS/FDMDV_OS_48)); + for (i = 0; i < N8; i++, t++) + in8k[MEM8 + i] = 16000.0 * cos(TWO_PI * t * freq / (FS / FDMDV_OS_48)); #endif - for(i=0; i<N8; i++) - in8k_short[i] = (short)in8k[i]; - fwrite(in8k_short, sizeof(short), N8, f8in); - - /* upsample */ - - fdmdv_8_to_48(out48k, &in8k[MEM8], N8); + for (i = 0; i < N8; i++) in8k_short[i] = (short)in8k[i]; + fwrite(in8k_short, sizeof(short), N8, f8in); - /* save 48k to disk for plotting and check out */ + /* upsample */ - for(i=0; i<N48; i++) - out48k_short[i] = (short)out48k[i]; - fwrite(out48k_short, sizeof(short), N48, f48); + fdmdv_8_to_48(out48k, &in8k[MEM8], N8); - /* add a 10 kHz spurious signal for fun, we want down sampler to - knock this out */ + /* save 48k to disk for plotting and check out */ - for(i=0; i<N48; i++,t1++) - in48k[i+FDMDV_OS_TAPS_48K] = out48k[i] + 16000.0*cos(TWO_PI*t1*1E4/FS); + for (i = 0; i < N48; i++) out48k_short[i] = (short)out48k[i]; + fwrite(out48k_short, sizeof(short), N48, f48); - /* downsample */ + /* add a 10 kHz spurious signal for fun, we want down sampler to + knock this out */ - fdmdv_48_to_8(out8k, &in48k[FDMDV_OS_TAPS_48K], N8); + for (i = 0; i < N48; i++, t1++) + in48k[i + FDMDV_OS_TAPS_48K] = + out48k[i] + 16000.0 * cos(TWO_PI * t1 * 1E4 / FS); - /* save 8k to disk for plotting and check out */ + /* downsample */ - for(i=0; i<N8; i++) - out8k_short[i] = (short)out8k[i]; - fwrite(out8k_short, sizeof(short), N8, f8); + fdmdv_48_to_8(out8k, &in48k[FDMDV_OS_TAPS_48K], N8); - } + /* save 8k to disk for plotting and check out */ - fclose(f48); - fclose(f8); - fclose(f8in); - return 0; + for (i = 0; i < N8; i++) out8k_short[i] = (short)out8k[i]; + fwrite(out8k_short, sizeof(short), N8, f8); + } + fclose(f48); + fclose(f8); + fclose(f8in); + return 0; } |
