File: kaiser_window_test.c

package info (click to toggle)
sndfile-tools 1.5-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 860 kB
  • sloc: ansic: 2,923; sh: 237; python: 212; makefile: 94
file content (64 lines) | stat: -rw-r--r-- 1,845 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
** Copyright (C) 2007-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 or version 3 of the
** License.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <src/window.h>

#define ARRAY_LEN(x)	((int) ((sizeof (x)) / (sizeof (x [0]))))

int
main (void)
{
	double window [2000] ;
	int k ;

	printf ("%-37s : ", "kaiser_window_test") ;
	fflush (stdout) ;

	calc_kaiser_window (window, ARRAY_LEN (window), 1.0) ;

	for (k = 0 ; k < ARRAY_LEN (window) ; k++)
	{	if (window [k] > 1.0)
		{	printf ("\nError (%s %d) : window [%d] > 1.0.\n", __func__, __LINE__, k) ;
			exit (1) ;
			} ;

		if (window [k] < 0.0)
		{	printf ("\nError (%s %d) : window [%d] < 0.0.\n", __func__, __LINE__, k) ;
			exit (1) ;
			} ;
		} ;

	if (fabs (window [0] - window [ARRAY_LEN (window) - 1]) > 1e-20)
	{	printf ("\nError (%s %d) : fabs (%f - %f) > 1e-20)\n", __func__, __LINE__, window [0], window [ARRAY_LEN (window) - 1]) ;
		exit (1) ;
		} ;

	calc_kaiser_window (window, ARRAY_LEN (window) - 1, 1.0) ;

	if (fabs (window [0] - window [ARRAY_LEN (window) - 2]) > 1e-20)
	{	printf ("\nError (%s %d) : fabs (%f - %f) > 1e-20)\n", __func__, __LINE__, window [0], window [ARRAY_LEN (window) - 1]) ;
		exit (1) ;
		} ;

	puts ("ok") ;

	return 0 ;
} /* main */