From b16207097440cb1b73dc230cdd8e7d1739805c49 Mon Sep 17 00:00:00 2001 From: Tomas Mudrunka Date: Thu, 2 Aug 2012 17:35:30 +0200 Subject: [PATCH] Realtime equalizer-like graphing of goertzel output --- c/goertzel/histogram.pl | 38 ++++++++++++++++++++++++++++++++++++++ c/goertzel/histogram.sh | 2 ++ 2 files changed, 40 insertions(+) create mode 100755 c/goertzel/histogram.pl create mode 100755 c/goertzel/histogram.sh diff --git a/c/goertzel/histogram.pl b/c/goertzel/histogram.pl new file mode 100755 index 0000000..c27f28c --- /dev/null +++ b/c/goertzel/histogram.pl @@ -0,0 +1,38 @@ +#!/usr/bin/env perl +#This script processes output of goertzel and paints histogram + +use strict; +use warnings; +use Term::ReadKey; + + +sub bar($$$) { + my ($value,$max,$prefix) = @_; + my ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize(); + $value = ($value/$max)*($wchar-length($prefix)); + return $prefix."#" x $value." " x ($wchar-$value-length($prefix)); +} + +sub trim($) { + my $string = shift; + $string =~ s/^\s+//; + $string =~ s/\s+$//; + return $string; +} + +print "\033[H\033[2J"; + +my @header = split('\t', ); + +while() { + my @values = split('\t', $_); + my $i=0; + print "\033[H"; + foreach my $i (1..$#values) { + print bar($values[$i],10,sprintf("%8s ",trim($header[$i])))."\n"; + } + print "Time: ".$values[0]." \n"; + print " \n"; +} + +exit 0; diff --git a/c/goertzel/histogram.sh b/c/goertzel/histogram.sh new file mode 100755 index 0000000..ac26b7e --- /dev/null +++ b/c/goertzel/histogram.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./goertzel -f 10 -f 20 -f 40 -f 60 -f 100 -f 200 -f 300 -f 400 -f 500 -f 1000 -f 2000 -f 4000 -f 6100 -f 10000 -f 20000 2>/dev/null | ./histogram.pl -- 2.30.2