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

Showing the changes to src/spectrogram.c (1 of 3 files). Show all

Unified · Split

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