Showing the changes to src/spectrogram.c (1 of 16 files). Show all
Unified · Split
| @@ -26,15 +26,11 @@ · 25 unmodified lines | |||
| 26 | 26 | ||
| 27 | #include "sox_i.h" | 27 | #include "sox_i.h" |
| 28 | #include "fft4g.h" | 28 | #include "fft4g.h" |
| 29 | #include "sgetopt.h" | ||
| 29 | #include <assert.h> | 30 | #include <assert.h> |
| 30 | #include <math.h> | 31 | #include <math.h> |
| 31 | #include <png.h> | 32 | #include <png.h> |
| 32 | 33 | ||
| 33 | /* we are playing games with getopt aliases so this needs to be included | ||
| 34 | * after system header files to prevent aliasing OS's version of getopt. | ||
| 35 | */ | ||
| 36 | #include "getopt.h" | ||
| 37 | |||
| 38 | #define malloc lsx_malloc | 34 | #define malloc lsx_malloc |
| 39 | #define calloc lsx_calloc | 35 | #define calloc lsx_calloc |
| 40 | #define realloc lsx_realloc | 36 | #define realloc lsx_realloc |
| @@ -89,7 +85,7 @@ static int getopts(sox_effect_t * effp, int argc, char **argv) · 48 unmodified lines | |||
| 89 | p->spectrum_points = 249, p->perm = 1, p->max_cols = MAX_COLS; | 85 | p->spectrum_points = 249, p->perm = 1, p->max_cols = MAX_COLS; |
| 90 | p->out_name = "spectrogram.png", p->comment = "Created by SoX"; | 86 | p->out_name = "spectrogram.png", p->comment = "Created by SoX"; |
| 91 | 87 | ||
| 92 | while ((c = getopt(argc, argv, "+M:x:X:y:z:Z:q:p:w:st:c:amlho:")) != -1) switch (c) { | 88 | while ((c = lsx_getopt(argc, argv, "+M:x:X:y:z:Z:q:p:w:st:c:amlho:")) != -1) switch (c) { |
| 93 | GETOPT_NUMERIC('M', max_cols , 100, 2000) | 89 | GETOPT_NUMERIC('M', max_cols , 100, 2000) |
| 94 | GETOPT_NUMERIC('x', pixels_per_sec, 1 , 5000) | 90 | GETOPT_NUMERIC('x', pixels_per_sec, 1 , 5000) |
| 95 | GETOPT_NUMERIC('y', y_size , 1 , 1 + MAX_DFT_SIZE_SHIFT) | 91 | GETOPT_NUMERIC('y', y_size , 1 , 1 + MAX_DFT_SIZE_SHIFT) |
| @@ -100,25 +96,25 @@ static int getopts(sox_effect_t * effp, int argc, char **argv) · 4 unmodified lines | |||
| 100 | case 'w': p->win_type = lsx_enum_option(c, window_options); break; | 96 | case 'w': p->win_type = lsx_enum_option(c, window_options); break; |
| 101 | case 's': p->slack_overlap = sox_true; break; | 97 | case 's': p->slack_overlap = sox_true; break; |
| 102 | case 'X': | 98 | case 'X': |
| 103 | next = lsx_parsesamples(1e5, optarg, &duration_1e5, 't'); | 99 | next = lsx_parsesamples(1e5, lsx_optarg, &duration_1e5, 't'); |
| 104 | if (next == NULL || *next != '\0' || duration_1e5 > p->max_cols * 1e5 | 100 | if (next == NULL || *next != '\0' || duration_1e5 > p->max_cols * 1e5 |
| 105 | || duration_1e5 < 1e5 / 5000 * p->max_cols) | 101 | || duration_1e5 < 1e5 / 5000 * p->max_cols) |
| 106 | return lsx_usage(effp); | 102 | return lsx_usage(effp); |
| 107 | p->pixels_per_sec = p->max_cols * 1e5 / duration_1e5; | 103 | p->pixels_per_sec = p->max_cols * 1e5 / duration_1e5; |
| 108 | break; | 104 | break; |
| 109 | case 't': p->title = optarg; break; | 105 | case 't': p->title = lsx_optarg; break; |
| 110 | case 'c': p->comment = optarg; break; | 106 | case 'c': p->comment = lsx_optarg; break; |
| 111 | case 'a': p->no_axes = sox_true; break; | 107 | case 'a': p->no_axes = sox_true; break; |
| 112 | case 'm': p->monochrome = sox_true; break; | 108 | case 'm': p->monochrome = sox_true; break; |
| 113 | case 'l': p->light_background = sox_true; break; | 109 | case 'l': p->light_background = sox_true; break; |
| 114 | case 'h': p->high_colour = sox_true; break; | 110 | case 'h': p->high_colour = sox_true; break; |
| 115 | case 'o': p->out_name = optarg; break; | 111 | case 'o': p->out_name = lsx_optarg; break; |
| 116 | default: lsx_fail("invalid option `-%c'", optopt); return lsx_usage(effp); | 112 | default: lsx_fail("invalid option `-%c'", optopt); return lsx_usage(effp); |
| 117 | } | 113 | } |
| 118 | p->gain = -p->gain; | 114 | p->gain = -p->gain; |
| 119 | --p->y_size, --p->perm; | 115 | --p->y_size, --p->perm; |
| 120 | p->spectrum_points += 2; | 116 | p->spectrum_points += 2; |
| 121 | return optind !=argc || p->win_type == INT_MAX? lsx_usage(effp) : SOX_SUCCESS; | 117 | return lsx_optind !=argc || p->win_type == INT_MAX? lsx_usage(effp) : SOX_SUCCESS; |
| 122 | } | 118 | } |
| 123 | 119 | ||
| 124 | static double make_window(priv_t * p, int end) | 120 | static double make_window(priv_t * p, int end) |