Home | History | Annotate | Download | only in test
      1 /********************************************************************
      2  *                                                                  *
      3  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
      4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
      5  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
      6  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
      7  *                                                                  *
      8  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
      9  * by the Xiph.Org Foundation http://www.xiph.org/                  *
     10  *                                                                  *
     11  ********************************************************************
     12 
     13  function: utility functions for vorbis codec test suite.
     14  last mod: $Id: util.c 13293 2007-07-24 00:09:47Z erikd $
     15 
     16  ********************************************************************/
     17 
     18 #include <stdio.h>
     19 #include <stdlib.h>
     20 #include <math.h>
     21 #include <string.h>
     22 #include <errno.h>
     23 
     24 #include <vorbis/codec.h>
     25 #include <vorbis/vorbisenc.h>
     26 
     27 #include "util.h"
     28 
     29 void
     30 gen_windowed_sine (float *data, int len, float maximum)
     31 {    int k ;
     32 
     33     memset (data, 0, len * sizeof (float)) ;
     34 
     35     len /= 2 ;
     36 
     37     for (k = 0 ; k < len ; k++)
     38     {    data [k] = sin (2.0 * k * M_PI * 1.0 / 32.0 + 0.4) ;
     39 
     40         /* Apply Hanning Window. */
     41         data [k] *= maximum * (0.5 - 0.5 * cos (2.0 * M_PI * k / ((len) - 1))) ;
     42         }
     43 
     44     return ;
     45 }
     46 
     47 void
     48 set_data_in (float * data, unsigned len, float value)
     49 {        unsigned k ;
     50 
     51         for (k = 0 ; k < len ; k++)
     52                 data [k] = value ;
     53 }
     54