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
29 #define TIME_SECONDS__STR "ssss.sss"
30 #define TIME_HMS__STR "h:mm:ss.sss"
31 #define TIME_HMS2__STR "h:mm:ss"
32 #define TIME_HMS3__STR "hh:mm:ss"
33 #define TIME_HMSF__STR "h:mm:ss:ff"
34 #define TIME_SAMPLES__STR "audio samples"
35 #define TIME_SAMPLES_HEX__STR "audio samples (hex)"
36 #define TIME_FRAMES__STR "video frames"
37 #define TIME_FEET_FRAMES__STR "video frames (feet)"
42 DB(float infinitygain
= INFINITYGAIN
);
45 // return power of db using a table
47 float fromdb_table(float db
);
48 // return power from db using log10
50 static float fromdb(float db
);
52 // convert db to power using a formula
53 static float todb(float power
);
55 inline DB
& operator++() { if(db
< MAXGAIN
) db
+= 0.1; return *this; };
56 inline DB
& operator--() { if(db
> INFINITYGAIN
) db
-= 0.1; return *this; };
57 inline DB
& operator=(DB
&newdb
) { db
= newdb
.db
; return *this; };
58 inline DB
& operator=(int newdb
) { db
= newdb
; return *this; };
59 inline int operator==(DB
&newdb
) { return db
== newdb
.db
; };
60 inline int operator==(int newdb
) { return db
== newdb
; };
62 static float *topower
;
66 static float *allocated
;
69 // Third octave frequency table
74 Freq(const Freq
& oldfreq
);
77 static void init_table();
79 // set freq to index given
80 static int tofreq(int index
);
82 // return index of frequency
84 static int fromfreq(int index
);
86 // increment frequency by one
90 int operator>(Freq
&newfreq
);
91 int operator<(Freq
&newfreq
);
92 Freq
& operator=(const Freq
&newfreq
);
93 int operator=(const int newfreq
);
94 int operator!=(Freq
&newfreq
);
95 int operator==(Freq
&newfreq
);
96 int operator==(int newfreq
);
98 static int *freqtable
;
108 static int timeformat_totype(char *tcf
);
111 static float toframes(int64_t samples
, int sample_rate
, float framerate
);
113 static int64_t toframes_round(int64_t samples
, int sample_rate
, float framerate
);
114 static double fix_framerate(double value
);
115 static double atoframerate(char *text
);
117 // Punctuate with commas
118 static void punctuate(char *string
);
121 // separator strings for BC_TextBox::set_separators
122 // Returns 0 if the format has no separators.
123 static char* format_to_separators(int time_format
);
125 static int64_t tosamples(float frames
, int sample_rate
, float framerate
);
126 // give text representation as time
127 static char* totext(char *text
,
131 float frame_rate
= 0,
132 float frames_per_foot
= 0);
133 // give text representation as time
134 static char* totext(char *text
,
138 float frame_rate
= 0,
139 float frames_per_foot
= 0);
140 // convert time to samples
141 static int64_t fromtext(char *text
,
145 float frames_per_foot
);
146 // Convert text to seconds
147 static double text_to_seconds(char *text
,
151 float frames_per_foot
);
153 static char* print_time_format(int time_format
, char *string
);
155 static float xy_to_polar(int x
, int y
);
156 static void polar_to_xy(float angle
, int radius
, int &x
, int &y
);
158 // Numbers < 0 round down if next digit is < 5
159 // Numbers > 0 round up if next digit is > 5
160 static int64_t round(double result
);
162 // Flooring type converter rounded to nearest .001
163 static int64_t to_int64(double result
);
165 static float quantize10(float value
);
166 static float quantize(float value
, float precision
);
168 static void* int64_to_ptr(uint64_t value
);
169 static uint64_t ptr_to_int64(void *ptr
);