11 #define INFINITYGAIN -40
13 #define TOTALFREQS 1024
19 #define TIME_SAMPLES 2
20 #define TIME_SAMPLES_HEX 3
22 #define TIME_FEET_FRAMES 5
28 DB(float infinitygain
= INFINITYGAIN
);
31 // return power of db using a table
33 float fromdb_table(float db
);
34 // return power from db using log10
36 static float fromdb(float db
);
38 // convert db to power using a formula
39 static float todb(float power
);
41 inline DB
& operator++() { if(db
< MAXGAIN
) db
+= 0.1; return *this; };
42 inline DB
& operator--() { if(db
> INFINITYGAIN
) db
-= 0.1; return *this; };
43 inline DB
& operator=(DB
&newdb
) { db
= newdb
.db
; return *this; };
44 inline DB
& operator=(int newdb
) { db
= newdb
; return *this; };
45 inline int operator==(DB
&newdb
) { return db
== newdb
.db
; };
46 inline int operator==(int newdb
) { return db
== newdb
; };
48 static float *topower
;
53 // Third octave frequency table
58 Freq(const Freq
& oldfreq
);
61 static void init_table();
63 // set freq to index given
64 static int tofreq(int index
);
66 // return index of frequency
68 static int fromfreq(int index
);
70 // increment frequency by one
74 int operator>(Freq
&newfreq
);
75 int operator<(Freq
&newfreq
);
76 Freq
& operator=(const Freq
&newfreq
);
77 int operator=(const int newfreq
);
78 int operator!=(Freq
&newfreq
);
79 int operator==(Freq
&newfreq
);
80 int operator==(int newfreq
);
82 static int *freqtable
;
93 static float toframes(int64_t samples
, int sample_rate
, float framerate
);
95 static int64_t toframes_round(int64_t samples
, int sample_rate
, float framerate
);
96 static double fix_framerate(double value
);
97 static double atoframerate(char *text
);
100 static int64_t tosamples(float frames
, int sample_rate
, float framerate
);
101 static char* totext(char *text
,
105 float frame_rate
= 0,
106 float frames_per_foot
= 0); // give text representation as time
107 static char* totext(char *text
,
111 float frame_rate
= 0,
112 float frames_per_foot
= 0); // give text representation as time
113 static int64_t fromtext(char *text
,
117 float frames_per_foot
); // convert time to samples
118 static double text_to_seconds(char *text
,
122 float frames_per_foot
); // Convert text to seconds
124 static char* print_time_format(int time_format
, char *string
);
126 static float xy_to_polar(int x
, int y
);
127 static void polar_to_xy(float angle
, int radius
, int &x
, int &y
);
129 // Numbers < 0 round down if next digit is < 5
130 // Numbers > 0 round up if next digit is > 5
131 static int64_t round(double result
);
133 // Flooring type converter rounded to nearest .001
134 static int64_t to_int64(double result
);
136 static float quantize10(float value
);
137 static float quantize(float value
, float precision
);
139 static void* int64_to_ptr(uint64_t value
);
140 static uint64_t ptr_to_int64(void *ptr
);