world of sound Spectrum - Chapter 6.1: Description of the coprocessor registers of the musical AY- 3-8910 (AY-3-8912).

ZX Forum #04
              6.1. Registers


    R0 - low byte of the frequency channel A

    R1 - byte frequency channel A

    R2 - Low byte frequency channel B

    R3 - Senior byte frequency channel B

    R4 - low byte of the frequency channel C

    R5 - high byte of the frequency channel C


   The required frequency of each channel is obtained by 
dividing the clock frequency of co-processor at 16 and then 
dividing the result by a 12-bit value is obtained by merging 
the register low byte frequency and bits D0 ... D3 register 
older byte frequency. Thus, there can be

4095 set of different frequencies (from 27 Hz to
110 kHz). Naturally, the highest you do not
hear. Please note that the difference
between the two neighboring values ​​in the low frequencies is 
a fraction of a hertz, and at high frequencies up to several 
kilohertz. 

   Junior and Senior bytes, and the frequency can be calculated 
as follows: 


       Hi = INT (INT (110830/Fq + .5) / 256)

       Lo = INT (110830/Fq + .5)-Hi * 256

       Fq = 110830 / (Lo +256 * Hi)

where Hi - byte, Lo - low byte
and Fq - frequency in Hz. Note
that in most cases, given the frequency can not accurately 
convey the musical coprocessor. Table 9 shows the values ​​of 
registers tone for all possible notes. 


    R6 - sets the frequency noise


   The required frequency noise is obtained by dividing the 
clock by 256 and dividing the result by 5-bit value located in 
the five LSBs (D0. .. D4) register R6. Total You can ask 31 
different frequencies (from 223 Hz to 7 kHz). Value of the 
register R6 and the frequency noise can be calculated by the 
following formulas:



       R = INT (6927.3437/Fq + .5)

       Fq = 6927.3437 / R

where R - value of R6, and Fq - frequency in Hz.

   Everything said about the tone generator is also
true for the noise generator.


    R7 - control the mixer and the input /

         O


   The individual bits of this register are used for different 
purposes: 


     D0 - the tone of the channel A

     D1 - the tone of the channel B

     D2 - the tone of the channel C

     D3 - A noise channel

     D4 - noise channel B

     D5 - noise channel C

     D6 - Port A: 0 - I / 1 - output

     D7 - Port B: 0 - I / 1 - output

          (Only AY-3-8910)


   Zero in bits D0 ... D5 indicates
that the function is enabled. Thus, each channel can be 
adjusted to three different conditions: the tone, noise and 
tone + noise. Ports I / O, contained in the music

coprocessor, a ZX-Spectrum are not used, but these can add 
extra joysticks, printer, MIDI-interface or something like 
that. Port B exists only in the AY-3-8910. 


    R8 - control of the amplitude of channel A

    R9 - control of the amplitude channel B

    R10 - control the amplitude of the channel C


   Bits D0 ... D3 these registers set the volume for each 
channel (from 0 to 15). If one (or several) of

these bits set D4, then the value in the lower bits are 
ignored, and the amplitude of the channel controls the envelope 
generator (See below).



    R11 - low byte of the period of the envelope

    R12 - byte period of the envelope


   Required period of the envelope is obtained
by dividing the clock frequency of co-processor 256 and then 
dividing the results the one on 16-bit value obtained merge 
registers R11 and R12. Total You can set the 65,535 different 
periods. Values ​​of registers R11 and R12, as well as 
frequency and period of the envelope can be calculated as 
follows: 


     Hi = INT (INT (6927.3437/Fq + .5) / 256)

     Lo = INT (6927.3437/Fq + .5)-Hi * 256

     Fq = 6927.3437 / (Lo +256 * Hi) = 1/Pd

     Pd = (Lo +256 * Hi) / 6927.3437 = 1/Fq

where Lo and Hi - the values ​​of registers R11 and
R12, respectively, Fq - frequency in Hz envelope, and Pd - the 
period of the envelope in seconds. 


    R13 - control of the shape of the envelope


   Desired shape of the envelope is given by bits D0 ... D3 
register R13 as follows: 


     D0 - damping

     D1 - striping

     D2 - growth

     D3 - continued


   Table 10 shows all possible
combinations of these bits.


    R14 - I / O port A

    R15 - I / O port B


   As mentioned above, the ports of entry /
O do not have much importance on the generated sound is not 
affected.