Minor build fixes, integrate XMMS into the autoconfed stuff
[platform/upstream/libvorbis.git] / lib / window.c
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5  * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
6  * PLEASE READ THESE TERMS DISTRIBUTING.                            *
7  *                                                                  *
8  * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000             *
9  * by Monty <monty@xiph.org> and The XIPHOPHORUS Company            *
10  * http://www.xiph.org/                                             *
11  *                                                                  *
12  ********************************************************************
13
14  function: window functions
15  last mod: $Id: window.c,v 1.3 1999/12/30 07:26:55 xiphmont Exp $
16
17  ********************************************************************/
18
19 #include <stdlib.h>
20 #include <math.h>
21 #include "os.h"
22
23 /* The 'vorbis window' is sin(sin(x)*sin(x)*2pi) */
24
25 double *_vorbis_window(int window,int left,int right){
26   double *ret=calloc(window,sizeof(double));
27   int leftbegin=window/4-left/2;
28   int rightbegin=window-window/4-right/2;
29   int i;
30   
31   for(i=0;i<left;i++){
32     double x=(i+.5)/left*M_PI/2.;
33     x=sin(x);
34     x*=x;
35     x*=M_PI/2.;
36     x=sin(x);
37     ret[i+leftbegin]=x;
38   }
39
40   for(i=leftbegin+left;i<rightbegin;i++)
41     ret[i]=1.;
42
43   for(i=0;i<right;i++){
44     double x=(right-i-.5)/right*M_PI/2.;
45     x=sin(x);
46     x*=x;
47     x*=M_PI/2.;
48     x=sin(x);
49     ret[i+rightbegin]=x;
50   }
51
52   return(ret);
53 }
54