5 * Copyright (C) 2002-2005 Monty
7 * Postfish is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * Postfish is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Postfish; see the file COPYING. If not, write to the
19 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 /* This project is a small, tightly tailored application. it is not
25 designed to be nigh-infinitely extensible, nor is it designed to be
26 reusable code. It's monolithic, inflexible, and designed that way
33 #define _ISOC99_SOURCE
34 #define _FILE_OFFSET_BITS 64
44 #include <sys/types.h>
54 extern void ef_free(void * address
);
55 extern void *ef_realloc(void * oldBuffer
, size_t newSize
);
56 extern void *ef_malloc(size_t size
);
57 extern void *ef_calloc(size_t nelem
, size_t elsize
);
58 extern void *ef_valloc (size_t size
);
61 #define realloc ef_realloc
62 #define malloc ef_malloc
63 #define calloc ef_calloc
64 #define valloc ef_valloc
67 #define OUTPUT_CHANNELS 8 // UI code assumes this is <=8
68 #define MAX_INPUT_CHANNELS 32 // engine code requires <= 32
70 static inline float todB(float x
){
71 return logf((x
)*(x
)+1e-30f
)*4.34294480f
;
74 static inline double todBd(double x
){
75 return log((x
)*(x
)+1e-30)*4.34294480;
78 static inline float fromdB(float x
){
79 return expf((x
)*.11512925f
);
82 static inline int zerome(double x
){
83 return (x
*x
< 1.e
-30);
86 #ifdef UGLY_IEEE754_FLOAT32_HACK
88 static inline float todB_a(const float x
){
94 ix
.i
= ix
.i
&0x7fffffff;
95 return (float)(ix
.i
* 7.17711438e-7f
-764.6161886f
);
98 // eliminate a *.5 in ops on sq magnitudes
99 static inline float todB_a2(const float x
){
105 ix
.i
= ix
.i
&0x7fffffff;
106 return (float)(ix
.i
* 3.58855719e-7f
-382.3080943f
);
109 static inline float fromdB_a(const float x
){
114 ix
.i
= (x
< -300.f
? 0 : 1.39331762961e+06f
*(x
+764.6161886f
));
118 static inline void underguard(float *x
){
124 if((ix
.i
& 0x7f800000)==0) *x
=0.0f
;
129 static inline float todB_a(const float *x
){
133 static inline float fromdB_a(float x
){
137 static inline void underguard(float *x
){
138 if(*x
<1e-30f
&& *x
>-1e-30f
) x
=0.0f
;
144 #define max(x,y) ((x)>(y)?(x):(y))
148 #define toOC(n) (log(n)*1.442695f-5.965784f)
149 #define fromOC(o) (exp(((o)+5.965784f)*.693147f))
150 #define toBark(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
151 #define fromBark(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f)
153 typedef struct time_linkage
{
155 int samples
; /* normally same as size; exception is EOF */
158 u_int32_t active
; /* active channel bitmask */
162 extern sig_atomic_t loop_active
;
163 extern sig_atomic_t playback_active
;
164 extern sig_atomic_t playback_exit
;
165 extern sig_atomic_t playback_seeking
;
166 extern sig_atomic_t master_att
;
167 extern int outfileno
;
168 extern int input_seekable
;
169 extern int eventpipe
[2];
171 extern int input_size
;
172 extern int input_rate
;
174 extern int mute_channel_muted(u_int32_t bitmap
,int i
);
175 extern void clean_exit(int sig
);