LMMS
Loading...
Searching...
No Matches
fft_helpers.h
Go to the documentation of this file.
1/*
2 * fft_helpers.h - some functions around FFT analysis
3 *
4 * Copyright (c) 2008-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 * Copyright (c) 2019 Martin Pavelek <he29.HS/at/gmail.com>
6 *
7 * This file is part of LMMS - https://lmms.io
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
23 *
24 */
25
26#ifndef LMMS_FFT_HELPERS_H
27#define LMMS_FFT_HELPERS_H
28
29#include "lmms_export.h"
30
31#include <vector>
32#include <fftw3.h>
33
34namespace lmms
35{
36
37// NOTE: FFT_BUFFER_SIZE should be considered deprecated!
38// It is used by Eq plugin and some older code here, but this should be a user
39// switchable parameter, not a constant. Use a value from FFT_BLOCK_SIZES
40constexpr auto FFT_BUFFER_SIZE = std::size_t{2048};
41
42// Allowed FFT block sizes. Ranging from barely useful to barely acceptable
43// because of performance and latency reasons.
44const std::vector<unsigned int> FFT_BLOCK_SIZES = {256, 512, 1024, 2048, 4096, 8192, 16384};
45
46// List of FFT window functions supported by precomputeWindow()
54
55
60float LMMS_EXPORT maximum(const float *abs_spectrum, unsigned int spec_size);
61float LMMS_EXPORT maximum(const std::vector<float> &abs_spectrum);
62
63
69int LMMS_EXPORT normalize(const float *abs_spectrum, float *norm_spectrum, unsigned int bin_count, unsigned int block_size);
70int LMMS_EXPORT normalize(const std::vector<float> &abs_spectrum, std::vector<float> &norm_spectrum, unsigned int block_size);
71
72
78int LMMS_EXPORT notEmpty(const std::vector<float> &spectrum);
79
80
86int LMMS_EXPORT precomputeWindow(float *window, unsigned int length, FFTWindow type, bool normalized = true);
87
88
95int LMMS_EXPORT absspec(const fftwf_complex *complex_buffer, float *absspec_buffer,
96 unsigned int compl_length);
97
98
105int LMMS_EXPORT compressbands(const float * _absspec_buffer, float * _compressedband,
106 int _num_old, int _num_new, int _bottom, int _top);
107
108
109} // namespace lmms
110
111#endif // LMMS_FFT_HELPERS_H
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
Definition AudioAlsa.cpp:35
int normalize(const float *abs_spectrum, float *norm_spectrum, unsigned int bin_count, unsigned int block_size)
Definition fft_helpers.cpp:65
float maximum(const float *abs_spectrum, unsigned int spec_size)
Definition fft_helpers.cpp:40
int precomputeWindow(float *window, unsigned int length, FFTWindow type, bool normalized)
Definition fft_helpers.cpp:105
FFTWindow
Definition fft_helpers.h:48
@ Hanning
Definition fft_helpers.h:52
@ Hamming
Definition fft_helpers.h:51
@ Rectangular
Definition fft_helpers.h:49
@ BlackmanHarris
Definition fft_helpers.h:50
const std::vector< unsigned int > FFT_BLOCK_SIZES
Definition fft_helpers.h:44
int notEmpty(const std::vector< float > &spectrum)
Definition fft_helpers.cpp:91
int compressbands(const float *absspec_buffer, float *compressedband, int num_old, int num_new, int bottom, int top)
Definition fft_helpers.cpp:189
int absspec(const fftwf_complex *complex_buffer, float *absspec_buffer, unsigned int compl_length)
Definition fft_helpers.cpp:168
constexpr auto FFT_BUFFER_SIZE
Definition fft_helpers.h:40
png_uint_32 length
Definition png.c:2247
static size_t block_size(const block_header_t *block)
Definition tlsf.c:173