tresh=10
last='';
-./goertzel -n -q -l -r 8000 -d 20 -t $tresh -f 697 -f 770 -f 852 -f 941 -f 1209 -f 1336 -f 1477 -f 1633 $@ | while read line; do
+./goertzel -n B -q -l -r 8000 -d 20 -t $tresh -f 697 -f 770 -f 852 -f 941 -f 1209 -f 1336 -f 1477 -f 1633 $@ | while read line; do
#echo "$line";
#Get time
g="$(echo "$line" | cut -f 8)";
h="$(echo "$line" | cut -f 9)";
- #Compare values to treshold
- test $a -gt $tresh && a=true || a=false
- test $b -gt $tresh && b=true || b=false
- test $c -gt $tresh && c=true || c=false
- test $d -gt $tresh && d=true || d=false
- test $e -gt $tresh && e=true || e=false
- test $f -gt $tresh && f=true || f=false
- test $g -gt $tresh && g=true || g=false
- test $h -gt $tresh && h=true || h=false
-
#echo "$pos: $a $b $c $d $e $f $g $h";
state="$a$b$c$d$e$f$g$h";
"\t-f <freq>\tAdd frequency in Hz to detect (use multiple times, if no added 440 Hz will be...)\n"
"\n"
"\t-t <treshold>\tSet treshold (used to hide magnitudes lower than treshold) (defaults -1)\n"
- "\t-n\t\tPrint integers rather than floats\n"
+ "\t-n <format>\tSet output format\n"
+ "\t\tf: float (default)\n"
+ "\t\ti: integer\n"
+ "\t\tb: binary (0|1)\n"
+ "\t\tB: Boolean (false|true)\n"
"\t-l\t\tDo not repeat values while still over treshold\n"
"\t-b\t\tDo not print first value that will fall under treshold\n"
"\t-q\t\tQuiet mode: print only values\n"
int treshold = -1;
char noreturn = 0;
char repeat = 1;
- char integers=0;
+ char format=0;
char verbose=1;
int freqs[argc+1]; freqs[0]=-1;
int opt;
- while ((opt = getopt(argc, argv, "?i:o:a:r:c:d:f:t:nlbq")) != -1) {
+ while ((opt = getopt(argc, argv, "?i:o:a:r:c:d:f:t:n:lbq")) != -1) {
switch (opt) {
case 'i':
freopen(optarg, "r", stdin);
treshold = atoi(optarg);
break;
case 'n':
- integers = 1;
+ format = optarg[0];
break;
case 'l':
repeat = 0;
printf("%8.2f", position);
for(i=0;freqs[i]!=-1;i++) {
printf("\t");
- if(integers)
- printf("%d",(int)power[i]);
- else
- printf("%.4f",power[i]);
+ switch(format) {
+ case 'i':
+ printf("%d",(int)power[i]);
+ break;
+ case 'b':
+ printf("%d",power[i]>treshold);
+ break;
+ case 'B':
+ if(power[i]>treshold) printf("true");
+ else printf("false");
+ break;
+ case 'f':
+ default:
+ printf("%.4f",power[i]);
+ }
}
puts("");
fflush(stdout);
test "$OPT" == 's' && screen=true;
done
echo "Writing to file: $out";
-arecord | ./goertzel -n -q -l -t $tresh -d 4 | while read line; do
+arecord | ./goertzel -n i -q -l -t $tresh -d 4 | while read line; do
date="$(date +%s)"
time="$(echo "$line" | cut -f 1)"
level="$(echo "$line" | cut -f 2)"