tomwalters@0: /* tomwalters@0: Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989 tomwalters@0: =========================================================================== tomwalters@0: tomwalters@0: Permission to use, copy, modify, and distribute this software without fee tomwalters@0: is hereby granted for research purposes, provided that this copyright tomwalters@0: notice appears in all copies and in all supporting documentation, and that tomwalters@0: the software is not redistributed for any fee (except for a nominal shipping tomwalters@0: charge). Anyone wanting to incorporate all or part of this software in a tomwalters@0: commercial product must obtain a license from the Medical Research Council. tomwalters@0: tomwalters@0: The MRC makes no representations about the suitability of this tomwalters@0: software for any purpose. It is provided "as is" without express or implied tomwalters@0: warranty. tomwalters@0: tomwalters@0: */ tomwalters@0: tomwalters@0: /* tomwalters@0: recurse.h tomwalters@0: ========= tomwalters@0: tomwalters@0: defines for modular recursive filterbank system tomwalters@0: tomwalters@0: J.Holdsworth MRC-APU 17th January 1989. tomwalters@0: tomwalters@0: */ tomwalters@0: tomwalters@0: #define _RECURSE_H_ tomwalters@0: tomwalters@0: #define NO_PHASE_COMPENSTAION (0) tomwalters@0: #define ENVELOPE_ALIGNMENT (-1) tomwalters@0: #define FINE_ALIGNMENT (-2) tomwalters@0: #define ACUASAL (-2) tomwalters@0: tomwalters@0: #define LOG_ZERO (-10) tomwalters@0: tomwalters@0: #if !defined( LITTLE_FIRST ) && !defined( BIG_FIRST ) tomwalters@0: tomwalters@0: #if defined( vax ) || defined( MIPSEL ) || defined( NICHE ) || defined( IBM ) tomwalters@0: #define LITTLE_FIRST tomwalters@0: #endif tomwalters@0: tomwalters@0: #if defined( sun ) || defined( MIPSEB ) || defined( mc68000 ) || defined( THINK_C ) tomwalters@0: #define BIG_FIRST tomwalters@0: #endif tomwalters@0: tomwalters@0: #endif tomwalters@0: tomwalters@0: #if defined( LITTLE_FIRST ) tomwalters@0: tomwalters@0: typedef union { long all ; struct { short lo, hi ; } shorts ; } Phase ; tomwalters@0: #define ALL( _var ) ( _var.all ) tomwalters@0: #define HI( _var ) ( _var.shorts.hi ) tomwalters@0: tomwalters@0: #else tomwalters@0: tomwalters@0: #if defined( BIG_FIRST ) tomwalters@0: tomwalters@0: typedef union { long all ; struct { short hi, lo ; } shorts ; } Phase ; tomwalters@0: #define ALL( _var ) ( _var.all ) tomwalters@0: #define HI( _var ) ( _var.shorts.hi ) tomwalters@0: tomwalters@0: #else tomwalters@0: tomwalters@0: #ifdef DSP32 tomwalters@0: tomwalters@0: typedef union { int all ; struct { short lo, hi ; } shorts ; } Phase ; tomwalters@0: #define ALL( _var ) ( ( _var ).all ) tomwalters@0: #define HI( _var ) ( ( _var ).shorts.hi & 0xff ) tomwalters@0: tomwalters@0: #else tomwalters@0: tomwalters@0: typedef long Phase ; tomwalters@0: #define ALL( _var ) ( _var ) tomwalters@0: #define HI( _var ) ( ( _var ) >> 16 ) tomwalters@0: tomwalters@0: #endif tomwalters@0: tomwalters@0: #endif tomwalters@0: #endif tomwalters@0: tomwalters@0: #ifdef DSP32 tomwalters@0: typedef float *Table ; tomwalters@0: #else tomwalters@0: typedef int *Table ; tomwalters@0: #endif tomwalters@0: tomwalters@0: typedef struct _recursive_filter_state RecursiveFilterState ; tomwalters@0: tomwalters@0: typedef struct { short real, imag ; } scomplex ; tomwalters@0: typedef struct { int real, imag ; } icomplex ; tomwalters@0: typedef struct { long real, imag ; } lcomplex ; tomwalters@0: typedef struct { float real, imag ; } fcomplex ; tomwalters@0: typedef struct { double real, imag ; } dcomplex ; tomwalters@0: tomwalters@0: tomwalters@0: extern RecursiveFilterState *NewRecursiveFilter() ; tomwalters@0: extern double bandwidth_normalisation() ; tomwalters@0: extern int imB() ; tomwalters@0: tomwalters@0: extern int DoFilterShortDataArray() ; extern int DoEnvelopeShortDataArray() ; tomwalters@0: extern int DoRealFilterShortDataArray() ; extern int DoRealEnvelopeShortDataArray() ; tomwalters@0: tomwalters@0: extern int DoRealFilterFloatDataArray() ; extern int DoRealEnvelopeFloatDataArray() ; tomwalters@0: tomwalters@0: extern int DoFilterIntDataArray() ; tomwalters@0: extern int DoRealFilterIntDataArray() ; tomwalters@0: extern int DoRealFilterDoubleDataArray() ; tomwalters@0: extern int DoComplexFilterShortDataArray() ; tomwalters@0: extern int DoComplexFilterFloatDataArray() ; tomwalters@0: tomwalters@0: extern int DoNewFilterDataArray() ; tomwalters@0: tomwalters@0: /* formuale.h for attempt at safety */ tomwalters@0: tomwalters@0: extern double Erb(), ErbScale(), FofErbScale(), dBAudiogram(), Audiogram() ; tomwalters@0: tomwalters@0: extern int filterSineTableBits, filterSineTableShift ; tomwalters@0: extern unsigned long filterSineTableSize, filterSineTableMask ; tomwalters@0: extern Table filterSineTable, filterCosineTable ; tomwalters@0: tomwalters@0: tomwalters@0: /* private data structure for filter */ tomwalters@0: tomwalters@0: struct _recursive_filter_state { tomwalters@0: double k, output_scale ; /* basic real filter parameters */ tomwalters@0: long ik, post_divisor, post_log ; /* integer versions of basic parameters */ tomwalters@0: int order, over_sample, input_bits ; /* integer filter parameters */ tomwalters@0: char *states, *states_end ; /* filter state vector */ tomwalters@0: Phase phi, output_phi ; /* integer phase of complex sinusiod */ tomwalters@0: #ifdef DSP32 tomwalters@0: int delta_phi, output_delta_phi ; /* phase increments for filter cf */ tomwalters@0: #else tomwalters@0: long delta_phi, output_delta_phi ; /* phase increments for filter cf */ tomwalters@0: #endif tomwalters@0: float gain, k1, k2 ; /* for new filter algorithimn */ tomwalters@0: } ; tomwalters@0: