Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions X16 Reference - 09 - VERA Programmer's Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -869,11 +869,13 @@ FX features are controlled mainly by registers $9F29-$9F2C with DCSEL set to 2 t
Preliminary documentation for the feature can be found in [Chapter 10](X16%20Reference%20-%2010%20-%20VERA%20FX%20Reference.md#chapter-10-vera-fx-reference), but as this is a brand new
feature, examples and documentation still need to be written.

## Programmable Sound Generator (PSG)
## Audio

The audio functionality contains of 2 independent systems. The first is the PSG or Programmable Sound Generator. The second is the PCM (or Pulse-Code Modulation) playback system.

16 entries (channels) of the following format:
### Programmable Sound Generator (PSG)

The PSG consists of 16 voices, each with their own set of registers:

<table>
<tr>
Expand Down Expand Up @@ -904,7 +906,7 @@ The audio functionality contains of 2 independent systems. The first is the PSG
<tr>
<td>3</td>
<td align="center" colspan="2">Waveform</td>
<td align="center" colspan="6">Pulse width</td>
<td align="center" colspan="6">Pulse Width / XOR</td>
</tr>
</table>

Expand All @@ -919,8 +921,9 @@ Thus the output frequency can be set in steps of about 0.373 Hz.

*Example: to output a frequency of 440Hz (note A4) the **Frequency word** should be set to 440 / (48828.125 / (2^17)) = 1181*

**Volume** controls the volume of the sound with a logarithmic curve; 0 is silent, 63 is the loudest.
The **Left** and **Right** bits control to which output channels the sound should be output.
**Volume** controls the volume of the sound with a logarithmic curve; 0 is silent, 63 ($3F)
is the loudest. The **Left** and **Right** bits control to which output channels the sound
should be output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you haven't changed this sentence but the first "output" (line 925) seems redundant.


**Waveform** controls the waveform of the sound:

Expand All @@ -931,16 +934,29 @@ The **Left** and **Right** bits control to which output channels the sound shoul
| 2 | Triangle |
| 3 | Noise |

**Pulse width** controls the duty cycle of the pulse waveform. A value of 63 will give a 50% duty cycle or square wave, 0 will give a very narrow pulse.
**Pulse Width / XOR** controls the duty cycle of the pulse waveform or the XOR
permutation when used with the triangle or saw. For pulse, a value of 63 ($3F) will
give a 50% duty cycle or square wave, 0 will give a very narrow pulse.

When the triangle or saw waveform is selected, the value influences an XOR calculation
the changes the resulting waveform. This is most noticeable with the triangle waveform.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smells like a typo, possibly intended as "an XOR calculation that changes"?

It can be used to provide an NES-like fuzzy triangle as well as an overdriven saw sound
(similar to the VRC6 NES chip) among several other varieties of sounds.

When used with the saw, the result is more substle. It adds some overtones to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

substle?

the saw.

Just like the other waveform types, the frequency of the noise waveform can be controlled using frequency. In this case a higher frequency will give brighter noise and a lower value will give darker noise.
Setting the PW/XOR to 00 for Tri/Saw inverts the waveform from what it was prior
to the addition of the XOR feature. Be careful of phasing as a result.

**Noise** Just like the other waveform types, the frequency of the noise waveform can be controlled using frequency. In this case a higher frequency will give brighter noise and a lower value will give darker noise. The PWM/XOR values do not influence
the noise shape.

## PCM audio
### PCM audio

For PCM playback, VERA contains a 4kB FIFO buffer. This buffer needs to be filled in a timely fashion by the CPU. To facilitate this an **AFLOW** (Audio FIFO low) interrupt can be generated when the FIFO is less than 1/4 filled.

### Audio registers
#### Audio registers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heading hierarchy seems a bit off. If "Audio registers" is made h4, the respective register headings should be h5, and "Audio data formats" also h4 (since they also relate to PCM).

That does feel like some very deep nesting into the hierarchy, but I think that's a symptom of most of the VERA stuff being on the one page, an issue for another day.


#### `AUDIO_CTRL ($9F3B)` ####

Expand Down