postfish.h 2.94 KB
Newer Older
Monty Montgomery's avatar
Monty Montgomery committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 *
 *  postfish
 *    
 *      Copyright (C) 2002-2003 Monty
 *
 *  Postfish is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  Postfish is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with Postfish; see the file COPYING.  If not, write to the
 *  Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * 
 */

/* This project is a small, tightly tailored application.  it is not
   designed to be nigh-infinitely extensible, nor is it designed to be
   reusable code.  It's monolithic, inflexible, and designed that way
   on purpose. */

29 30 31
#ifndef _POSTFISH_H_
#define _POSTFISH_H_

Monty Montgomery's avatar
Monty Montgomery committed
32
#define _GNU_SOURCE
33
#define _ISOC99_SOURCE
Monty Montgomery's avatar
Monty Montgomery committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#define _FILE_OFFSET_BITS 64
#define _REENTRANT 1
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#define __USE_GNU 1
#include <pthread.h>
#include <string.h>
#include <math.h>
#include <signal.h>
#include <fcntl.h>

53 54
#define OUTPUT_CHANNELS 6

55 56 57 58 59 60 61 62 63 64 65
static inline float todB(float x){
  return logf((x)*(x)+1e-30f)*4.34294480f;
}

static inline float fromdB(float x){
  return expf((x)*.11512925f);
}

#ifdef UGLY_IEEE754_FLOAT32_HACK

static inline float todB_a(const float *x){
66
  return (float)((*(int32_t *)x)&0x7fffffff) * 7.17711438e-7f -764.6161886f;
67 68 69
}

static inline float fromdB_a(float x){
70
  int y=1.39331762961e+06f*((x<-400?-400:x)+764.6161886f);
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
  return *(float *)&y;
}

#else

static inline float todB_a(const float *x){
  return todB(*x);
}

static inline float fromdB_a(float x){
  return fromdB(x);
}

#endif

86 87 88 89 90
#ifndef max
#define max(x,y) ((x)>(y)?(x):(y))
#endif


Monty Montgomery's avatar
Monty Montgomery committed
91
#define toOC(n)     (log(n)*1.442695f-5.965784f)
92
#define fromOC(o)   (exp(((o)+5.965784f)*.693147f))
93 94
#define toBark(n)   (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
#define fromBark(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f)
Monty Montgomery's avatar
Monty Montgomery committed
95

Monty Montgomery's avatar
Monty Montgomery committed
96
typedef struct time_linkage {
Monty Montgomery's avatar
Monty Montgomery committed
97
  int samples;  /* normally same as size; exception is EOF */
Monty Montgomery's avatar
Monty Montgomery committed
98
  int channels;
99
  float **data;
100
  u_int32_t active; /* active channel bitmask */
Monty Montgomery's avatar
Monty Montgomery committed
101 102 103
} time_linkage;

extern pthread_mutex_t master_mutex;
104 105 106 107

extern sig_atomic_t loop_active;
extern sig_atomic_t playback_active;
extern sig_atomic_t playback_exit;
108
extern sig_atomic_t playback_seeking;
109
extern sig_atomic_t master_att;
110 111 112 113 114
extern int outfileno;
extern int seekable;
extern int eventpipe[2];
extern int input_ch;

Monty Montgomery's avatar
Monty Montgomery committed
115
extern void mainpanel_go(int n,char *list[],int ch);
116
extern int mute_channel_muted(u_int32_t bitmap,int i);
Monty Montgomery's avatar
Monty Montgomery committed
117

118
#endif
119