|
50 | 50 | Each of the four "conceptual" channels is composed of a "generation" circuit (designated "channel" in the above diagram), and a [DAC](https://en.wikipedia.org/wiki/Digital-to-analog_converter).
|
51 | 51 | The digital value produced by the generator, which ranges between $0 and $F (0 and 15), is linearly translated by the DAC into an analog[^digital_analog] value between -1 and 1 (the unit is arbitrary).
|
52 | 52 |
|
53 |
| -The four analog channel outputs are then fed into the mixer[^vin], which selectively adds them (depending on [`NR51`](<#FF25 — NR51: Sound panning>)) into two analog outputs (Left and Right). |
| 53 | +The four analog channel outputs are then fed into the mixer[^vin], which selectively adds them (depending on [`NR51`]) into two analog outputs (Left and Right). |
54 | 54 | Thus, the analog range of those outputs is 4× that of each channel, -4 to 4.
|
55 | 55 |
|
56 | 56 | Then, both of these two get their respective volume scaled, once from [`NR50`](<#FF24 — NR50: Master volume & VIN panning>), and once from the volume knob (if the console has one).
|
@@ -103,11 +103,17 @@ Indicated values are under normal operation; the frequencies will obviously diff
|
103 | 103 | A high-pass filter (HPF) removes constant biases over time.
|
104 | 104 | The HPFs therefore remove the DC offset created by inactive channels with an enabled DAC, and off-center waveforms.
|
105 | 105 |
|
106 |
| -Enabling or disabling a DAC ([see below](#DACs)), adding or removing it using NR51, or changing the volume in NR50, will cause an audio "pop". |
| 106 | +::: tip Avoiding audio pops |
| 107 | + |
| 108 | +Enabling or disabling a DAC ([see below](#DACs)), adding or removing it using NR51, or changing the volume in NR50, will cause an audio pop. |
107 | 109 | (All of these actions cause a change in DC offset, which is smoothed out by the HPFs over time, but still creates a pop.)
|
108 | 110 |
|
| 111 | +To avoid this, a sound driver should avoid turning the DACs off; this can be done by writing $08 to `NRx2` (silences the channel but keeps the DAC on) then $80 to `NRx4` to retrigger the channel and reload `NRx2`. |
| 112 | + |
| 113 | +::: |
| 114 | + |
109 | 115 | The HPF is more aggressive on GBA than on GBC, which itself is more aggressive than on DMG.
|
110 |
| -(The more "aggressive" a HPF, the faster it pulls the signal towards "analog 0"; this reduces the pops, but tends to also distort waveforms.) |
| 116 | +(The more "aggressive" a HPF, the faster it pulls the signal towards "analog 0"; this tends to also distort waveforms.) |
111 | 117 |
|
112 | 118 | ### DACs
|
113 | 119 |
|
@@ -183,10 +189,12 @@ This does not happen under regular operation, but can be achieved by switching f
|
183 | 189 | ## Game Boy Advance audio
|
184 | 190 |
|
185 | 191 | The APU was reworked pretty heavily for the GBA, which introduces some slightly different behavior:
|
186 |
| -- Instead of mixing being done analogically, it's instead done digitally; then, sound is converted to an analog signal and an offset is added (see `SOUNDBIAS` in [GBATEK](http://problemkaputt.de/gbatek.htm#gbasoundcontrolregisters) for more details). |
| 192 | +- Instead of mixing being done by analog circuitry, it's instead done digitally; then, sound is converted to an analog signal and an offset is added (see `SOUNDBIAS` in [GBATEK](http://problemkaputt.de/gbatek.htm#gbasoundcontrolregisters) for more details). |
187 | 193 | - This also means that the GBA APU has no DACs.
|
188 | 194 | Instead, they are emulated digitally such that a disabled "DAC" behaves like an enabled DAC receiving 0 as its input.
|
189 | 195 | - Additionally, CH3's DAC has its output inverted.
|
190 | 196 | In particular, this causes the channel to emit a loud spike when disabled; therefore, it's a good idea to "disconnect" the channel using NR51 before accessing wave RAM.
|
191 | 197 |
|
192 | 198 | None of the additional features (more wave RAM, digital FIFOs, etc.) are available to CGB programs.
|
| 199 | + |
| 200 | +[`NR51`]: <#FF25 — NR51: Sound panning> |
0 commit comments