LMMS
Loading...
Searching...
No Matches
sinc.h
Go to the documentation of this file.
1/*
2 dsp/sinc.h
3
4 Copyright 2003-4 Tim Goetze <tim@quitte.de>
5
6 http://quitte.de/dsp/
7
8 computes the sinc function: sin (x * pi) / (x * pi).
9
10*/
11/*
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 as published by the Free Software Foundation; either version 2
15 of the License, or (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA or point your web browser to http://www.gnu.org.
26*/
27
28#ifndef _SINC_H_
29#define _SINC_H_
30
31#include "Sine.h"
32
33namespace DSP {
34
35/* sample sinc() with step size omega into s[], centered around s + n / 2 */
36
37inline void
38sinc (double omega, sample_t * s, int n)
39{
40 /* initial phase */
41 double phi = (n / 2) * -omega;
42
43 Sine sine (omega, phi);
44
45 for (int i = 0; i < n; ++i, phi += omega)
46 {
47 double sin_phi = sine.get();
48
49 if (fabs (phi) < 0.000000001)
50 s[i] = 1.;
51 else
52 s[i] = sin_phi / phi;
53 }
54}
55
56}; /* namespace DSP */
57
58#endif /* _SINC_H_ */
#define sinc(x)
Definition analyzer.cpp:35
LADSPA_Data sample_t
Definition basics.h:100
Definition Sine.h:34
double get()
Definition Sine.h:72
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
Definition BiQuad.h:31
int n
Definition crypt.c:458