How to emulate DAC-based arcade sounds

Before I begin, it might be a good idea to clear up some terminology.  The term 'DAC' stands for Digital-to-Analog-Converter.  What this means is a device which takes a digital value (usually 6 or 8-bits) and converts it to a linear voltage.  For example, the value 0 might represent 0 volts, 0xFF might be 5 volts and 0x80 would then be 2.5 volts.  The simplest form of DAC is a resistor ladder; more accurate DACs are usually in the form of a small integrated circuit which produces a current or voltage in proportion to the input value. The output of this part is used by many arcade games to create the sound by directly generating the audio waveforms in the same manner that .WAV files can be played on the PC to generate sound.  Usually a dedicated CPU sends the DAC the appropriate values with the appropriate timing to create the game sounds.  However, unlike a .WAV file, the samples sent to the DAC are not uniformly timed.  The CPU is usually executing code to precisely time the DAC output, creating a variable amount of delay between each sample.  In order to emulate these sounds, the CPU emulator must keep an accurate clock cycle count for each instruction executed in order to know how much time has passed since the last DAC value changed.  In the following example we assume a sound sample rate of 44.1 KHz and a CPU clock rate of 1 Mhz.

The number of samples per clock tick = CPU clock / Sample rate = 1,000,000. / 44100 = 22.7
This means that for every 22.7 clock cycles of the CPU, 1 sound sample is generated for the emulated sound.
If the time between the last value written to the DAC and the current value is 135 CPU clocks, then we should generate 135/22.7 = 6 emulated sound samples.  The old value send to the DAC will then be repeated 6 times in our emulated sound buffer.

The sound output would be generated in this manner each time the sound CPU writes to the DAC.  In the case where nothing has been written to the DAC in a long time, the old value will just be repeated.  The output of this method can be made to sound a bit 'smoother' by linear interpolating a few DAC values between changes so that the change isn't so abrupt.  On the original arcade machine the DAC output may have been sent through a 4K lowpass filter and so, you may want to take 10 samples to change the DAC value so as to round off the harsh harmonics caused by the sharp waveform edges.

Back