From: Harvie Date: Wed, 1 Aug 2012 03:54:20 +0000 (+0200) Subject: Goertzel documentation X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=84329d34e2656810bcf2ea1a36b41e6ab57aae0b;p=mirrors%2FPrograms.git Goertzel documentation --- diff --git a/c/goertzel/goertzel.c b/c/goertzel/goertzel.c index 6b6c5aa..607b08b 100644 --- a/c/goertzel/goertzel.c +++ b/c/goertzel/goertzel.c @@ -2,16 +2,6 @@ #include #include - -/* - Usage examples - arecord | ./goertzel - sox input.mp3 -b 8 -c 1 -r 8000 -t wav - | ./goertzel - - Arguments for DTMF decoding: - -f 697 -f 770 -f 852 -f 941 -f 1209 -f 1336 -f 1477 -f 1633 -t 10 -*/ - float goertzel_mag(int numSamples,int TARGET_FREQUENCY,int SAMPLING_RATE, float* data) { /* @@ -54,7 +44,43 @@ float goertzel_mag(int numSamples,int TARGET_FREQUENCY,int SAMPLING_RATE, float* } void print_help(char ** argv) { - printf("help me %s\n", argv[0]); + + printf( + "Arguments:\n" + + "\t-i \tInput from file (default STDIN)\n" + "\t-o \tOutput to file (default STDOUT)\n" + "\t-a \tOutput to file (append) (default STDOUT)\n" + "\n" + "\t-r \tInput samplerate (deault 8000 Hz)\n" + "\t-c \tFrame size in samples (default 4000 Samples)\n" + "\t-d \tFrame size (default 2) (samplerate will be divided by this number to get frame size same as -c)\n" + "\n" + "\t-f \tAdd frequency in Hz to detect (if no specified 440 Hz will be added)\n" + "\n" + "\t-t \tSet treshold (used to hide magnitudes lower than treshold) (defaults -1)\n" + "\t-n\t\tPrint integers rather than floats\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" + "\n" + "\t-?\t\tPrint help\n" + "\n" + ); + + printf( + "Usage examples:\n" + "\tarecord | %s\n" + "\tsox input.mp3 -b 8 -c 1 -r 8000 -t wav - | %s\n" + "\t%s -n -q -l -r 8000 -d 20 -t $tresh -f 697 [-f 770 ...]\n" + "\n" + ,argv[0],argv[0],argv[0] + ); + + printf( + "Frequencies for DTMF decoding:\n" + "\t-f 697 -f 770 -f 852 -f 941 -f 1209 -f 1336 -f 1477 -f 1633 -t 10\n" + ); } void addfreq(int *freqs, int freq) { @@ -65,13 +91,6 @@ void addfreq(int *freqs, int freq) { } int main(int argc, char ** argv) { - /* - int samples[] = {0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1}; - int samplecount = 18; - float power = goertzel(samplecount, samples, 1.2, 18); - printf("G: %f\n", power); - */ - int samplerate = 8000; int samplecount = 4000; int treshold = -1;