From 3344dcf2dee6e85a636c14d50c252c9786c81458 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Wed, 20 Jun 2012 05:52:26 +0000 Subject: [PATCH] first pass at spectrogram, would like to improve CPU load, make resizable git-svn-id: https://svn.code.sf.net/p/freetel/code@572 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/README | 10 +-- codec2-dev/README_fdmdv.txt | 4 +- codec2-dev/fltk/Makefile | 3 +- codec2-dev/fltk/fl_fdmdv.cxx | 160 ++++++++++++++++++++++++++++++----- codec2-dev/win32/Makefile | 2 - 5 files changed, 145 insertions(+), 34 deletions(-) diff --git a/codec2-dev/README b/codec2-dev/README index 10f0a761..4a87406a 100644 --- a/codec2-dev/README +++ b/codec2-dev/README @@ -64,10 +64,11 @@ Debugging Directories ----------- - script - shell scripts for playing and converting raw files - src - C source code + fltk - FLTK GUI programs(s) octave - Octave scripts used for visualising internal signals during development + script - shell scripts for playing and converting raw files + src - C source code raw - speech files in raw format (16 bits signed linear 8 kHz) unittest - unit test source code voicing - hand-estimated voicing files, used for development @@ -77,6 +78,5 @@ Directories TODO ---- -[ ] Make sure we have separate state variables for enc and dec on - modes that use difference in time coding and have statesthat are - presevred from frame to frame. +[ ] Get win32/Makefile integarted into Automake system, such that if + i586-mingw32msvc exists the Win32 code gets automatically built. diff --git a/codec2-dev/README_fdmdv.txt b/codec2-dev/README_fdmdv.txt index fc091018..64254202 100644 --- a/codec2-dev/README_fdmdv.txt +++ b/codec2-dev/README_fdmdv.txt @@ -176,9 +176,7 @@ This introduces a simulated 1000ppm error: TODO ---- -[ ] 48 kHz to and from 8 kHz routines to drive 48 kHz sound card audio -[ ] implement SNR and ppm measurements in fdmdv_get_demod_stats() -[ ] implement fdmdv_get_waterfall_line() +[ ] implement ppm measurements in fdmdv_get_demod_stats() [ ] try interfering sine wave + maybe swept + does modem fall over? diff --git a/codec2-dev/fltk/Makefile b/codec2-dev/fltk/Makefile index 0a2b7041..df2ddfac 100644 --- a/codec2-dev/fltk/Makefile +++ b/codec2-dev/fltk/Makefile @@ -1,11 +1,12 @@ FLTK_CFLAGS += $(shell fltk-config --ldstaticflags) +CFLAGS = -O3 -g LC2POC_C = fl_fdmdv.cxx all: fl_fdmdv fl_fdmdv: Makefile $(LC2POC_C) - g++ $(LC2POC_C) -I../src/ -o fl_fdmdv $(FLTK_CFLAGS) ../src/.libs/libcodec2.a + g++ $(LC2POC_C) -I../src/ -o fl_fdmdv $(CFLAGS) $(FLTK_CFLAGS) ../src/.libs/libcodec2.a clean: rm -f fl_fdmdv diff --git a/codec2-dev/fltk/fl_fdmdv.cxx b/codec2-dev/fltk/fl_fdmdv.cxx index aba5fbcd..5af89b14 100644 --- a/codec2-dev/fltk/fl_fdmdv.cxx +++ b/codec2-dev/fltk/fl_fdmdv.cxx @@ -18,20 +18,29 @@ #include "fdmdv.h" -#define MIN_DB -40.0 -#define MAX_DB 0.0 -#define BETA 0.1 -#define MIN_HZ 0 -#define MAX_HZ 4000 +#define MIN_DB -40.0 +#define MAX_DB 0.0 +#define BETA 0.1 +#define MIN_HZ 0 +#define MAX_HZ 4000 +#define WATERFALL_SECS_Y 5 // number of seconds respresented by y axis of waterfall +#define DT 0.1 // time between samples +#define FS 8000 class Spectrum; +class Waterfall; + char *fin_name = NULL; FILE *fin = NULL; struct FDMDV *fdmdv; Fl_Group *agroup; Fl_Window *window; Spectrum *aSpectrum; +Waterfall *aWaterfall; + +float av_mag[FDMDV_NSPEC]; // shared between a few classes +float Ts = 0.0; class Spectrum: public Fl_Box { protected: @@ -100,30 +109,119 @@ protected: } public: - float av_mag[FDMDV_NSPEC]; - Spectrum(int x, int y, int h, int w): Fl_Box(x,y,h,w, "Spectrum") { - int i; - - for(i=0; i 255) intensity = 255; + if (intensity < 0) intensity = 0; + + for(py=0; pynew_data(rx_spec); - aSpectrum->redraw(); - usleep(20000); + new_data(rx_spec); + if (Ts >= DT) { + Ts -= DT; + aSpectrum->redraw(); + aWaterfall->redraw(); + } } + usleep(20000); } int arg_callback(int argc, char **argv, int &i) { @@ -154,8 +258,9 @@ int arg_callback(int argc, char **argv, int &i) { int main(int argc, char **argv) { int ret; - int i = 1; + int i; + i = 1; Fl::args(argc,argv,i,arg_callback); if (argc != 3) { @@ -169,9 +274,18 @@ int main(int argc, char **argv) { exit(1); } - window = new Fl_Window(800, 600, "fl_fmdv"); + for(i=0; isize_range(400,200); aSpectrum = new Spectrum(20, 20, 800-40, 300); + aWaterfall = new Waterfall(20, 20+300+20+20, 800-40, 300); window->add_resizable(*aSpectrum); fdmdv = fdmdv_create(); diff --git a/codec2-dev/win32/Makefile b/codec2-dev/win32/Makefile index 2ee8ad84..8e1ecc4b 100644 --- a/codec2-dev/win32/Makefile +++ b/codec2-dev/win32/Makefile @@ -7,8 +7,6 @@ # the machine-generated codebook source files. It is designed to be cross compiled on # Linux. # -# TODO - get this integarted into Automake system, such that if i586-mingw32msvc exists -# the Win32 code gets automatically built. # uncomment under Windows #CC_PREFIX = -- 2.25.1