diff options
Diffstat (limited to 'parse-to-h.pl')
-rwxr-xr-x | parse-to-h.pl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/parse-to-h.pl b/parse-to-h.pl new file mode 100755 index 0000000..5e9f36d --- /dev/null +++ b/parse-to-h.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl -w + +$DATAFILE = "earplug_data.txt"; +open(DATAFILE); +#368 +for ($i = 0; $i < 368; $i++) { + $_ = <DATAFILE>; +# if(m|^\*\*(.*)\*\*$|) {$comment[$i] = $1;} +# if(m|^\*\*.*H-(.*)\.wav \*\*$|) {$arrayname[$i] = "H_$1";} + $_ = <DATAFILE>; + for ($j = 0 ; $j < 128 ; $j++) { + # fscanf(fp, "%f %f ", $impulses[$i][0][$j], $impulses[$i][1][$j]); + while (m|([0-9.-]+) ([0-9.-]+) |g) { + $impulses[$i][0][$j] = $1; + $impulses[$i][1][$j] = $2; + } + } + $_ = <DATAFILE>; +} +close(DATAFILE); + +print("float impulses\[368\]\[2\]\[128\] = {\n"); +for ($i = 0; $i < 368; $i++) { +# print("/*$comment[$i]*/\n"); +# print("float $arrayname[$i]\[2\]\[128\] = {\n{"); + print("{\n{"); + for ($j = 0 ; $j < 128 ; $j++) { + print("$impulses[$i][0][$j], "); + } + print("},\n{"); + for ($j = 0 ; $j < 128 ; $j++) { + print("$impulses[$i][1][$j], "); + } + print("}\n},\n"); +} +print("\n};\n\n"); |