History

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.

Ulrich Klauer committed 13 years ago

Commit 22924df1 parent 1badd3e3 files · +7 −4Browse files

Unified · Split

3 files
  1. ChangeLog +1 −0
  2. sox.1 +1 −1
  3. src/spectrogram.c +5 −3
ChangeLog+1−0
@@ -33,6 +33,7 @@ Effects: · 32 unmodified lines
3333 o Restore 8 seconds default for spectrogram, if the input length is
3434 not known. (Ulrich Klauer)
3535 o Set output length for splice to unknown instead of 0. (Ulrich Klauer)
36+ o Increase maximum width for spectrograms. (Ulrich Klauer)
3637
3738 Other bug fixes:
3839
sox.1+1−1
@@ -3145,7 +3145,7 @@ printer. · 3144 unmodified lines
31453145 .RS
31463146 .IP \fB\-x\ \fInum\fR
31473147 Change the (maximum) width (X-axis) of the spectrogram from its default
3148−value of 800 pixels to a given number between 100 and 5000.
3148+value of 800 pixels to a given number between 100 and 200000.
31493149 See also \fB\-X\fR and \fB\-d\fR.
31503150 .IP \fB\-X\ \fInum\fR
31513151 X-axis pixels/second; the default is auto-calculated to fit the given
src/spectrogram.c+5−3
@@ -33,6 +33,8 @@ · 32 unmodified lines
3333 #define MAX_FFT_SIZE 4096
3434 #define is_p2(x) !(x & (x - 1))
3535
36+#define MAX_X_SIZE 200000
37+
3638 typedef enum {Window_Hann, Window_Hamming, Window_Bartlett, Window_Rectangular, Window_Kaiser} win_type_t;
3739 static lsx_enum_item const window_options[] = {
3840 LSX_ENUM_ITEM(Window_,Hann)
@@ -102,7 +104,7 @@ static int getopts(sox_effect_t * effp, int argc, char **argv) · 63 unmodified lines
102104 p->out_name = "spectrogram.png", p->comment = "Created by SoX";
103105
104106 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)
106108 GETOPT_NUMERIC(optstate, 'X', pixels_per_sec, 1 , 5000)
107109 GETOPT_NUMERIC(optstate, 'y', y_size , 64 , 1200)
108110 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
196198 double actual, duration = p->duration, pixels_per_sec = p->pixels_per_sec;
197199
198200 memset(&p->WORK, 0, sizeof(*p) - field_offset(priv_t, WORK));
199−
201+
200202 p->skip = p->start_time * effp->in_signal.rate + .5;
201203 p->x_size = p->x_size0;
202204 while (sox_true) {
203205 if (!pixels_per_sec && p->x_size && duration)
204206 pixels_per_sec = min(5000, p->x_size / duration);
205207 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));
207209 if (!duration && effp->in_signal.length != SOX_UNKNOWN_LEN) {
208210 duration = effp->in_signal.length / (effp->in_signal.rate * effp->in_signal.channels);
209211 duration -= p->start_time;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t