#include "mathutils.h"
#include "config.h"
+
+/** Window types */
+typedef enum
+{
+ aubio_win_rectangle,
+ aubio_win_hamming,
+ aubio_win_hanning,
+ aubio_win_hanningz,
+ aubio_win_blackman,
+ aubio_win_blackman_harris,
+ aubio_win_gaussian,
+ aubio_win_welch,
+ aubio_win_parzen,
+ aubio_win_default = aubio_win_hanningz,
+} aubio_window_type;
+
fvec_t *
-new_aubio_window (uint_t size, aubio_window_type wintype)
+new_aubio_window (char_t * window_type, uint_t size)
{
// create fvec of size x 1 channel
fvec_t * win = new_fvec( size, 1);
smpl_t * w = win->data[0];
uint_t i;
+ aubio_window_type wintype;
+ if (strcmp (window_type, "rectangle") == 0)
+ wintype = aubio_win_rectangle;
+ else if (strcmp (window_type, "hamming") == 0)
+ wintype = aubio_win_hamming;
+ else if (strcmp (window_type, "hanning") == 0)
+ wintype = aubio_win_hanning;
+ else if (strcmp (window_type, "hanningz") == 0)
+ wintype = aubio_win_hanningz;
+ else if (strcmp (window_type, "blackman") == 0)
+ wintype = aubio_win_blackman;
+ else if (strcmp (window_type, "blackman_harris") == 0)
+ wintype = aubio_win_blackman_harris;
+ else if (strcmp (window_type, "gaussian") == 0)
+ wintype = aubio_win_gaussian;
+ else if (strcmp (window_type, "welch") == 0)
+ wintype = aubio_win_welch;
+ else if (strcmp (window_type, "parzen") == 0)
+ wintype = aubio_win_parzen;
+ else if (strcmp (window_type, "default") == 0)
+ wintype = aubio_win_default;
+ else {
+ AUBIO_ERR ("unknown window type %s, using default.\n", window_type);
+ wintype = aubio_win_default;
+ return NULL;
+ }
switch(wintype) {
case aubio_win_rectangle:
for (i=0;i<size;i++)
extern "C" {
#endif
-/** Window types
+/** create window
References:
ps.gz</a>)
*/
-typedef enum
-{
- aubio_win_rectangle,
- aubio_win_hamming,
- aubio_win_hanning,
- aubio_win_hanningz,
- aubio_win_blackman,
- aubio_win_blackman_harris,
- aubio_win_gaussian,
- aubio_win_welch,
- aubio_win_parzen
-} aubio_window_type;
-
-/** create window */
-fvec_t *new_aubio_window (uint_t size, aubio_window_type wintype);
+fvec_t *new_aubio_window (char_t * window_type, uint_t size);
/** compute the principal argument
p->fftOut = new_cvec(bufsize,1);
p->fftLastPhase = new_fvec(bufsize, channels);
p->fft = new_aubio_fft(bufsize, 1);
- p->win = new_aubio_window(bufsize, aubio_win_hanning);
+ p->win = new_aubio_window("hanning", bufsize);
return p;
}
p->res = new_cvec(bufsize,1);
p->yinfft = new_fvec(bufsize/2+1,1);
p->tol = 0.85;
- p->win = new_aubio_window(bufsize, aubio_win_hanningz);
+ p->win = new_aubio_window("hanningz", bufsize);
p->weight = new_fvec(bufsize/2+1,1);
{
uint_t i = 0, j = 1;
/* new input output */
pv->dataold = new_fvec (win_s-hop_s, channels);
pv->synthold = new_fvec (win_s-hop_s, channels);
- pv->w = new_aubio_window (win_s, aubio_win_hanningz);
+ pv->w = new_aubio_window ("hanningz", win_s);
pv->channels = channels;
pv->hop_s = hop_s;
uint_t length;
for (length = 1; length < 10; length ++ ) {
aubio_hist_t *o = new_aubio_hist(0, 1, length, 5);
- fvec_t *t = new_aubio_window(length,aubio_win_hanning);
+ fvec_t *t = new_aubio_window("hanning", length);
aubio_hist_do(o,t);
fvec_print(t);
aubio_hist_do_notnull(o,t);
aubio_hist_dyn_notnull(o,t);
fvec_print(t);
del_fvec(t);
- t = new_aubio_window(length,aubio_win_hanningz);
+ t = new_aubio_window("hanningz", length);
aubio_hist_do(o,t);
fvec_print(t);
aubio_hist_do_notnull(o,t);
uint_t length;
for (length = 2; length <= 5; length++)
{
- fvec_t *t = new_aubio_window(length,aubio_win_rectangle);
+ fvec_t *t = new_aubio_window("rectangle", length);
del_fvec(t);
- t = new_aubio_window(length,aubio_win_hamming);
+ t = new_aubio_window("hamming", length);
fvec_print(t);
del_fvec(t);
- t = new_aubio_window(length,aubio_win_hanning);
+ t = new_aubio_window("hanning", length);
fvec_print(t);
del_fvec(t);
- t = new_aubio_window(length,aubio_win_hanningz);
+ t = new_aubio_window("hanningz", length);
fvec_print(t);
del_fvec(t);
- t = new_aubio_window(length,aubio_win_blackman);
+ t = new_aubio_window("blackman", length);
fvec_print(t);
del_fvec(t);
- t = new_aubio_window(length,aubio_win_blackman_harris);
+ t = new_aubio_window("blackman_harris", length);
fvec_print(t);
del_fvec(t);
- t = new_aubio_window(length,aubio_win_gaussian);
+ t = new_aubio_window("gaussian", length);
fvec_print(t);
del_fvec(t);
- t = new_aubio_window(length,aubio_win_welch);
+ t = new_aubio_window("welch", length);
fvec_print(t);
del_fvec(t);
- t = new_aubio_window(length,aubio_win_parzen);
+ t = new_aubio_window("parzen", length);
+ fvec_print(t);
+ del_fvec(t);
+ t = new_aubio_window("default", length);
fvec_print(t);
del_fvec(t);
}