Changes
PSG
,/* D/A converter table */
The Programmable Sound Generator (PSG) of the CPC is an AY-3-8912 chip. It is able to output three separate sound channels (named Channel A, B and C). Each channel can be used to output tones and/or white noise.
== PSG Registers ==
The PSG has 16 read/writeable data registers, and a write-only index register. Both the index and data registers are accessed through PIO Port A, depending on the current setting of the BC1 and BDIR bits in [[PIO8255|PPI]] Port C. The four possible combinations are:
0=inactive 2=write data
1=read data 3=write index
The procedure to write data to a specific register is as follows: Write the register number to [[PIO8255|PPI]] Port A, set BC1/BDIR to Write Index - and back to Inactive. Now write the data to PIO Port A, set BC1/BDIR to Write Data - and back to Inactive.
* [[How to access the PSG via PPI]]
===05h - Channel C Tone Frequency High (4bit)===
The tone (square wave) frequency in Hertz is calculated as follows:
F = 4MHz 1MHz / 64 16 / nn ;with nn in range 1..4095 (nn=0 acts as nn=1)
Possible frequencies are in range from 62500Hz (nn=1) down to approx. 15.26Hz (nn=4095).
The noise frequency in Hertz is calculated as follows:
F = 4MHz 1MHz / 64 16 / nn ;with nn in range 1..31 (nn=0 acts as nn=1)
Noise can be output on all 3 channels, but there is only one noise generator (so all channels share the same noise frequency). The noise generator consists of 17bit shift register, and a 1bit noise level (0=LOW or 1=HIGH). These are updated at the selected frequency as follows:
Envelope step frequency (tone or noise) calculated as follows:
F = 4MHz 1MHz / 64 16 / nn ;with nn in range 1..65535 (nn=0 acts as nn=1)
Depending on the envelope shape, the volume is incremented from 0 to 15, or decremented from 15 to 0. In either case it takes 16 steps to complete, the completion time for 16 steps is therefore:
T = nn*1024 256 / 4MHz 1MHz ;with nn in range 1..65535 (256us .. 16.7 seconds)
=== 0Dh - Volume Envelope Shape (4bit) ===
01XX 04h-07h /_________ (same as 0Fh)
1000 08h \\\\\\\\\\
1001 09h \_________ (volume remains quitequiet)
1010 0Ah \/\/\/\/\/
1011 0Bh \""""""""" (volume remains high)
1101 0Dh /""""""""" (volume remains high)
1110 0Eh /\/\/\/\/\
1111 0Fh /_________ (volume remains quitequiet)
When using the volume envelope generator, the volume is always increased from 00h to 0Fh (or vice versa), it is not possible to specify a starting/ending point (like from 00h to 07h).
=== 0Eh - External Dataregister Port A ===
This register receives data from the CPC keyboard (or joystick), for more information read the chapter about the [[Programming:Keyboard_scanning|CPC Keyboard Matrix]]. This register can be also used as output port by setting bit 6 of the PSG control register to 1 (that would allow to use the six data pins of the joystick connector to output data to external hardware).
=== 0Fh - External Dataregister Port B ===
== Mono and Stereo Output ==
When using the CPC's external stereo jack, channel A is output to the right, channel C is output left, and channel B is output to both left and right, in that case channel B is output through a bigger resistor to prevent that this channel appears loader louder than the others.
Otherwise (when using the built-in speaker), all three channels are mixed at the same intensity. This signal appears to be also sent to the Tape output line also, so a connected Data Recorder could be used to record CPC music also.
== Datasheet Noise Generator ==* The noise generator uses a [[Mediahttps:Ay3-891x//en.pdf|AYwikipedia.org/wiki/Linear-3feedback_shift_register Linear-891x datasheet]Feedback Shift Register]algorithm.
[[Category:Hardware]]
[[Category:Music and sound| ]]
[[Category:Video contents]][[Category:CPC Internal Components]]