Realtime equalizer-like graphing of goertzel output
authorTomas Mudrunka <tomas@mudrunka.cz>
Thu, 2 Aug 2012 15:35:30 +0000 (17:35 +0200)
committerTomas Mudrunka <tomas@mudrunka.cz>
Thu, 2 Aug 2012 15:35:30 +0000 (17:35 +0200)
c/goertzel/histogram.pl [new file with mode: 0755]
c/goertzel/histogram.sh [new file with mode: 0755]

diff --git a/c/goertzel/histogram.pl b/c/goertzel/histogram.pl
new file mode 100755 (executable)
index 0000000..c27f28c
--- /dev/null
@@ -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', <STDIN>);
+
+while(<STDIN>) {
+       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 (executable)
index 0000000..ac26b7e
--- /dev/null
@@ -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
This page took 0.344414 seconds and 4 git commands to generate.