11 #define INFINITYGAIN -40
13 #define TOTALFREQS 1024
22 #define TIME_SECONDS 8
24 #define TIME_SAMPLES 2
25 #define TIME_SAMPLES_HEX 3
28 #define TIME_FEET_FRAMES 5
33 DB(float infinitygain
= INFINITYGAIN
);
36 // return power of db using a table
38 float fromdb_table(float db
);
39 // return power from db using log10
41 static float fromdb(float db
);
43 // convert db to power using a formula
44 static float todb(float power
);
46 inline DB
& operator++() { if(db
< MAXGAIN
) db
+= 0.1; return *this; };
47 inline DB
& operator--() { if(db
> INFINITYGAIN
) db
-= 0.1; return *this; };
48 inline DB
& operator=(DB
&newdb
) { db
= newdb
.db
; return *this; };
49 inline DB
& operator=(int newdb
) { db
= newdb
; return *this; };
50 inline int operator==(DB
&newdb
) { return db
== newdb
.db
; };
51 inline int operator==(int newdb
) { return db
== newdb
; };
53 static float *topower
;
57 static float *allocated
;
60 // Third octave frequency table
65 Freq(const Freq
& oldfreq
);
68 static void init_table();
70 // set freq to index given
71 static int tofreq(int index
);
73 // return index of frequency
75 static int fromfreq(int index
);
77 // increment frequency by one
81 int operator>(Freq
&newfreq
);
82 int operator<(Freq
&newfreq
);
83 Freq
& operator=(const Freq
&newfreq
);
84 int operator=(const int newfreq
);
85 int operator!=(Freq
&newfreq
);
86 int operator==(Freq
&newfreq
);
87 int operator==(int newfreq
);
89 static int *freqtable
;
100 static float toframes(int64_t samples
, int sample_rate
, float framerate
);
102 static int64_t toframes_round(int64_t samples
, int sample_rate
, float framerate
);
103 static double fix_framerate(double value
);
104 static double atoframerate(char *text
);
106 // Punctuate with commas
107 static void punctuate(char *string
);
110 // separator strings for BC_TextBox::set_separators
111 // Returns 0 if the format has no separators.
112 static char* format_to_separators(int time_format
);
114 static int64_t tosamples(float frames
, int sample_rate
, float framerate
);
115 // give text representation as time
116 static char* totext(char *text
,
120 float frame_rate
= 0,
121 float frames_per_foot
= 0);
122 // give text representation as time
123 static char* totext(char *text
,
127 float frame_rate
= 0,
128 float frames_per_foot
= 0);
129 // convert time to samples
130 static int64_t fromtext(char *text
,
134 float frames_per_foot
);
135 // Convert text to seconds
136 static double text_to_seconds(char *text
,
140 float frames_per_foot
);
142 static char* print_time_format(int time_format
, char *string
);
144 static float xy_to_polar(int x
, int y
);
145 static void polar_to_xy(float angle
, int radius
, int &x
, int &y
);
147 // Numbers < 0 round down if next digit is < 5
148 // Numbers > 0 round up if next digit is > 5
149 static int64_t round(double result
);
151 // Flooring type converter rounded to nearest .001
152 static int64_t to_int64(double result
);
154 static float quantize10(float value
);
155 static float quantize(float value
, float precision
);
157 static void* int64_to_ptr(uint64_t value
);
158 static uint64_t ptr_to_int64(void *ptr
);