2 * fft_helpers.h - some functions around FFT analysis
4 * Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
26 #ifndef _FFT_HELPERS_H
27 #define _FFT_HELPERS_H
29 #include "lmmsconfig.h"
32 #ifdef LMMS_HAVE_FFTW3F
36 const int FFT_BUFFER_SIZE
= 2048;
46 /* returns biggest value from abs_spectrum[spec_size] array
50 float EXPORT
maximum( float * _abs_spectrum
, unsigned int _spec_size
);
52 /* apply hanning or hamming window to channel
56 int EXPORT
hanming( float * _timebuffer
, int _length
, WINDOWS _type
);
58 /* compute absolute values of complex_buffer, save to absspec_buffer
59 * take care that - compl_len is not bigger than complex_buffer!
60 * - absspec buffer is big enough!
62 * returns 0 on success, else -1
64 int EXPORT
absspec( fftwf_complex
* _complex_buffer
, float * _absspec_buffer
,
67 /* build fewer subbands from many absolute spectrum values
68 * take care that - compressedbands[] array num_new elements long
71 * returns 0 on success, else -1
73 int EXPORT
compressbands( float * _absspec_buffer
, float * _compressedband
,
74 int _num_old
, int _num_new
, int _bottom
, int _top
);
77 int EXPORT
calc13octaveband31( float * _absspec_buffer
, float * _subbands
,
78 int _num_spec
, float _max_frequency
);
80 /* compute power of finite time sequence
81 * take care num_values is length of timesignal[]
83 * returns power on success, else -1
85 float EXPORT
signalpower(float *timesignal
, int num_values
);