|
|
Line 1: |
Line 1: |
| [[Category:APU]]
| | #REDIRECT [[APU Mixer]] |
| The [[APU Mixer|NES APU Mixer]] can be efficiently emulated using a lookup table or a less-accurate linear approximation.
| |
| | |
| == Lookup Table ==
| |
| | |
| The APU mixer formulas can be efficiently implemented using two lookup tables: a 31-entry table for the two [[APU Pulse|pulse channels]] and a 203-entry table for the remaining channels (due to the approximation of tnd_out, the numerators are adjusted slightly to preserve the normalized output range).
| |
| | |
| <pre>
| |
| output = pulse_out + tnd_out
| |
| | |
| pulse_table [n] = 95.52 / (8128.0 / n + 100)
| |
| | |
| pulse_out = pulse_table [pulse1 + pulse2]
| |
| </pre>
| |
| | |
| The tnd_out table is approximated (within 4%) by using a base unit close to the [[APU DMC|DMC's]] DAC.
| |
| | |
| <pre>
| |
| tnd_table [n] = 163.67 / (24329.0 / n + 100)
| |
| | |
| tnd_out = tnd_table [3 * triangle + 2 * noise + dmc]
| |
| </pre>
| |
| | |
| | |
| == Linear Approximation ==
| |
| | |
| A linear approximation can also be used, which results in slightly louder DMC samples, but otherwise fairly accurate operation since the wave channels use a small portion of the transfer curve. The overall volume will be reduced due to the headroom required by the DMC approximation.
| |
| | |
| <pre>
| |
| output = pulse_out + tnd_out
| |
|
| |
| pulse_out = 0.00752 * (pulse1 + pulse2)
| |
|
| |
| tnd_out = 0.00851 * triangle + 0.00494 * noise + 0.00335 * dmc
| |
| </pre>
| |