+
+
+void Units::init()
+{
+ DB::topower_base = new float[(MAXGAIN - INFINITYGAIN) * 10 + 1];
+ float *topower = DB::topower_base + -INFINITYGAIN * 10;
+ for(int i = INFINITYGAIN * 10; i <= MAXGAIN * 10; i++)
+ topower[i] = pow(10, (float)i / 10 / 20);
+ topower[INFINITYGAIN * 10] = 0; // infinity gain
+
+ Freq::freqtable = new int[TOTALFREQS + 1];
+// starting frequency
+ double freq1 = 27.5, freq2 = 55;
+// Some number divisable by three. This depends on the value of TOTALFREQS
+ int scale = 105;
+
+ Freq::freqtable[0] = 0;
+ for(int i = 1, j = 0; i <= TOTALFREQS; i++, j++) {
+ Freq::freqtable[i] = (int)(freq1 + (freq2 - freq1) / scale * j + 0.5);
+ if(j < scale) continue;
+ freq1 = freq2; freq2 *= 2; j = 0;
+ }
+}
+void Units::finit()
+{
+ delete [] DB::topower_base; DB::topower_base = 0;
+ delete [] Freq::freqtable; Freq::freqtable = 0;
+}
+