diff --git a/src/Makefile.am b/src/Makefile.am index 73d6166..dd2a7da 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,5 +9,5 @@ minimodem_LDADD = $(DEPS_LIBS) minimodem_SOURCES = minimodem.c tscope_LDADD = $(DEPS_LIBS) -tscope_SOURCES = tscope.c +tscope_SOURCES = tscope.c tscope_print.c diff --git a/src/Makefile.in b/src/Makefile.in index 49e9413..a705088 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -49,7 +49,7 @@ am_minimodem_OBJECTS = minimodem.$(OBJEXT) minimodem_OBJECTS = $(am_minimodem_OBJECTS) am__DEPENDENCIES_1 = minimodem_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_tscope_OBJECTS = tscope.$(OBJEXT) +am_tscope_OBJECTS = tscope.$(OBJEXT) tscope_print.$(OBJEXT) tscope_OBJECTS = $(am_tscope_OBJECTS) tscope_DEPENDENCIES = $(am__DEPENDENCIES_1) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) @@ -158,7 +158,7 @@ INCLUDES = $(DEPS_CFLAGS) minimodem_LDADD = $(DEPS_LIBS) minimodem_SOURCES = minimodem.c tscope_LDADD = $(DEPS_LIBS) -tscope_SOURCES = tscope.c +tscope_SOURCES = tscope.c tscope_print.c all: all-am .SUFFIXES: @@ -245,6 +245,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimodem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tscope.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tscope_print.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff --git a/src/tscope.c b/src/tscope.c index c2c73eb..bfc047b 100644 --- a/src/tscope.c +++ b/src/tscope.c @@ -27,47 +27,7 @@ #include - -static inline -float -band_mag( fftwf_complex * const cplx, unsigned int band, float scalar ) -{ - float re = cplx[band][0]; - float im = cplx[band][1]; - float mag = hypot(re, im) * scalar; - return mag; -} - - -void -tscope_print( fftwf_complex * const fftout, int nbands, float magscalar, - unsigned char one_line_mode, unsigned char show_maxmag ) -{ - char magchars[] = " .-=+#^"; - char *buf = alloca(nbands+1); - if ( one_line_mode ) - magchars[0] = '_'; - float maxmag = 0; - int i; - for ( i=0; i maxmag ) - maxmag = mag; - char c; - if ( mag <= 0.05 ) c = magchars[0]; - else if ( mag <= 0.10 ) c = magchars[1]; - else if ( mag <= 0.25 ) c = magchars[2]; - else if ( mag <= 0.50 ) c = magchars[3]; - else if ( mag <= 0.95 ) c = magchars[4]; - else if ( mag <= 1.00 ) c = magchars[5]; - else c = magchars[6]; - buf[i] = c; - } - buf[i] = 0; - if ( show_maxmag ) - printf(" %.2f", maxmag); - printf("|%s|", buf); -} +#include "tscope_print.h" int @@ -87,6 +47,9 @@ main( int argc, char*argv[] ) int one_line_mode = 1; int show_maxmag = 1; + if ( ! isatty(1) ) + one_line_mode = 0; + int argi = 1; while ( argi < argc && argv[argi][0] == '-' ) { /* -s switch enables "scrolling mode" instead of "one line mode" */ @@ -198,7 +161,7 @@ main( int argc, char*argv[] ) int n; for ( n=0; n + * + * Unpublished work, not licensed for any purpose. + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include "tscope_print.h" + + +static inline +float +band_mag( fftwf_complex * const cplx, unsigned int band, float scalar ) +{ + float re = cplx[band][0]; + float im = cplx[band][1]; + float mag = hypot(re, im) * scalar; + return mag; +} + + +void +tscope_print( fftwf_complex * const fftout, int nbands, float magscalar, + int one_line_mode, int show_maxmag ) +{ + char *buf = alloca(nbands+1); + char magchars[] = " .-=+#^"; + if ( one_line_mode ) + magchars[0] = '_'; + float maxmag = 0; + int i; + for ( i=0; i + * + * Unpublished work, not licensed for any purpose. + * + */ + +#include + +extern void +tscope_print( fftwf_complex * const fftout, int nbands, float magscalar, + int one_line_mode, int show_maxmag ); +