Fex

Check-in [4fd5b5e5b0]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added logFreq option to log transform frequencies - I advise *against* using this option
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | master
Files: files | file ages | folders
SHA3-256: 4fd5b5e5b0a284cebd2d62a27b63726a266eb1a3746f46fde4ea973f11d85bb5
User & Date: jesse.mcclure@umassmed.edu 2016-02-10 19:14:56
Context
2016-05-18
14:00
add log transform option check-in: 17f3ce2f1e user: jesse.mcclure@umassmed.edu tags: trunk, master
2016-02-10
19:14
added logFreq option to log transform frequencies - I advise *against* using this option check-in: 4fd5b5e5b0 user: jesse.mcclure@umassmed.edu tags: trunk, master
2015-01-11
14:35
remove broken link (wiki is moving) check-in: 616e4e5238 user: jesse@mccluresk9.com tags: trunk, master
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to share/config.

25
26
27
28
29
30
31

32
33
34
35
36
37
38
39
40






41
42
43
44
45
46
47
##       coefficients for a generalized cosine window function
##   fontFamily: font name
##   fontSize: font size in pixels
##   help: command for launching the help page
##   output: any combination of the following:
##     path: print path length
##     time: print path duration

set threshold  = 18.0
set floor      = 30.0
set samples    = 256
set bandpass   = 1.25 10.0
set scale      = 8
set window     = hanning
set fontFamily = droid sans
set fontSize	= 14
set help       = xterm -e man fex-help







## Colors
##   spectrogram: background spectrogram
##   threshold: points included in the signal
##   points: points included in the current excursion calculation
##   lines: lines connecting points in the current calculation
##   eraser1/2: two colors for eraser block







>









>
>
>
>
>
>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
##       coefficients for a generalized cosine window function
##   fontFamily: font name
##   fontSize: font size in pixels
##   help: command for launching the help page
##   output: any combination of the following:
##     path: print path length
##     time: print path duration
##   logFreq: whether frequency should be log10 transformed (true or false)
set threshold  = 18.0
set floor      = 30.0
set samples    = 256
set bandpass   = 1.25 10.0
set scale      = 8
set window     = hanning
set fontFamily = droid sans
set fontSize	= 14
set help       = xterm -e man fex-help
## CAUTION: logFreq was added by user request.  While the option will accurately
## log (base 10) transform frequencies as requested, I have not done any testing
## on whether this produces reasonable results.  Using this option is strongly
## discouraged until it has been thoroughly tested and found to give reasonable
## results.
set logFreq    = false

## Colors
##   spectrogram: background spectrogram
##   threshold: points included in the signal
##   points: points included in the current excursion calculation
##   lines: lines connecting points in the current calculation
##   eraser1/2: two colors for eraser block

Changes to src/config.c.

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
		rc = fopen("config","r");
	if (!rc && !chdir(getenv("HOME"))) rc = fopen(".fexrc","r");
	chdir(pwd);
	if (!rc) rc = fopen("/usr/share/fex/config","r");
	if (!rc) die("unable to open configuration file");
	/* initialize conf structure and config reading variables */
	char line[LINE_LEN], prefix[32], option[32], fmt[LINE_LEN];
	char window[32], font_fam[LINE_LEN];
	const char *fspec[] = { "", "%d ","%f ", "%lf ", "%s", "%[^\n]" };
	int j, mode;
	conf.thresh = 14.0;
	conf.spect_floor = 40.0;
	conf.hipass = 12.0;
	conf.lopass = 800.0;
	conf.winlen = 256;
	conf.hop = 0;
	conf.win = (WindowFunction *) windows;

	struct {
		const char *name;
		int mode;
		int type[5];
		void *var[5];
	} cf[] = {
		#include "config.h"







|









>







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
		rc = fopen("config","r");
	if (!rc && !chdir(getenv("HOME"))) rc = fopen(".fexrc","r");
	chdir(pwd);
	if (!rc) rc = fopen("/usr/share/fex/config","r");
	if (!rc) die("unable to open configuration file");
	/* initialize conf structure and config reading variables */
	char line[LINE_LEN], prefix[32], option[32], fmt[LINE_LEN];
	char window[32], font_fam[LINE_LEN], logFreq[32];
	const char *fspec[] = { "", "%d ","%f ", "%lf ", "%s", "%[^\n]" };
	int j, mode;
	conf.thresh = 14.0;
	conf.spect_floor = 40.0;
	conf.hipass = 12.0;
	conf.lopass = 800.0;
	conf.winlen = 256;
	conf.hop = 0;
	conf.win = (WindowFunction *) windows;
	conf.log10 = False;
	struct {
		const char *name;
		int mode;
		int type[5];
		void *var[5];
	} cf[] = {
		#include "config.h"
138
139
140
141
142
143
144

145
146
147
148
149
150
151
				sscanf(line,fmt,cf[i].var[0],cf[i].var[1],cf[i].var[2],
						cf[i].var[3],cf[i].var[4]);
			}
		}
	}
	/* set hop, threshold, floor, and windowing function */
	if (!conf.hop) conf.hop = conf.winlen / 4;

	conf.thresh *= -1;
	conf.spect_floor *= -1;
	if (strncasecmp(window,"custom",6) == 0)
		conf.win = (WindowFunction *) &custom;
	else if (strlen(window))
		for (i = 0; i < sizeof(windows)/sizeof(windows[0]); i++)
			if (!strncasecmp(window,windows[i].type,strlen(window)))







