Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | first commit for freeglut branch |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | origin/sfml |
Files: | files | file ages | folders |
SHA3-256: |
da496e6e10520a08973bde4ff129a6e4 |
User & Date: | jesse@mccluresk9.com 2015-06-16 15:46:33 |
2015-06-16
| ||
15:58 | branch notes (warnings) check-in: a036250782 user: jesse@mccluresk9.com tags: trunk, origin/sfml | |
15:46 | first commit for freeglut branch check-in: da496e6e10 user: jesse@mccluresk9.com tags: trunk, origin/sfml | |
2015-01-11
| ||
14:35 | remove broken link (wiki is moving) check-in: 616e4e5238 user: jesse@mccluresk9.com tags: trunk, master | |
Deleted COPYING.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to Makefile.
|
| > > | | | | > > | > > > > > | | | > > | | | | < | < < < < < < < < < < < < < < < < | < | < < < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | PROG = glFex VER = 3.0a CC ?= gcc ifeq ($(OS),win) # fftw3 and sndfile?? DEFS += -D_WIN32_ CFLAGS += -I"C:\Program Files\Common Files\MinGW\GLUT\include" LDLIBS += -L"C:\Program Files\Common Files\MinGW\GLUT\lib" -lglut32 -lopengl32 -Wl,--subsystem,windows endif ifeq ($(OS),linux) DEPS = fftw3 freeglut gl sndfile CFLAGS += $(shell pkg-config --cflags ${DEPS}) LDLIBS += $(shell pkg-config --libs ${DEPS}) -lm PREFIX ?= /usr endif MODULES = config fex fft wave HEADERS = fex.h fex_struct.h MANPAGES = fex.1 VPATH = src:doc ${PROG}: ${MODULES:%=%.o} glFex.o: glFex.c fex.h %.o: %.c ${HEADERS} clean: @rm -f *.o distclean: clean @rm -f glFex glFex.exe .PHONY: clean distclean |
Added README.
> > > | 1 2 3 | - erasing - complete configure module |
Deleted README.md.
|
| < < < < < < < < < < < < < |
Deleted doc/fex-1.tex.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted doc/fex-help-1.tex.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted doc/fex-help.1.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted doc/fex.1.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted pkg/README.md.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted pkg/archlinux/PKGBUILD.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted pkg/archlinux/fex.install.
|
| < < < < < < < < < < < |
Deleted pkg/deb/README.
|
| < < < < < < < < |
Deleted pkg/deb/fex-calc.spec.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted pkg/deb/makedeb.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted pkg/rpm/README.
|
| < < < < < < < |
Deleted pkg/rpm/fex.spec.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted pkg/rpm/makerpm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted share/config.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted share/fex.desktop.
|
| < < < < < < < < < < |
Deleted share/icon.png.
cannot compute difference between binary files
Changes to src/config.c.
1 | /**********************************************************************\ | < | > | | < < < < < < < < < < < < < < < | < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | | < < < < < < < < < | | < < < < < < | | < | < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /**********************************************************************\ * CONFIG.C * Part of FEX, see FEX.C for complete license information * Author: Jesse McClure, copyright 2013-2015 * License; GPL3 \**********************************************************************/ #include "fex.h" #include "fex_struct.h" // TODO: this module is just a placeholder for now fex_t configure(FEX *fex) { if (!fex) return FexNullAccess; fex->conf.winlen = 256; fex->conf.hop = 64; fex->conf.lopass = 1.25; fex->conf.hipass = 10.0; fex->conf.floor = -28.0; fex->conf.threshold = -14.0; return FexSuccess; } |
Deleted src/config.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/fex-gtk.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/fex.c.
|
| < < | > > | < | > | | | | | | | | | | | | > | | | > > > > > > > > > > > > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < > > | > | | < > | | > | > > > | > > | | > > > > | > > > > > > | < | > > > | | > | < < < > > | > | > > > | > > > > > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | #include <math.h> #include "fex.h" #include "fex_struct.h" extern fex_t read_wave(FEX *); extern fex_t free_wave(FEX *); extern fex_t configure(FEX *); extern fex_t create_fft(FEX *); extern fex_t destroy_fft(FEX *); static fex_t fex_populate(FEX *); static fex_t fex_depopulate(FEX *); static FEX *fex_ptr(fex_t); static int fex_make_path(FEX *); static unsigned char *spec_data = NULL; static FEX **fex_p = NULL; static int nfex = 0; /**********************/ /* exported functions */ /**********************/ fex_t fex_create(const char *fname) { fex_p = realloc(fex_p, (++nfex) * sizeof(FEX *)); fex_p[nfex-1] = malloc(sizeof(FEX)); fex_t ret; if (fex_p[nfex-1]) { fex_p[nfex-1]->wave.name = fname; ret = fex_populate(fex_p[nfex-1]); if (ret < 0) return ret; else return nfex-1; } return FexMallocError; } fex_t fex_destroy(fex_t fex_n) { if (spec_data) free(spec_data); spec_data = NULL; fex_t ret; if ( (ret=fex_depopulate(fex_p[fex_n])) < 0 ) return ret; free(fex_p[fex_n]); fex_p[fex_n] = NULL; return ret; } #define square(x) (x)*(x) unsigned char *fex_get_spectrogram(fex_t fex_n, int *w_ptr, int *h_ptr) { FEX *fex = fex_ptr(fex_n); if (!fex) return NULL; int w = fex->fft.ntime; int h = fex->fft.nfreq; spec_data = realloc(spec_data, w * h * 3); // TODO error checking, speed of loop order? int t, f; unsigned char *a = spec_data; unsigned char adj = 0.5 + 255.0 * fex->conf.threshold / fex->conf.floor; for (f = 0; f < h; ++f) for (t = 0; t < w; ++t) { // TODO clean up! //double dd = square(-sqrt(255.0) * fftAmp(fex,t,f) / fex->conf.floor); double dd = 255.0 * fftAmp(fex,t,f) / fex->conf.floor; unsigned char aa = dd; if (dd > 255) aa = 255; if (dd < 0) aa = 0; a[0] = a[1] = a[2] = aa; if (aa < adj) a[1] = a[2] = aa + 255-adj; a += 3; } *w_ptr = w; *h_ptr = h; fex_make_path(fex); return spec_data; } int *fex_get_path(fex_t fex_n) { FEX *fex = fex_ptr(fex_n); return fex->fft.path; } int fex_threshold(fex_t fex_n, float adj) { FEX *fex = fex_ptr(fex_n); fex->conf.threshold += adj; fex_make_path(fex); return 0; } #define dist(x,y) sqrt((x)*(x)+(y)*(y)) double fex_measure(fex_t fex_n, double *len_ptr, double *duration_ptr) { FEX *fex = fex_ptr(fex_n); int t, f; double prev_t = -1.0, prev_f, start, end; long double sum = 0.0; for (t = 0; t < fex->fft.ntime; ++t) { if ( (f=fex->fft.path[t]) < 0 ) continue; if (prev_t > 0) sum += dist(fex->fft.time[t] - prev_t, fex->fft.freq[f] - prev_f); else start = fex->fft.time[t]; prev_t = fex->fft.time[t]; prev_f = fex->fft.freq[f]; end = fex->fft.time[t]; } if (len_ptr) *len_ptr = sum; if (duration_ptr) *duration_ptr = end - start; return sum / (end - start); } int fex_coordinates(fex_t fex_n, double pt, double pf, double *time_ptr, double *freq_ptr) { FEX *fex = fex_ptr(fex_n); if (time_ptr) *time_ptr = fex->fft.time[(int) (pt * fex->fft.ntime)]; if (freq_ptr) *freq_ptr = fex->fft.freq[(int) (pf * fex->fft.nfreq)]; return 0; } /*******************/ /* local functions */ /*******************/ int fex_make_path(FEX *fex) { int t, f; double max; for (t = 0; t < fex->fft.ntime; ++t) { max = -1.0 * INFINITY; fex->fft.path[t] = -1; for (f = 0; f < fex->fft.nfreq; ++f) { if (fftAmp(fex,t,f) < fex->conf.threshold) continue; if (fftAmp(fex,t,f) > max) max = fftAmp(fex,t, (fex->fft.path[t]=f)); } } return 0; } FEX *fex_ptr(fex_t fex_n) { if (fex_n >= nfex) return NULL; else return fex_p[fex_n]; } fex_t fex_populate(FEX *fex) { if (!fex) return FexNullAccess; fex_t ret; if ( (ret=read_wave(fex)) < 0 ) return ret; if ( (ret=configure(fex)) < 0 ) return ret; if ( (ret=create_fft(fex)) < 0 ) return ret; fex->fft.path = malloc(fex->fft.ntime * sizeof(int)); } fex_t fex_depopulate(FEX *fex) { if (!fex) return FexNullAccess; fex_t ret; if (fex->fft.path) free(fex->fft.path); fex->fft.path = NULL; if ( (ret=destroy_fft(fex)) < 0 ) return ret; if ( (ret=free_wave(fex)) < 0 ) return ret; } |
Changes to src/fex.h.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < < < < < < < < < < < < | < < < < < | | < > | < < | | < < < < < < | < < < < < < | < < < < < < < | < < < | < < < < < < < < < < < < < < < < | < < < < < < < < < < < | | < | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #ifndef __FEX_H__ #define __FEX_H__ #include <stdlib.h> #include <stdio.h> #include <limits.h> typedef int fex_t; enum { FexWaveOpen = INT_MIN, FexNullMember, FexNullAccess, FexMallocError, FexSuccess = 0, } FexStatus; extern fex_t fex_create(const char *); extern fex_t fex_destroy(fex_t); extern unsigned char *fex_get_spectrogram(fex_t, int *, int *); extern int *fex_get_path(fex_t); extern int fex_threshold(fex_t, float); extern double fex_measure(fex_t, double *, double*); extern int fex_coordinates(fex_t, double, double, double *, double*); #endif /* __FEX_H__ */ |
Added src/fex_struct.h.
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #ifndef __FEX_STRUCT_H__ #define __FEX_STRUCT_H__ #define fftAmp(fex,t,f) (fex)->fft.amp[(fex)->fft.nfreq * t + f] typedef struct FEX { struct { const char *name; int samples, rate; double *data; } wave; struct { double *time, *freq, *amp; int ntime, nfreq; int *path; } fft; struct { int winlen, hop; double lopass, hipass, floor, threshold; // colors } conf; } FEX; #endif /* __FEX_STRUCT_H__ */ |
Changes to src/fft.c.
1 | /**********************************************************************\ | < | > | | < < < < < < < < < < < < < < < > > > > > | > > | > | < | > | | | | < | | > | < < | > | > | > | | | | | | | < | | | > | | | < | < < | | | | < < | | < | < | | | | < > > > | | > > > > | | > | < | < > | > | | < | | | < < < < < < < < | > | < > > | | < < < < < | > > > > | | > | > > | > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | /**********************************************************************\ * FFT.C * Part of FEX, see FEX.C for complete license information * Author: Jesse McClure, copyright 2013-2015 * License; GPL3 \**********************************************************************/ #include <math.h> #include <fftw3.h> #include "fex.h" #include "fex_struct.h" // TODO configurable window_function static double window_function[4] = { 0.5, 0.5, 0, 0 }; #define MatrixAmp(mat,nf,t,f) (mat)[nf * t + f] fex_t create_fft(FEX *fex) { if (!fex) return FexNullAccess; /* allocate space */ fex->fft.nfreq = fex->conf.winlen / 2 + 0.5; //fex->fft.ntime = (fex->wave.samples - fex->conf.winlen) / fex->conf.hop; fex->fft.ntime = fex->wave.samples / fex->conf.hop; fex->fft.freq = malloc(fex->fft.nfreq * sizeof(double)); fex->fft.time = malloc(fex->fft.ntime * sizeof(double)); fex->fft.amp = malloc(fex->fft.nfreq * fex->fft.ntime * sizeof(double)); /* fill time and freq arrays */ double nyquist = (double) fex->wave.rate / 2000.0; double dt = fex->wave.samples / (double) (fex->wave.rate * fex->fft.ntime); double df = nyquist / fex->fft.nfreq; int i; fex->fft.time[0] = fex->fft.freq[0] = 0.0; for (i = 1; i < fex->fft.ntime; ++i) fex->fft.time[i] = fex->fft.time[i-1] + dt; for (i = 1; i < fex->fft.nfreq; ++i) fex->fft.freq[i] = fex->fft.freq[i-1] + df; /* preare fftw */ fftw_complex *in, *out; fftw_plan plan; in = (fftw_complex *) fftw_malloc(fex->conf.winlen * sizeof(fftw_complex)); out = (fftw_complex *) fftw_malloc(fex->conf.winlen * sizeof(fftw_complex)); plan = fftw_plan_dft_1d(fex->conf.winlen, in, out, FFTW_FORWARD, FFTW_ESTIMATE); /* windowing function */ double *window = malloc(fex->conf.winlen * sizeof(double)); int t, f, pos; for (t = 0; t < fex->conf.winlen; ++t) window[t] = window_function[0] - // TODO - FIXME? window_function[1] * cos(2 * M_PI * t / (fex->conf.winlen - 1.0)) + window_function[2] * cos(2 * M_PI * t / (fex->conf.winlen - 1.0)) - window_function[3] * cos(2 * M_PI * t / (fex->conf.winlen - 1.0)); /* loop over signal */ for (pos = 0, t = 0; pos < fex->wave.samples; pos += fex->conf.hop, ++t) { /* copy windowed chunk to in */ for (i = 0; i < fex->conf.winlen; ++i) { if (pos + i < fex->wave.samples) in[i][0] = fex->wave.data[pos + i] * window[i]; else in[i][0] = 0.0; in[i][1] = 0.0; } /* calculate fft and fill amp */ fftw_execute(plan); for (f = 0; f < fex->fft.nfreq; ++f) fftAmp(fex,t,f) = sqrt(out[f][0] * out[f][0] + out[f][1] * out[f][1]); } /* zero unused bins */ for (; t < fex->fft.ntime; ++t) for (f = 0; f < fex->fft.nfreq; ++f) fftAmp(fex,t,f) = 0; /* drestroy and free data */ fftw_destroy_plan(plan); fftw_free(out); fftw_free(in); free(window); /* psuedo bandpass filter */ int f_zero, f_count = 0; for (f = 0; fex->fft.freq[f] < fex->conf.lopass; ++f); f_zero = f; for (; fex->fft.freq[f] <= fex->conf.hipass; ++f) f_count++; for (f = 0; f < f_count; ++f) fex->fft.freq[f] = fex->fft.freq[f+f_zero]; fex->fft.freq = realloc(fex->fft.freq, f_count * sizeof(double)); double *new_amp = malloc(fex->fft.ntime * f_count * sizeof(double)); for (t = 0; t < fex->fft.ntime; ++t) for (f = 0; f < f_count; ++f) new_amp[f_count * t + f] = fex->fft.amp[fex->fft.nfreq * t + f + f_zero]; fex->fft.nfreq = f_count; free(fex->fft.amp); fex->fft.amp = new_amp; /* normalize, log transform and scale to dB */ double max = 0.0; for (t = 0; t < fex->fft.ntime; ++t) for (f = 0; f < fex->fft.nfreq; ++f) if (fftAmp(fex,t,f) > max) max = fftAmp(fex,t,f); for (t = 0; t < fex->fft.ntime; ++t) for (f = 0; f < fex->fft.nfreq; ++f) fftAmp(fex,t,f) = 10.0 * log10(fftAmp(fex,t,f) / max); } fex_t destroy_fft(FEX *fex) { if (!fex) return FexNullAccess; fex_t ret = FexSuccess; if (!fex->fft.amp) ret = FexNullMember; free(fex->fft.amp); fex->fft.amp = NULL; if (!fex->fft.time) ret = FexNullMember; free(fex->fft.time); fex->fft.time = NULL; if (!fex->fft.freq) ret = FexNullMember; free(fex->fft.freq); fex->fft.freq = NULL; return ret; } |
Added src/glFex.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | #ifdef _WIN32_ #include <windows.h> #endif #include <GL/freeglut.h> #include "fex.h" // http://freeglut.sourceforge.net/docs/api.php#Freeglut.h_Header typedef unsigned short int bool; enum { false = 0, true }; static bool running = true, overlay = true, hud = true; static fex_t fex; static int topWin, win; static double time, freq, calc; static GLint SpectroTexture; static int w, h; static unsigned char *data = NULL; int redraw_spectrogram() { data = fex_get_spectrogram(fex, &w, &h); calc = fex_measure(fex,NULL,NULL); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(1, &SpectroTexture); glBindTexture(GL_TEXTURE_2D, SpectroTexture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, data); glBindTexture(GL_TEXTURE_2D, SpectroTexture); return 0; } void drawTop() { glClear(GL_COLOR_BUFFER_BIT); glColor4f(1.0,1.0,1.0, 1.0); //glColor4f(0.5,0.525,0.575, 1.0); glBegin(GL_QUADS); glVertex2f(-1.0, -1.0); glVertex2f(-1.0, 1.0); glVertex2f(1.0, 1.0); glVertex2f(1.0, -1.0); glEnd(); glutSwapBuffers(); } /* Handler for window-repaint event. Call back when the window first appears and whenever the window needs to be re-painted. */ void display() { glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_MULTISAMPLE_ARB); /* Use spectrogram background: */ glColor4f(1.0,1.0,1.0, 1.0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, SpectroTexture); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex2f(-1.0f, -1.0f); glTexCoord2f(1.0, 0.0); glVertex2f(1.0f, -1.0f); glTexCoord2f(1.0, 1.0); glVertex2f( 1.0f, 1.0f); glTexCoord2f(0.0, 1.0); glVertex2f(-1.0f, 1.0f); glEnd(); glDisable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); if (overlay) { int *path = fex_get_path(fex); glColor4f(0.8,0.2,0.0, 0.4); glLineWidth(4.0); glEnable(GL_LINE_SMOOTH); int x; double dx, dy; glBegin(GL_LINE_STRIP); for (x = 0; x < w; ++x) { if (path[x] < 0) continue; dx = 2.0 * x / w - 1.0; dy = 2.0 * path[x] / h - 1.0; glVertex2f(dx,dy); } glEnd(); glColor4f(0.0,0.0,0.4, 0.5); glBegin(GL_QUADS); for (x = 0; x < w; ++x) { if (path[x] < 0) continue; dx = 2.0 * x / w - 1.0; dy = 2.0 * path[x] / h - 1.0; glVertex2f(dx-0.004,dy-0.008); glVertex2f(dx-0.004,dy+0.008); glVertex2f(dx+0.004,dy+0.008); glVertex2f(dx+0.004,dy-0.008); } glEnd(); } if (hud) { float x_units = 2.0 / (float) glutGet(GLUT_WINDOW_WIDTH); float y_units = 2.0 / (float) glutGet(GLUT_WINDOW_HEIGHT); glColor4f(0.0,0.0,0.5,0.4); glBegin(GL_QUADS); glVertex2f(-1.0f, 1.0f - 26 * y_units); glVertex2f(1.0f, 1.0f - 26 * y_units); glVertex2f( 1.0f, 1.0f); glVertex2f(-1.0f, 1.0f); glEnd(); glColor4f(1.0,0.9,0.6,0.8); glRasterPos2f(-1.0 + 8 * x_units, 1.0 - 20 * y_units); char str[32]; snprintf(str,32,"%0.3lfs %0.1lfkHz FE: %0.2lf",time,freq,calc); glutBitmapString(GLUT_BITMAP_HELVETICA_18,str); } glDisable(GL_BLEND); glutSwapBuffers(); } int show_menu(int x, int y) { //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glEnable(GL_BLEND); glutSwapBuffers(); } void specialKeys(int key, int x, int y) { static bool fullscreen = false; static int wx, wy, ww, wh; if (key == GLUT_KEY_F1) running = false; else if (key == GLUT_KEY_F2) { overlay = !overlay; redraw_spectrogram(); glutPostRedisplay(); } else if (key == GLUT_KEY_F11) glutFullScreenToggle(); else if (key == GLUT_KEY_UP) { fex_threshold(fex, 0.5); redraw_spectrogram(); glutPostRedisplay(); } else if (key == GLUT_KEY_DOWN) { fex_threshold(fex, -0.5); redraw_spectrogram(); glutPostRedisplay(); } } static int mN = -1, mX, mY, mW, mH; void mouse_button(int button, int state, int x, int y) { static bool old_hud; if (state == GLUT_DOWN) { old_hud = hud; hud = false; mN = button; mX = x; mY = y; mW = glutGet(GLUT_WINDOW_WIDTH); mH = glutGet(GLUT_WINDOW_HEIGHT); if (button == GLUT_MIDDLE_BUTTON) { glutSetWindow(topWin); int ww = glutGet(GLUT_WINDOW_WIDTH); int wh = glutGet(GLUT_WINDOW_HEIGHT); glutSetWindow(win); glutPositionWindow(0, 0); glutReshapeWindow(ww, wh); mN = -1; } } if (state == GLUT_UP) { hud = old_hud; glutPostRedisplay(); mN = -1; } } void move_resize(int x, int y) { int wx = glutGet(GLUT_WINDOW_X); int wy = glutGet(GLUT_WINDOW_Y); if (mN == -1) return; else if (mN == GLUT_LEFT_BUTTON) glutPositionWindow(wx + x - mX, wy + y - mY); else if (mN == GLUT_RIGHT_BUTTON) glutReshapeWindow(mW + x - mX, mH + y - mY); } void motion(int x, int y) { double ww = glutGet(GLUT_WINDOW_WIDTH); double wh = glutGet(GLUT_WINDOW_HEIGHT); fex_coordinates(fex, x / ww, 1.0 - y / wh, &time, &freq); glutPostRedisplay(); } /* Main function: GLUT runs as a console application starting at main() */ int main(int argc, char **argv) { fex = fex_create(argv[1]); if (fex < 0) return fex; glutInit(&argc, argv); // Initialize GLUT glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE); topWin = glutCreateWindow("OpenGL Setup Test"); // Create a window with the given title glutInitWindowSize(640, 480); // Set the window's initial width & height glutInitWindowPosition(50, 50); // Position the window's initial top-left corner glutDisplayFunc(drawTop); // Register display callback handler for window re-paint win = glutCreateSubWindow(topWin,0,0,640,480); glClearColor(1.0,1.0,1.0,1.0); glutDisplayFunc(display); // Register display callback handler for window re-paint glutMouseFunc(mouse_button); glutMotionFunc(move_resize); glutPassiveMotionFunc(motion); glutSpecialFunc(specialKeys); redraw_spectrogram(); while (running) glutMainLoopEvent(); double pex, tex; calc = fex_measure(fex,&pex,&tex); fex_destroy(fex); printf("%lf / %lf = %lf\n",pex,tex,calc); return 0; } |
Deleted src/icon.xpm.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/spectro.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to src/wave.c.
1 | /**********************************************************************\ | < | > | | < < < < < < < < < < < < < < < > | | < > | | < | > | | | | | > | | | > | | | | | < < < | > > > | | | | | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 | /**********************************************************************\ * WAVE.C * Part of FEX, see FEX.C for complete license information * Author: Jesse McClure, copyright 2013-2015 * License; GPL3 \**********************************************************************/ #include <sndfile.h> #include "fex.h" #include "fex_struct.h" fex_t read_wave(FEX *fex) { if (!fex) return FexNullAccess; SF_INFO info; SNDFILE *file = sf_open(fex->wave.name, SFM_READ, &info); if (!file) return FexWaveOpen; /* read in if single channel */ fex->wave.samples = info.frames; fex->wave.rate = info.samplerate; fex->wave.data = malloc(fex->wave.samples * sizeof(double)); sf_count_t n; if (info.channels == 1) { n = sf_readf_double(file, fex->wave.data, fex->wave.samples); } /* otherwise downmix to single channel */ else { double *multi = malloc(info.frames * info.channels * sizeof(double)); n = sf_readf_double(file, multi, info.frames * info.channels); /* average across all channels */ int i, nframe; double mix; for (nframe = 0; nframe < info.frames; ++nframe) { mix = 0.0; for (i = 0; i < info.channels; ++i) mix += multi[nframe * info.channels + i]; fex->wave.data[nframe] = mix / info.channels; } free(multi); } /* close file and check that we read the right number of samples */ sf_close(file); if (n != fex->wave.samples) fprintf(stderr, "[Fex:Wave] Warning reading \"%s\"\n\tRead %d / %d samples\n", fex->wave.name, n, fex->wave.samples); return FexSuccess; } fex_t free_wave(FEX *fex) { if (!fex) return FexNullAccess; if (!fex->wave.data) return FexNullMember; free(fex->wave.data); fex->wave.data = NULL; return FexSuccess; } |
Deleted src/xlib.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/xlib_actions.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/xlib_events.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted src/xlib_toolwin.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added winbuild.
> > > | 1 2 3 | gcc -c -o example.o example.c -I"C:\Program Files\Common Files\MinGW\GLUT\include" gcc -o example.exe example.o -L"C:\Program Files\Common Files\MinGW\GLUT\lib" -lglut32 -lopengl32 -Wl,--subsystem,windows |