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
);
118 // Punctuate with commas
119 static void punctuate(char *string
);
122 // separator strings for BC_TextBox::set_separators
123 // Returns 0 if the format has no separators.
124 static char* format_to_separators(int time_format
);
126 static int64_t tosamples(float frames
, int sample_rate
, float framerate
);
127 // give text representation as time
128 static char* totext(char *text
,
132 float frame_rate
= 0,
133 float frames_per_foot
= 0);
134 // give text representation as time
135 static char* totext(char *text
,
139 float frame_rate
= 0,
140 float frames_per_foot
= 0);
141 // convert time to samples
142 static int64_t fromtext(char *text
,
146 float frames_per_foot
);
147 // Convert text to seconds
148 static double text_to_seconds(char *text
,
152 float frames_per_foot
);
154 static char* print_time_format(int time_format
, char *string
);
156 static float xy_to_polar(int x
, int y
);
157 static void polar_to_xy(float angle
, int radius
, int &x
, int &y
);
159 // Numbers < 0 round down if next digit is < 5
160 // Numbers > 0 round up if next digit is > 5
161 static int64_t round(double result
);
163 // Flooring type converter rounded to nearest .001
164 static int64_t to_int64(double result
);
166 static float quantize10(float value
);
167 static float quantize(float value
, float precision
);
169 static void* int64_to_ptr(uint64_t value
);
170 static uint64_t ptr_to_int64(void *ptr
);
172 // Comparisons between double seem to work more often when this is called
173 // on the comparison values.
174 static void fix_double(double *x
);