view filter/recurse.h @ 0:5242703e91d3 tip

Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author tomwalters
date Fri, 20 May 2011 15:19:45 +0100
parents
children
line wrap: on
line source
/*
    Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989
    ===========================================================================

    Permission to use, copy, modify, and distribute this software without fee 
    is hereby granted for research purposes, provided that this copyright 
    notice appears in all copies and in all supporting documentation, and that 
    the software is not redistributed for any fee (except for a nominal shipping 
    charge). Anyone wanting to incorporate all or part of this software in a
    commercial product must obtain a license from the Medical Research Council.

    The MRC makes no representations about the suitability of this 
    software for any purpose.  It is provided "as is" without express or implied 
    warranty.
 
*/

/*
	recurse.h
	=========

    defines for modular recursive filterbank system

    J.Holdsworth MRC-APU 17th January 1989.

*/

#define _RECURSE_H_

#define NO_PHASE_COMPENSTAION (0)
#define ENVELOPE_ALIGNMENT   (-1)
#define FINE_ALIGNMENT       (-2)
#define ACUASAL              (-2)

#define LOG_ZERO (-10)

#if !defined( LITTLE_FIRST ) && !defined( BIG_FIRST )

#if defined( vax ) || defined( MIPSEL ) || defined( NICHE ) || defined( IBM )
#define LITTLE_FIRST
#endif

#if defined( sun ) || defined( MIPSEB ) || defined( mc68000 ) || defined( THINK_C )
#define BIG_FIRST
#endif

#endif

#if defined( LITTLE_FIRST )

typedef union { long all ; struct { short lo, hi ; } shorts ; } Phase ;
#define ALL( _var ) ( _var.all )
#define HI(  _var ) ( _var.shorts.hi )

#else

#if defined( BIG_FIRST )

typedef union { long all ; struct { short hi, lo ; } shorts ; } Phase ;
#define ALL( _var ) ( _var.all )
#define HI(  _var ) ( _var.shorts.hi )

#else

#ifdef DSP32

typedef union { int all ; struct { short lo, hi ; } shorts ; } Phase ;
#define ALL( _var ) ( ( _var ).all )
#define HI(  _var ) ( ( _var ).shorts.hi & 0xff )

#else

typedef long Phase ;
#define ALL( _var ) ( _var )
#define HI(  _var ) ( ( _var ) >> 16 )

#endif

#endif
#endif

#ifdef DSP32
typedef float *Table ;
#else
typedef int   *Table ;
#endif

typedef struct _recursive_filter_state RecursiveFilterState ;

typedef struct { short  real, imag ; } scomplex ;
typedef struct { int    real, imag ; } icomplex ;
typedef struct { long   real, imag ; } lcomplex ;
typedef struct { float  real, imag ; } fcomplex ;
typedef struct { double real, imag ; } dcomplex ;


extern RecursiveFilterState *NewRecursiveFilter() ;
extern double bandwidth_normalisation() ;
extern int imB() ;

extern int     DoFilterShortDataArray() ; extern int     DoEnvelopeShortDataArray() ;
extern int DoRealFilterShortDataArray() ; extern int DoRealEnvelopeShortDataArray() ;

extern int DoRealFilterFloatDataArray() ; extern int DoRealEnvelopeFloatDataArray() ;

extern int DoFilterIntDataArray() ;
extern int DoRealFilterIntDataArray() ;
extern int DoRealFilterDoubleDataArray() ;
extern int DoComplexFilterShortDataArray() ;
extern int DoComplexFilterFloatDataArray() ;

extern int DoNewFilterDataArray() ;

/* formuale.h for attempt at safety */

extern double Erb(), ErbScale(), FofErbScale(), dBAudiogram(), Audiogram() ;

extern int filterSineTableBits, filterSineTableShift ;
extern unsigned long filterSineTableSize, filterSineTableMask ;
extern Table filterSineTable, filterCosineTable ;


/* private data structure for filter */

struct _recursive_filter_state {
    double k, output_scale ;             /* basic real filter parameters */
    long ik, post_divisor, post_log ;    /* integer versions of basic parameters */
    int order, over_sample, input_bits ; /* integer filter parameters */
    char *states, *states_end ;          /* filter state vector */
    Phase phi, output_phi ;              /* integer phase of complex sinusiod */
#ifdef DSP32
    int  delta_phi, output_delta_phi ;   /* phase increments for filter cf */
#else
    long delta_phi, output_delta_phi ;   /* phase increments for filter cf */
#endif
    float gain, k1, k2 ;                 /* for new filter algorithimn */
    } ;