Think #30
09 августа 1999

Programmers - On AY'ke.

<b>Programmers</b> - On AY'ke.
         Programmers on the AY-shke



TECHNICAL INFORMATION ON PROGRAMMING
MUSIC Coprocessor "AY" ON SPECCY!
==========================================


Music coprocessor connects to
Spectrum via two internal ports:

1. Port 49149 (# BFFD)
2. Port 65533 (# FFFD)


  It is through these two ports CPU Z80
communicates with muz.sopr. Y
muz.sopr. has sixteen internal
registers R0 ... R15.Eti registers bidirectional, ie, 
information they record and schityvat.Dlya access to an 
arbitrary register his neuzhno make current, for this we must 
write the number of Register (0 .. 15) in port 65533 ... after

You can then exchange data with
this register:

To write to the reg. - Output to port 49149

To read from reg. - Reading from port 65533

Muz.sopr. has three independent channels for
formation of sound (A, B and C) and two
bi-directional eight-channel
I / O - IRA and the IRB:

IRA through a channel for communication with
printer, the output signals for a special
MIDI interface and, in addition, communication with
special remote keyboard function keys used in the extended
BASIC interpreter.
But these functions performs a channel IRA
natural Sinclaire, but we in Russia
our models are not stuck ... (By
At least I found none nebylo
machine, where would be so used channel
IRA) ...

In our time channels IRA and IRB by some
ispolzuyutsya for external
Device: AY-Mouse, AY-Covox etc. Some of them even became a 
standard, though not very extended ones (Ay-Mouse).


Now consider what all the registers and how to create a sound:

*** R0/R1, R2/R3, R4/R5 ***

Three paired Register R0/R1; R2/R3; R4/R5
used to select the frequency of tone
respectively for channels A, B and C.
Necessary dvenadtsatirazryadnye values
obrazuyutsya youngest of eight bits of the register number and 
the four LSBs of the register number of senior ... 

*** Register R6 ***

Younger five categories of this register sets the frequency 
noise ... 

*** Register R7 ***

Through this registry manages audio and sound channels, as well 
as I / O IRA and IRB: 

Bits 0 .. 2


  if you install them, then you will be banned
  water frequency tones in the channels A, B and C resp.

Bits 3 .. 5


  - / - But for the frequency noise ...

Bits 6 and 7


  Their condition determines the mode ka
  nals IRA and IRB, respectively:


  if bit = 1, the channel operates on the input ...

  If bit = 0, the channel operates on the output ..

*** Registers R8, R9 and R10 ***

Younger five categories of these registers control the 
amplitude channels A, B and C.


*** Registers R11/R12 ***

Paired registers R11/R12 form
hexadecimal value of the envelope
output, R11-under. R12-over.

*** Register R13 ***

Junior 4 bits of this register control the
form and mode ogibayuscheyvyhodnogo signal:

Bit 0 - decay
Bit 1 - striping
Bit 2 - growth
Bit 3 - continued

*** Registers R14/R15 ***

R14-Contact with the IRA R15-communication with IRB ...

-----------------------------------------
Now specifically about playing Digital
effects:
Digitized audio consists of a
finite set of eight-byte, characterizing the amplitude 
tsifruemyh fluctuations in discrete time ...

To play otsifrovok must be submitted to the ports of the volume 
control of these bytes at a certain frequency ...

Two common types of formats, Digital
sound

1.Wav-Files: Digitization produced by

  256-point scale (0 .. 255), only half
  positive part of the sound wave ...

2.Aif-Files: Digitization produced by

  two 128-point scale:


  The positive part of the wave (0 ... 128)

  The negative part of the wave (-128 ... 0)

Consider how to play digitized.
Sound: If you have COVOX, then the values
bytes from the WAV-file entirely
served in the data port COVOX `Yes. To play the AIF-file to 
each byte before feed it to COVOX must add the number of

128 ...

This is due to the fact that it COVOX-
a device for playing eight-bit WAV-files ... and AIF must be 
converted to properly play COVOX'om ...



And now the program:



         ORG 30000
COVOX EQU # FB
START EQU 35000
LENGTH EQU 5000
PAUSA EQU 20

         XOR A

         OUT (COVOX), A

         LD HL, START

         LD DE, LENGTH
LOOP LD A, (HL)
*** ADD A, 128

         OUT (COVOX), A

         LD B, PAUSA

         DJNZ $

         INC HL

         DEC DE

         LD A, D

         OR E

         JR NZ, LOOP

         RET


If you do not have COVOX'a, but there are AY, then
You can play DIGITAL sound on it
although the quality will be worse:


         ORG 30000
START EQU 35000
LENGTH EQU 5000
PAUSA EQU 20
CHANEL EQU 10

         LD BC, # FFFD

         LD A, # 07

         OUT (C), A

         LD B, # BF

         LD A, # FF

         OUT (C), A

         LD HL, START

         LD DE, LENGTH

         LD BC, # FF

         LD A, CHANEL

         OUT (C), A
LOOP LD B, # BF

         LD A, (HL)
*** ADD A, 128

         SRL A

         SRL A

         SRL A

         OUT (C), A

         LD B, PAUSA

         DJNZ $

         INC HL

         DEC DE

         LD A, D

         OR E

         JR NZ, LOOP

         RET



The variables used in the program have
the following values:

START-address stored in the memory of digitization.

LENGTH - length of sampling.

COVOX - COVOX'a port (usually # FB for
PENTAGONA 128, and 231 for SCORPIONA 256) ...

CHANEL-channel playback (see above)

PAUSA-most important parametr.On determines
with what frequency will be played digitization. Generally 
speaking PAUSA sets the time interval between two adjacent pin 
in audio channel ...



In both cases, marked with an asterisk lines that must be 
retained, if reproduced AIF-files, and should be removed

to play the WAV-files ...

That's basically all there is to know that
reproduce digitization ...

But this method of reproduction is
frequency time dependent, ie when the frequency is changed 
accordingly, and playing an instrument ... 







Other articles:

From the Author - Hope that the newspaper will soon be a dial-up ...

News - is nearing the end of the work to create CD-ROM.

Prohodilka - Homer Simpson in Russia.

Overview of new products - Pussy, TR-Dos/MS-Dos converter.

Programmers - On AY'ke.

Nonfictional stories - Humorous stories.

tales - Humor.

Jokes - Humor.

Assembler - LED - color squares.

Passwords - Passwords to the game "Net Walk".

Form - Questionnaire for the readers.

Congratulations ... - Happy Birthday Think!!!

Birthday List v0.0 - A list of birthdays.

WANTED - Searching software ...

Advertising - Advertisements and announcements ...


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Novella - Computer novel "The Neverending Story" Part 2

В этот день...   2 May