From: Tomas Mudrunka Date: Thu, 2 Aug 2012 15:35:30 +0000 (+0200) Subject: Realtime equalizer-like graphing of goertzel output X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=b16207097440cb1b73dc230cdd8e7d1739805c49;p=mirrors%2FPrograms.git Realtime equalizer-like graphing of goertzel output --- 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