summaryrefslogtreecommitdiff
path: root/tools/peakdump.c
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-01-12 20:45:34 +0100
committerRobin Gareus <robin@gareus.org>2015-01-12 21:42:44 +0100
commitbb75553e9b449a2e38f51e5f33ddcd886b4b234e (patch)
tree81df0d49c804b0fab595e3d3d9fdc4434ba234b8 /tools/peakdump.c
parentb8bec75aa36e64ad8e333b528e3ff50d1429c88d (diff)
small tool to debug .peak files
Diffstat (limited to 'tools/peakdump.c')
-rw-r--r--tools/peakdump.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/peakdump.c b/tools/peakdump.c
new file mode 100644
index 0000000000..7d88a294f4
--- /dev/null
+++ b/tools/peakdump.c
@@ -0,0 +1,49 @@
+// gcc -o peakdump peakdump.c -Wall -O3 -lm
+// inspect ardour .peak files
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#define _FPP 256
+
+int main (int argc, char **argv) {
+ int c = 0, d = 0;
+ float thresh = -1.f;
+
+ if (argc < 2 || argc > 3) {
+ fprintf(stderr, "usage: %s [threshold] <peakfile>\n", argv[0]);
+ return -1;
+ }
+
+ if (argc == 3) {
+ thresh = atof(argv[1]);
+ }
+
+ FILE *F = fopen(argv[argc-1], "r");
+
+ if (!F) {
+ fprintf(stderr, "Cannot open file '%s'\n", argv[argc-1]);
+ return -1;
+ }
+
+ printf(" # ) audio sample range : MIN MAX\n");
+ while (!feof(F)) {
+ struct PeakData {
+ float min;
+ float max;
+ } buf;
+
+ if (fread(&buf, sizeof(struct PeakData), 1, F) <= 0) {
+ break;
+ }
+ if (fabsf(buf.min) > thresh || fabsf(buf.max) > thresh) {
+ printf("%8d) %10d - %10d: %+.3f %+.3f\n", ++d,
+ _FPP * c, _FPP * (c + 1) - 1,
+ buf.min, buf.max);
+ }
+ ++c;
+ }
+ fclose(F);
+ return 0;
+}