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
33#define MAX_FFT_SIZE 409633#define MAX_FFT_SIZE 4096
34#define is_p2(x) !(x & (x - 1))34#define is_p2(x) !(x & (x - 1))
35 35
36#define MAX_X_SIZE 200000
37
36typedef enum {Window_Hann, Window_Hamming, Window_Bartlett, Window_Rectangular, Window_Kaiser} win_type_t;38typedef enum {Window_Hann, Window_Hamming, Window_Bartlett, Window_Rectangular, Window_Kaiser} win_type_t;
37static lsx_enum_item const window_options[] = {39static lsx_enum_item const window_options[] = {
38 LSX_ENUM_ITEM(Window_,Hann)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 p->out_name = "spectrogram.png", p->comment = "Created by SoX";104 p->out_name = "spectrogram.png", p->comment = "Created by SoX";
103 105
104 while ((c = lsx_getopt(&optstate)) != -1) switch (c) {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 GETOPT_NUMERIC(optstate, 'X', pixels_per_sec, 1 , 5000)108 GETOPT_NUMERIC(optstate, 'X', pixels_per_sec, 1 , 5000)
107 GETOPT_NUMERIC(optstate, 'y', y_size , 64 , 1200)109 GETOPT_NUMERIC(optstate, 'y', y_size , 64 , 1200)
108 GETOPT_NUMERIC(optstate, 'Y', Y_size , 130, MAX_FFT_SIZE / 2 + 2)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 double actual, duration = p->duration, pixels_per_sec = p->pixels_per_sec;198 double actual, duration = p->duration, pixels_per_sec = p->pixels_per_sec;
197 199
198 memset(&p->WORK, 0, sizeof(*p) - field_offset(priv_t, WORK));200 memset(&p->WORK, 0, sizeof(*p) - field_offset(priv_t, WORK));
199 201
200 p->skip = p->start_time * effp->in_signal.rate + .5;202 p->skip = p->start_time * effp->in_signal.rate + .5;
201 p->x_size = p->x_size0;203 p->x_size = p->x_size0;
202 while (sox_true) {204 while (sox_true) {
203 if (!pixels_per_sec && p->x_size && duration)205 if (!pixels_per_sec && p->x_size && duration)
204 pixels_per_sec = min(5000, p->x_size / duration);206 pixels_per_sec = min(5000, p->x_size / duration);
205 else if (!p->x_size && pixels_per_sec && duration)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 if (!duration && effp->in_signal.length != SOX_UNKNOWN_LEN) {209 if (!duration && effp->in_signal.length != SOX_UNKNOWN_LEN) {
208 duration = effp->in_signal.length / (effp->in_signal.rate * effp->in_signal.channels);210 duration = effp->in_signal.length / (effp->in_signal.rate * effp->in_signal.channels);
209 duration -= p->start_time;211 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