From dd0d20921ba13713e3f70e94d9ba80ae89407c44 Mon Sep 17 00:00:00 2001 From: ha7ilm Date: Thu, 6 Apr 2017 22:03:09 +0200 Subject: [PATCH] Added simple_agc_cc GRC test --- csdr.c | 2 +- grc_tests/test_simple_agc.grc | 844 ++++++++++++++++++++++++++++++++++ libcsdr.c | 4 +- 3 files changed, 847 insertions(+), 3 deletions(-) create mode 100644 grc_tests/test_simple_agc.grc mode change 100644 => 100755 libcsdr.c diff --git a/csdr.c b/csdr.c index 6ddaa78..e4e0aeb 100755 --- a/csdr.c +++ b/csdr.c @@ -27,7 +27,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + #define _POSIX_C_SOURCE 199309L #define _BSD_SOURCE #define _GNU_SOURCE diff --git a/grc_tests/test_simple_agc.grc b/grc_tests/test_simple_agc.grc new file mode 100644 index 0000000..5e06234 --- /dev/null +++ b/grc_tests/test_simple_agc.grc @@ -0,0 +1,844 @@ + + + + Sun Nov 16 15:12:31 2014 + + options + + author + + + + window_size + 1280, 1024 + + + category + Custom + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (10, 10) + + + _rotation + 0 + + + generate_options + wx_gui + + + id + top_block + + + max_nouts + 0 + + + realtime_scheduling + + + + run_options + prompt + + + run + True + + + thread_safe_setters + + + + title + + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (10, 170) + + + _rotation + 0 + + + id + samp_rate + + + value + 48000 + + + + analog_agc_xx + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (432, 355) + + + _rotation + 0 + + + gain + 1 + + + id + analog_agc_xx_0 + + + max_gain + 65536 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + rate + 1e-2 + + + reference + 0.1 + + + type + complex + + + + audio_sink + + alias + + + + comment + + + + affinity + + + + device_name + + + + _enabled + True + + + _coordinate + (1152, 427) + + + _rotation + 0 + + + id + audio_sink_0 + + + num_inputs + 1 + + + ok_to_block + True + + + samp_rate + samp_rate + + + + band_reject_filter + + beta + 6.76 + + + alias + + + + comment + + + + affinity + + + + decim + 1 + + + _enabled + True + + + type + fir_filter_fff + + + _coordinate + (392, 35) + + + _rotation + 0 + + + gain + 1 + + + high_cutoff_freq + 2000 + + + id + band_reject_filter_0 + + + interp + 1 + + + low_cutoff_freq + 1600 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate + + + width + 50 + + + win + firdes.WIN_HAMMING + + + + blocks_complex_to_float + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (928, 289) + + + _rotation + 0 + + + id + blocks_complex_to_float_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_multiply_const_vxx + + alias + + + + comment + + + + const + 0.2 + + + affinity + + + + _enabled + True + + + _coordinate + (968, 427) + + + _rotation + 0 + + + id + blocks_multiply_const_vxx_0 + + + type + float + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_wavfile_source + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + file + /home/pcfl/Asztal/szakdoga/dipterv1/csdr-varicode/grc_tests/outfile.wav + + + _coordinate + (152, 163) + + + _rotation + 0 + + + id + blocks_wavfile_source_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + nchan + 1 + + + repeat + True + + + + freq_xlating_fir_filter_xxx + + alias + + + + center_freq + 2000 + + + comment + + + + affinity + + + + decim + 1 + + + _enabled + True + + + _coordinate + (832, 75) + + + _rotation + 0 + + + id + freq_xlating_fir_filter_xxx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate + + + taps + [1] + + + type + fcc + + + + freq_xlating_fir_filter_xxx + + alias + + + + center_freq + -2000 + + + comment + + + + affinity + + + + decim + 1 + + + _enabled + True + + + _coordinate + (696, 275) + + + _rotation + 0 + + + id + freq_xlating_fir_filter_xxx_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate + + + taps + [1] + + + type + ccc + + + + ha5kfu_execproc_xx + + alias + + + + commandline + csdr simple_agc_cc 0.001 0.05 + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (384, 291) + + + _rotation + 0 + + + id + ha5kfu_execproc_xx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + type + cc + + + + low_pass_filter + + beta + 6.76 + + + alias + + + + comment + + + + affinity + + + + cutoff_freq + 3000 + + + decim + 1 + + + _enabled + True + + + type + fir_filter_fff + + + _coordinate + (584, 43) + + + _rotation + 0 + + + gain + 1 + + + id + low_pass_filter_0 + + + interp + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate + + + width + 50 + + + win + firdes.WIN_HAMMING + + + + wxgui_fftsink2 + + avg_alpha + 0 + + + average + False + + + baseband_freq + 0 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + fft_size + 1024 + + + freqvar + None + + + _coordinate + (688, 403) + + + _rotation + 0 + + + grid_pos + + + + id + wxgui_fftsink2_0 + + + notebook + + + + peak_hold + False + + + ref_level + 0 + + + ref_scale + 2.0 + + + fft_rate + 15 + + + samp_rate + samp_rate + + + title + FFT Plot + + + type + complex + + + win_size + + + + win + None + + + y_divs + 10 + + + y_per_div + 10 + + + + analog_agc_xx_0 + freq_xlating_fir_filter_xxx_0_0 + 0 + 0 + + + analog_agc_xx_0 + wxgui_fftsink2_0 + 0 + 0 + + + band_reject_filter_0 + low_pass_filter_0 + 0 + 0 + + + blocks_complex_to_float_0 + blocks_multiply_const_vxx_0 + 0 + 0 + + + blocks_multiply_const_vxx_0 + audio_sink_0 + 0 + 0 + + + blocks_wavfile_source_0 + band_reject_filter_0 + 0 + 0 + + + freq_xlating_fir_filter_xxx_0 + analog_agc_xx_0 + 0 + 0 + + + freq_xlating_fir_filter_xxx_0 + ha5kfu_execproc_xx_0 + 0 + 0 + + + freq_xlating_fir_filter_xxx_0_0 + blocks_complex_to_float_0 + 0 + 0 + + + ha5kfu_execproc_xx_0 + freq_xlating_fir_filter_xxx_0_0 + 0 + 0 + + + ha5kfu_execproc_xx_0 + wxgui_fftsink2_0 + 0 + 0 + + + low_pass_filter_0 + freq_xlating_fir_filter_xxx_0 + 0 + 0 + + diff --git a/libcsdr.c b/libcsdr.c old mode 100644 new mode 100755 index 14f997e..93e3a51 --- a/libcsdr.c +++ b/libcsdr.c @@ -2001,8 +2001,8 @@ void simple_agc_cc(complexf* input, complexf* output, int input_size, float rate if(ideal_gain>max_gain) ideal_gain = max_gain; if(ideal_gain<=0) ideal_gain = 0; //*current_gain += (ideal_gain-(*current_gain))*rate; - *current_gain = (ideal_gain-(*current_gain))*rate + (*current_gain)*rate_1minus; - if(debugn<100) fprintf(stderr, "cgain: %g\n", *current_gain), debugn++; + *current_gain = (ideal_gain-(*current_gain))*rate + (*current_gain); //*rate_1minus; + //if(debugn<100) fprintf(stderr, "cgain: %g\n", *current_gain), debugn++; output[i].i=(*current_gain)*input[i].i; output[i].q=(*current_gain)*input[i].q; }