Spectrograms were arbitrarily limited to a width of 5000 pixels. This is not a enough for all use cases, as demonstrated in a discussion on sox-users. Now increased to 200000.
Showing the changes to src/spectrogram.c (1 of 3 files). Show all
Unified · Split
| @@ -33,6 +33,8 @@ · 32 unmodified lines | ||
| 33 | 33 | #define MAX_FFT_SIZE 4096 |
| 34 | 34 | #define is_p2(x) !(x & (x - 1)) |
| 35 | 35 | |
| 36 | +#define MAX_X_SIZE 200000 | |
| 37 | + | |
| 36 | 38 | typedef enum {Window_Hann, Window_Hamming, Window_Bartlett, Window_Rectangular, Window_Kaiser} win_type_t; |
| 37 | 39 | static lsx_enum_item const window_options[] = { |
| 38 | 40 | LSX_ENUM_ITEM(Window_,Hann) |
| @@ -102,7 +104,7 @@ static int getopts(sox_effect_t * effp, int argc, char **argv) · 63 unmodified lines | ||
| 102 | 104 | p->out_name = "spectrogram.png", p->comment = "Created by SoX"; |
| 103 | 105 | |
| 104 | 106 | while ((c = lsx_getopt(&optstate)) != -1) switch (c) { |
| 105 | − GETOPT_NUMERIC(optstate, 'x', x_size0 , 100, 5000) | |
| 107 | + GETOPT_NUMERIC(optstate, 'x', x_size0 , 100, MAX_X_SIZE) | |
| 106 | 108 | GETOPT_NUMERIC(optstate, 'X', pixels_per_sec, 1 , 5000) |
| 107 | 109 | GETOPT_NUMERIC(optstate, 'y', y_size , 64 , 1200) |
| 108 | 110 | GETOPT_NUMERIC(optstate, 'Y', Y_size , 130, MAX_FFT_SIZE / 2 + 2) |
| @@ -196,14 +198,14 @@ static int start(sox_effect_t * effp) · 87 unmodified lines | ||
| 196 | 198 | double actual, duration = p->duration, pixels_per_sec = p->pixels_per_sec; |
| 197 | 199 | |
| 198 | 200 | memset(&p->WORK, 0, sizeof(*p) - field_offset(priv_t, WORK)); |
| 199 | − | |
| 201 | + | |
| 200 | 202 | p->skip = p->start_time * effp->in_signal.rate + .5; |
| 201 | 203 | p->x_size = p->x_size0; |
| 202 | 204 | while (sox_true) { |
| 203 | 205 | if (!pixels_per_sec && p->x_size && duration) |
| 204 | 206 | pixels_per_sec = min(5000, p->x_size / duration); |
| 205 | 207 | else if (!p->x_size && pixels_per_sec && duration) |
| 206 | − p->x_size = min(5000, (int)(pixels_per_sec * duration + .5)); | |
| 208 | + p->x_size = min(MAX_X_SIZE, (int)(pixels_per_sec * duration + .5)); | |
| 207 | 209 | if (!duration && effp->in_signal.length != SOX_UNKNOWN_LEN) { |
| 208 | 210 | duration = effp->in_signal.length / (effp->in_signal.rate * effp->in_signal.channels); |
| 209 | 211 | duration -= p->start_time; |