From df7d2d3147671e8d83f2047d72ba05c5ab846a6b Mon Sep 17 00:00:00 2001 From: "Joseph D. Gaeddert" Date: Tue, 21 May 2024 13:18:27 -0400 Subject: [PATCH] nco: adding test for spectral cleanliness --- makefile.in | 3 +- src/nco/tests/nco_crcf_spectrum_autotest.c | 84 ++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/nco/tests/nco_crcf_spectrum_autotest.c diff --git a/makefile.in b/makefile.in index e8b69fa61..a276291a8 100644 --- a/makefile.in +++ b/makefile.in @@ -1,4 +1,4 @@ -# Copyright (c) 2007 - 2023 Joseph Gaeddert +# Copyright (c) 2007 - 2024 Joseph Gaeddert # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -977,6 +977,7 @@ nco_autotests := \ src/nco/tests/nco_crcf_mix_autotest.c \ src/nco/tests/nco_crcf_phase_autotest.c \ src/nco/tests/nco_crcf_pll_autotest.c \ + src/nco/tests/nco_crcf_spectrum_autotest.c \ src/nco/tests/unwrap_phase_autotest.c \ # additional autotest objects diff --git a/src/nco/tests/nco_crcf_spectrum_autotest.c b/src/nco/tests/nco_crcf_spectrum_autotest.c new file mode 100644 index 000000000..d4ae32cf6 --- /dev/null +++ b/src/nco/tests/nco_crcf_spectrum_autotest.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2007 - 2024 Joseph Gaeddert + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include "autotest/autotest.h" +#include "liquid.h" + +// autotest helper function +// _type : NCO type (e.g. LIQUID_NCO) +// _freq : normalized frequency (f/Fs), _freq in [-0.5,0.5) +void nco_crcf_spectrum_test(int _type, float _freq) +{ + unsigned long int num_samples = 1UL<<16; + unsigned int nfft = 9600; + + // create object and initialize + nco_crcf nco = nco_crcf_create(_type); + nco_crcf_set_frequency(nco, 2*M_PI*_freq); + + // sample buffer + unsigned int buf_len = 3*nfft; + float complex buf_0[buf_len]; + float complex buf_1[buf_len]; + unsigned int i; + for (i=0; i