/tags/rel-0-6-0/FreeSpeech/audio_blocks/src/window.c
# · C · 66 lines · 37 code · 8 blank · 21 comment · 4 complexity · d61e4662ef16e65edf2d952cf03b395e MD5 · raw file
- /********************************************************************
- * *
- * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
- * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
- * PLEASE READ THESE TERMS DISTRIBUTING. *
- * *
- * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
- * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
- * http://www.xiph.org/ *
- * *
- ********************************************************************
- function: window functions
- last mod: $Id: window.c 1439 2001-08-01 16:26:54Z jmvalin $
- ********************************************************************/
- #include <stdlib.h>
- #include <math.h>
- #include "window.h"
- //#include "os.h"
- //#include "misc.h"
- //@implements MDCT
- double *_vorbis_window(int type, int window,int left,int right){
- double *ret=calloc(window,sizeof(double));
- switch(type){
- case 0:
- /* The 'vorbis window' (window 0) is sin(sin(x)*sin(x)*2pi) */
- {
- int leftbegin=window/4-left/2;
- int rightbegin=window-window/4-right/2;
- int i;
-
- for(i=0;i<left;i++){
- double x=(i+.5)/left*M_PI/2.;
- x=sin(x);
- x*=x;
- x*=M_PI/2.;
- x=sin(x);
- ret[i+leftbegin]=x;
- }
-
- for(i=leftbegin+left;i<rightbegin;i++)
- ret[i]=1.;
-
- for(i=0;i<right;i++){
- double x=(right-i-.5)/right*M_PI/2.;
- x=sin(x);
- x*=x;
- x*=M_PI/2.;
- x=sin(x);
- ret[i+rightbegin]=x;
- }
- }
- break;
- default:
- free(ret);
- return(NULL);
- }
- return(ret);
- }