const int SAMPLE_BUF_SIZE = 0x138 * 2; // Size of buffer for sampled voice (double buffered) #endregion #region Public methods public DigitalRenderer() { for (int i = 0; i < voice.Length; i++) { voice[i] = new DRVoice(); } // Link voices together voice[0].mod_by = voice[2]; voice[1].mod_by = voice[0]; voice[2].mod_by = voice[1]; voice[0].mod_to = voice[1]; voice[1].mod_to = voice[2]; voice[2].mod_to = voice[0]; // Calculate triangle table for (int i = 0; i < 0x1000; i++) { TriTable[i] = (UInt16)((i << 4) | (i >> 8)); TriTable[0x1fff - i] = (UInt16)((i << 4) | (i >> 8)); } #if PRECOMPUTE_RESONANCE #if USE_FIXPOINT_MATHS // slow floating point doesn't matter much on startup! for (int i = 0; i < 256; i++) { resonanceLP[i] = FixPoint.FixNo((227.755 - 1.7635 * i - 0.0176385 * i * i + 0.00333484 * i * i * i - 9.05683E-6 * i * i * i * i)); resonanceHP[i] = FixPoint.FixNo((366.374 - 14.0052 * i + 0.603212 * i * i - 0.000880196 * i * i * i)); } // Pre-compute the quotient. No problem since int-part is small enough sidquot = (Int32)((((double)SID_FREQ) * 65536) / SAMPLE_FREQ); // compute lookup table for Math.Sin and Math.Cos FixPoint.InitFixSinTab(); #else for (int i = 0; i < 256; i++) { resonanceLP[i] = (227.755 - 1.7635 * i - 0.0176385 * i * i + 0.00333484 * i * i * i - 9.05683E-6 * i * i * i * i); resonanceHP[i] = (366.374 - 14.0052 * i + 0.603212 * i * i - 0.000880196 * i * i * i); } #endif #endif Reset(); // System specific initialization init_sound(); }