comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:5242703e91d3
1 /*
2 Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989
3 ===========================================================================
4
5 Permission to use, copy, modify, and distribute this software without fee
6 is hereby granted for research purposes, provided that this copyright
7 notice appears in all copies and in all supporting documentation, and that
8 the software is not redistributed for any fee (except for a nominal shipping
9 charge). Anyone wanting to incorporate all or part of this software in a
10 commercial product must obtain a license from the Medical Research Council.
11
12 The MRC makes no representations about the suitability of this
13 software for any purpose. It is provided "as is" without express or implied
14 warranty.
15
16 */
17
18 /*
19 recurse.h
20 =========
21
22 defines for modular recursive filterbank system
23
24 J.Holdsworth MRC-APU 17th January 1989.
25
26 */
27
28 #define _RECURSE_H_
29
30 #define NO_PHASE_COMPENSTAION (0)
31 #define ENVELOPE_ALIGNMENT (-1)
32 #define FINE_ALIGNMENT (-2)
33 #define ACUASAL (-2)
34
35 #define LOG_ZERO (-10)
36
37 #if !defined( LITTLE_FIRST ) && !defined( BIG_FIRST )
38
39 #if defined( vax ) || defined( MIPSEL ) || defined( NICHE ) || defined( IBM )
40 #define LITTLE_FIRST
41 #endif
42
43 #if defined( sun ) || defined( MIPSEB ) || defined( mc68000 ) || defined( THINK_C )
44 #define BIG_FIRST
45 #endif
46
47 #endif
48
49 #if defined( LITTLE_FIRST )
50
51 typedef union { long all ; struct { short lo, hi ; } shorts ; } Phase ;
52 #define ALL( _var ) ( _var.all )
53 #define HI( _var ) ( _var.shorts.hi )
54
55 #else
56
57 #if defined( BIG_FIRST )
58
59 typedef union { long all ; struct { short hi, lo ; } shorts ; } Phase ;
60 #define ALL( _var ) ( _var.all )
61 #define HI( _var ) ( _var.shorts.hi )
62
63 #else
64
65 #ifdef DSP32
66
67 typedef union { int all ; struct { short lo, hi ; } shorts ; } Phase ;
68 #define ALL( _var ) ( ( _var ).all )
69 #define HI( _var ) ( ( _var ).shorts.hi & 0xff )
70
71 #else
72
73 typedef long Phase ;
74 #define ALL( _var ) ( _var )
75 #define HI( _var ) ( ( _var ) >> 16 )
76
77 #endif
78
79 #endif
80 #endif
81
82 #ifdef DSP32
83 typedef float *Table ;
84 #else
85 typedef int *Table ;
86 #endif
87
88 typedef struct _recursive_filter_state RecursiveFilterState ;
89
90 typedef struct { short real, imag ; } scomplex ;
91 typedef struct { int real, imag ; } icomplex ;
92 typedef struct { long real, imag ; } lcomplex ;
93 typedef struct { float real, imag ; } fcomplex ;
94 typedef struct { double real, imag ; } dcomplex ;
95
96
97 extern RecursiveFilterState *NewRecursiveFilter() ;
98 extern double bandwidth_normalisation() ;
99 extern int imB() ;
100
101 extern int DoFilterShortDataArray() ; extern int DoEnvelopeShortDataArray() ;
102 extern int DoRealFilterShortDataArray() ; extern int DoRealEnvelopeShortDataArray() ;
103
104 extern int DoRealFilterFloatDataArray() ; extern int DoRealEnvelopeFloatDataArray() ;
105
106 extern int DoFilterIntDataArray() ;
107 extern int DoRealFilterIntDataArray() ;
108 extern int DoRealFilterDoubleDataArray() ;
109 extern int DoComplexFilterShortDataArray() ;
110 extern int DoComplexFilterFloatDataArray() ;
111
112 extern int DoNewFilterDataArray() ;
113
114 /* formuale.h for attempt at safety */
115
116 extern double Erb(), ErbScale(), FofErbScale(), dBAudiogram(), Audiogram() ;
117
118 extern int filterSineTableBits, filterSineTableShift ;
119 extern unsigned long filterSineTableSize, filterSineTableMask ;
120 extern Table filterSineTable, filterCosineTable ;
121
122
123 /* private data structure for filter */
124
125 struct _recursive_filter_state {
126 double k, output_scale ; /* basic real filter parameters */
127 long ik, post_divisor, post_log ; /* integer versions of basic parameters */
128 int order, over_sample, input_bits ; /* integer filter parameters */
129 char *states, *states_end ; /* filter state vector */
130 Phase phi, output_phi ; /* integer phase of complex sinusiod */
131 #ifdef DSP32
132 int delta_phi, output_delta_phi ; /* phase increments for filter cf */
133 #else
134 long delta_phi, output_delta_phi ; /* phase increments for filter cf */
135 #endif
136 float gain, k1, k2 ; /* for new filter algorithimn */
137 } ;
138