ref: 22924df9e29cd8ea90de8e0ec664d3feef4e6787
parent: 1badd3e9314eb33b7766614cb80d183cfbe6060a
author: Ulrich Klauer <ulrich@chirlu.de>
date: Wed Jan 2 20:06:20 EST 2013
Increase maximum width for spectrograms 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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,7 @@
o Restore 8 seconds default for spectrogram, if the input length is
not known. (Ulrich Klauer)
o Set output length for splice to unknown instead of 0. (Ulrich Klauer)
+ o Increase maximum width for spectrograms. (Ulrich Klauer)
Other bug fixes:
--- a/sox.1
+++ b/sox.1
@@ -3145,7 +3145,7 @@
.RS
.IP \fB\-x\ \fInum\fR
Change the (maximum) width (X-axis) of the spectrogram from its default
-value of 800 pixels to a given number between 100 and 5000.
+value of 800 pixels to a given number between 100 and 200000.
See also \fB\-X\fR and \fB\-d\fR.
.IP \fB\-X\ \fInum\fR
X-axis pixels/second; the default is auto-calculated to fit the given
--- a/src/spectrogram.c
+++ b/src/spectrogram.c
@@ -33,6 +33,8 @@
#define MAX_FFT_SIZE 4096
#define is_p2(x) !(x & (x - 1))
+#define MAX_X_SIZE 200000
+
typedef enum {Window_Hann, Window_Hamming, Window_Bartlett, Window_Rectangular, Window_Kaiser} win_type_t;
static lsx_enum_item const window_options[] = {
LSX_ENUM_ITEM(Window_,Hann)
@@ -102,7 +104,7 @@
p->out_name = "spectrogram.png", p->comment = "Created by SoX";
while ((c = lsx_getopt(&optstate)) != -1) switch (c) {
- GETOPT_NUMERIC(optstate, 'x', x_size0 , 100, 5000)
+ GETOPT_NUMERIC(optstate, 'x', x_size0 , 100, MAX_X_SIZE)
GETOPT_NUMERIC(optstate, 'X', pixels_per_sec, 1 , 5000)
GETOPT_NUMERIC(optstate, 'y', y_size , 64 , 1200)
GETOPT_NUMERIC(optstate, 'Y', Y_size , 130, MAX_FFT_SIZE / 2 + 2)
@@ -196,7 +198,7 @@
double actual, duration = p->duration, pixels_per_sec = p->pixels_per_sec;
memset(&p->WORK, 0, sizeof(*p) - field_offset(priv_t, WORK));
-
+
p->skip = p->start_time * effp->in_signal.rate + .5;
p->x_size = p->x_size0;
while (sox_true) {
@@ -203,7 +205,7 @@
if (!pixels_per_sec && p->x_size && duration)
pixels_per_sec = min(5000, p->x_size / duration);
else if (!p->x_size && pixels_per_sec && duration)
- p->x_size = min(5000, (int)(pixels_per_sec * duration + .5));
+ p->x_size = min(MAX_X_SIZE, (int)(pixels_per_sec * duration + .5));
if (!duration && effp->in_signal.length != SOX_UNKNOWN_LEN) {
duration = effp->in_signal.length / (effp->in_signal.rate * effp->in_signal.channels);
duration -= p->start_time;