>







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
				sscanf(line,fmt,cf[i].var[0],cf[i].var[1],cf[i].var[2],
						cf[i].var[3],cf[i].var[4]);
			}
		}
	}
	/* set hop, threshold, floor, and windowing function */
	if (!conf.hop) conf.hop = conf.winlen / 4;
	if (logFreq[0] == 't' || logFreq[0] == 'T') conf.log10 = True;
	conf.thresh *= -1;
	conf.spect_floor *= -1;
	if (strncasecmp(window,"custom",6) == 0)
		conf.win = (WindowFunction *) &custom;
	else if (strlen(window))
		for (i = 0; i < sizeof(windows)/sizeof(windows[0]); i++)
			if (!strncasecmp(window,windows[i].type,strlen(window)))

Changes to src/config.h.

26
27
28
29
30
31
32




33
34
35
36
37
38
39
	{ font_fam, NULL, NULL, NULL, NULL}, },
{ "fontSize", CONF_SET,
	{ C_TYPE_D, C_TYPE__, C_TYPE__, C_TYPE__, C_TYPE__ },
	{ &conf.font_size, NULL, NULL, NULL, NULL}, },
{ "help", CONF_SET,
	{ C_TYPE_LN, C_TYPE__, C_TYPE__, C_TYPE__, C_TYPE__ },
	{ &help_cmd, NULL, NULL, NULL, NULL}, },





/* color */
{ "spectrogram", CONF_COL,
	{ C_TYPE_LF, C_TYPE_LF, C_TYPE_LF, C_TYPE_LF, C_TYPE_LF },
	{ &conf.col[0].r, &conf.col[0].g, &conf.col[0].b, &conf.col[0].a,
			&conf.col[0].w } },
{ "threshold", CONF_COL,







>
>
>
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	{ font_fam, NULL, NULL, NULL, NULL}, },
{ "fontSize", CONF_SET,
	{ C_TYPE_D, C_TYPE__, C_TYPE__, C_TYPE__, C_TYPE__ },
	{ &conf.font_size, NULL, NULL, NULL, NULL}, },
{ "help", CONF_SET,
	{ C_TYPE_LN, C_TYPE__, C_TYPE__, C_TYPE__, C_TYPE__ },
	{ &help_cmd, NULL, NULL, NULL, NULL}, },
{ "logFreq", CONF_SET,
	{ C_TYPE_S, C_TYPE__, C_TYPE__, C_TYPE__, C_TYPE__ },
	{ &logFreq, NULL, NULL, NULL, NULL}, },


/* color */
{ "spectrogram", CONF_COL,
	{ C_TYPE_LF, C_TYPE_LF, C_TYPE_LF, C_TYPE_LF, C_TYPE_LF },
	{ &conf.col[0].r, &conf.col[0].g, &conf.col[0].b, &conf.col[0].a,
			&conf.col[0].w } },
{ "threshold", CONF_COL,

Changes to src/fex.h.

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
	double hipass, lopass;
	int scale;
	int winlen, hop, font_size;
	WindowFunction *win;
	RGBA col[RGBA_LAST];
	cairo_font_face_t *font, *bfont;
	char **help_cmd;
	Bool long_out, layers;
} Config;

/* main.c */
extern int die(const char *, ...);
/* config.c */
extern const char *configure(int, const char **);
extern int deconfigure();







|







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
	double hipass, lopass;
	int scale;
	int winlen, hop, font_size;
	WindowFunction *win;
	RGBA col[RGBA_LAST];
	cairo_font_face_t *font, *bfont;
	char **help_cmd;
	Bool long_out, layers, log10;
} Config;

/* main.c */
extern int die(const char *, ...);
/* config.c */
extern const char *configure(int, const char **);
extern int deconfigure();

Changes to src/spectro.c.

142
143
144
145
146
147
148

149

150
151
152
153
154
155
156
157
158
				if (spect->fft->mask[i][j]) continue;
				if (spect->fft->amp[i][j] > spect->fft->amp[i][f] || !f)
					f = j;
		}
		/* add points and do calculations if f is above threshold */
		if (f > 0 && spect->fft->amp[i][f] > conf.thresh) {
			if (lt != spect->fft->time[0]) {

				spect->pex += sqrt(

					(spect->fft->freq[f] - lf) * (spect->fft->freq[f] - lf) +
					(spect->fft->time[i] - lt) * (spect->fft->time[i] - lt) );
				spect->tex += spect->fft->time[i] - lt;
			}
			lt = spect->fft->time[i];
			lf = spect->fft->freq[f];
			cairo_line_to(l,
					(i - spect->fft_x) * conf.scale + conf.scale / 2,
					(f - spect->fft_y) * conf.scale + conf.scale / 2);







>
|
>
|
<







142
143
144
145
146
147
148
149
150
151
152

153
154
155
156
157
158
159
				if (spect->fft->mask[i][j]) continue;
				if (spect->fft->amp[i][j] > spect->fft->amp[i][f] || !f)
					f = j;
		}
		/* add points and do calculations if f is above threshold */
		if (f > 0 && spect->fft->amp[i][f] > conf.thresh) {
			if (lt != spect->fft->time[0]) {
				if (conf.log10)
					spect->pex += hypot(log10(spect->fft->freq[f]) - log10(lf),spect->fft->time[i] - lt);
				else
					spect->pex += hypot(spect->fft->freq[f] - lf,spect->fft->time[i] - lt);

				spect->tex += spect->fft->time[i] - lt;
			}
			lt = spect->fft->time[i];
			lf = spect->fft->freq[f];
			cairo_line_to(l,
					(i - spect->fft_x) * conf.scale + conf.scale / 2,
					(f - spect->fft_y) * conf.scale + conf.scale / 2);