aboutsummaryrefslogtreecommitdiff
path: root/parse-to-h.pl
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2009-02-04 03:06:56 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2009-02-04 03:06:56 +0000
commit016c7666e6f6c9d181b56384a3bc8364b729af0e (patch)
tree35a69d10f77a7ad0dee823fa500df2cdbe97420f /parse-to-h.pl
parenta23e8307a8f6d3b718894b42dd2bb891f8c27ac1 (diff)
first stab at a perl script to parse the data file into a C .h so that the data can easily be compiled into the external
svn path=/trunk/externals/earplug~/; revision=10729
Diffstat (limited to 'parse-to-h.pl')
-rwxr-xr-xparse-to-h.pl36
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");