libvisual  0.5.0
lv_fourier.h
1 /* Libvisual - The audio visualisation framework.
2  *
3  * Copyright (C) 2012 Libvisual team
4  * 2004-2006 Dennis Smit
5  *
6  * Authors: Chong Kai Xiong <kaixiong@codeleft.sg>
7  * Dennis Smit <ds@nerds-incorporated.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as
11  * published by the Free Software Foundation; either version 2.1
12  * 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
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #ifndef _LV_FOURIER_H
25 #define _LV_FOURIER_H
26 
27 #include <libvisual/lv_defines.h>
28 
34 #ifdef __cplusplus
35 
36 #include <memory>
37 
38 namespace LV {
39 
41  class LV_API DFT
42  {
43  public:
44 
61  DFT (unsigned int samples_out, unsigned int samples_in);
62 
63  DFT (DFT const&) = delete;
64 
68  DFT (DFT&& rhs);
69 
73  ~DFT ();
74 
75  DFT& operator= (DFT const&) = delete;
76 
80  DFT& operator= (DFT&& rhs);
81 
87  unsigned int get_spectrum_size () const;
88 
95  void perform (float *output, float const* input);
96 
107  static void log_scale (float* output, float const* input, unsigned int size);
108 
109  static void log_scale_standard (float* output, float const* input, unsigned int size);
110 
111  static void log_scale_custom (float* output, float const* input, unsigned int size, float log_scale_divisor);
112 
113  private:
114 
115  class Impl;
116 
117  std::unique_ptr<Impl> m_impl;
118  };
119 
120 } // LV namespace
121 
122 #endif /* __cplusplus */
123 
124 
125 /* C API bindings */
126 
127 #ifdef __cplusplus
128 typedef ::LV::DFT VisDFT;
129 #else
130 typedef struct _VisDFT VisDFT;
131 struct _VisDFT;
132 #endif
133 
134 LV_BEGIN_DECLS
135 
136 LV_API VisDFT *visual_dft_new (unsigned int samples_out, unsigned int samples_in);
137 LV_API void visual_dft_free (VisDFT *dft);
138 
139 LV_API void visual_dft_perform (VisDFT *dft, float *output, float const *input);
140 
141 LV_API void visual_dft_log_scale (float *output, float const *input, unsigned int size);
142 LV_API void visual_dft_log_scale_standard (float *output, float const *input, unsigned int size);
143 LV_API void visual_dft_log_scale_custom (float *output, float const *input, unsigned int size, float log_scale_divisor);
144 
145 LV_END_DECLS
146 
151 #endif /* _LV_FOURIER_H */