Recognizes if input is ogg or not.
[xiph.git] / postfish / postfish.h
blob919d192c6a823432dd1c424703aba2b7dbe2602b
1 /*
3 * postfish
4 *
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)
10 * any later version.
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
27 on purpose. */
29 #ifndef _POSTFISH_H_
30 #define _POSTFISH_H_
32 #define _GNU_SOURCE
33 #define _ISOC99_SOURCE
34 #define _FILE_OFFSET_BITS 64
35 #define _REENTRANT 1
36 #include <stdlib.h>
37 #include <unistd.h>
38 #include <stdio.h>
39 #include <fcntl.h>
40 #include <errno.h>
41 #include <string.h>
42 #include <sys/mman.h>
43 #include <sys/stat.h>
44 #include <sys/types.h>
45 #include <sys/time.h>
46 #define __USE_GNU 1
47 #include <pthread.h>
48 #include <string.h>
49 #include <math.h>
50 #include <signal.h>
51 #include <fcntl.h>
53 #if 0
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);
60 #define free ef_free
61 #define realloc ef_realloc
62 #define malloc ef_malloc
63 #define calloc ef_calloc
64 #define valloc ef_valloc
65 #endif
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){
89 union {
90 u_int32_t i;
91 float f;
92 } ix;
93 ix.f = 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){
100 union {
101 u_int32_t i;
102 float f;
103 } ix;
104 ix.f = 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){
110 union {
111 u_int32_t i;
112 float f;
113 } ix;
114 ix.i = (x < -300.f ? 0 : 1.39331762961e+06f*(x+764.6161886f));
115 return ix.f;
118 static inline void underguard(float *x){
119 union {
120 u_int32_t i;
121 float f;
122 } ix;
123 ix.f = *x;
124 if((ix.i & 0x7f800000)==0) *x=0.0f;
127 #else
129 static inline float todB_a(const float *x){
130 return todB(*x);
133 static inline float fromdB_a(float x){
134 return fromdB(x);
137 static inline void underguard(float *x){
138 if(*x<1e-30f && *x>-1e-30f) x=0.0f;
141 #endif
143 #ifndef max
144 #define max(x,y) ((x)>(y)?(x):(y))
145 #endif
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 {
154 int alias;
155 int samples; /* normally same as size; exception is EOF */
156 int channels;
157 float **data;
158 u_int32_t active; /* active channel bitmask */
159 } time_linkage;
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];
170 extern int input_ch;
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);
176 #endif