replace ::cast_dynamic() with relevant ActionManager::get_*_action() calls
[ardour.git] / tools / peakdump.c
1 // gcc -o peakdump peakdump.c -Wall -O3 -lm
2 // inspect ardour .peak files
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <math.h>
7
8 #define _FPP 256
9
10 int main (int argc, char **argv) {
11         int c = 0, d = 0;
12         float thresh = -1.f;
13
14         if (argc < 2 || argc > 3) {
15                 fprintf(stderr, "usage: %s [threshold] <peakfile>\n", argv[0]);
16                 return -1;
17         }
18
19         if (argc == 3) {
20                 thresh = atof(argv[1]);
21         }
22
23         FILE *F = fopen(argv[argc-1], "r");
24
25         if (!F) {
26                 fprintf(stderr, "Cannot open file '%s'\n", argv[argc-1]);
27                 return -1;
28         }
29
30         printf("   #    )   audio sample range   :   MIN    MAX\n");
31         while (!feof(F)) {
32                 struct PeakData {
33                         float min;
34                         float max;
35                 } buf;
36
37                 if (fread(&buf, sizeof(struct PeakData), 1, F) <= 0) {
38                         break;
39                 }
40                 if (fabsf(buf.min) > thresh || fabsf(buf.max) > thresh) {
41                         printf("%8d) %10d - %10d: %+.3f %+.3f\n", ++d,
42                                         _FPP * c, _FPP * (c + 1) - 1,
43                                         buf.min, buf.max);
44                 }
45                 ++c;
46         }
47         fclose(F);
48         return 0;
49 }