ZX Forum #04
19 ноября 1997

world of sound Spectrum - Chapter 3: How is the sound device (BEEP'ra and methods of sound production).

<b>world of sound Spectrum</b> - Chapter 3: How is the sound device (BEEP'ra and methods of sound production).
          3. How is the sound


   Unfortunately, the ZX-Spectrum to control the sound allotted 
only one bit. This bit D4 port 254 (# FE). But despite

this, the programmers manage to create
very beautiful melodies and effects.

   When this bit is set, the speaker (amplifier) ​​is 
energized, and its membrane is located in one position. When he 
is cleared, the dynamics of the voltage No, and the membrane is 
in a different position. Thus, if you change the state of this 
bit with a fairly high frequency, the membrane will vibrate and 
you hear a sound. 

   Use this method can even be of
BASIC:


   10 FOR A = 1 TO 300: OUT 254,23

   20 OUT 254,7: NEXT A

And as easy on the assembler, but this
case will prohibit the interruption, if
You want to get high-quality sound:
1415.
 10 DI; ban interrupt
 20 LD BC, 2560; BC = length
 30 LD A, 7; A = Border color
 40 BEGIN XOR 16; inverting bits D4
 50 OUT (254), A; output to port A 254
 60 LD D, 100; D = delay (frequency)
 70 PAUSE DEC D; D = D-1
 80 JR NZ, PAUSE; if D <> 0 then loop
 90 DEC BC; BC = BC-1
100 LD D, A; preservation A
110 LD A, B; BC =
120 OR C; 0?
130 LD A, D; A recovery
140 JR NZ, BEGIN; if BC <> 0 then loop
150 EI; permission to interrupt
160 RET; return to BASIC
2

   You've probably noticed that in these programs to the drop 
port is not 16 and 0, would be consistent set and reset bits 
D4, and 23 and 7. The fact that this port The speaker controls 
the border and even the color output on a tape recorder. 
Acquainted with its ability to close:



   Bits D0 ... D2 determine the color of the border:


  000 (0) - Black 100 (4) - Green

  001 (1) - Blue 101 (5) - blue

  010 (2) - red 110 (6) - yellow

  011 (3) - Purple 111 (7) - white


   Bit D3 control the output on tape.

   Bit D4 controls the sound. Bits D5 ... D7
not used.

   When you enter a byte from a port bit D6 controls the tape 
input. 

   I think now it is clear where it came from
numbers 23 and 7: to set and reset bits
D4 is necessary to consistently bring in
port value of 16 and 0. But it must
retain color border is 7 (white).
Consequently, the first value will be 16 +7 = 23, and the 
second - 0 +7 = 7. In fact, You can set any color border. 
Moreover, we can create new different color effects. It's 
enough when inverting the sound bits use a different color 
border. 

   You've probably noticed that in the above program in 
assembly language prohibits interruption. I think we should 
clarify this. The fact is that the ZX-Spectrum is designed so 
that every fiftieth of a second routine is called ROM, which is 
located at address 56 (# 38). And if you want a quality (not 
popping) sound, then it must be disabled, and that achieved by 
the prohibition of interrupt (command DI). When you return to 
the BASIC interrupt need to re-authorize (command EI).







Other articles:

Help - Description of the shell of an electronic book "ZX-FORUM 4.

Secrets of Successful Design - Head for the book "Design your Programs

screen effects - Running a string of R-Type.

screen effects - clearing the screen of Zynaps.

screen effects - "minimize" the screen from Comando Tracer.

screen effects - smooth "decay" of the screen Sommando Tracer.

screen effects - changed the character set for the original stylized font from the game Rockstar.

screen effects - "running out the string" out of the game Rockstar.

screen effects - "pouring" the screen of the game Rockstar.

screen effects - a complex multi-effects from the game Bubbler.

New top 40 procedures - scrolling display, a fusion of two images, inverting screen, rotate characters, replacement of attributes, fill a closed loop, the calculation of addresses in the screen, copy of the screen, etc.

Technology sprites - Part 1: Introduction.

Technology sprites - Part 2: The hunt for sprites (search and pulling).

Technology sprites - Part 3: Format of sprites.

Technology sprites - Part 4: Format of sprites with a mask.

Technology sprites - Part 5: Structure sprite blocks (both co-exist in memory sprite and mask, what data to help us quickly find the address of the sprite in memory, and much more.)

Technology sprites - Part 6: preparation of data for publication.

Technology sprites - Part 8: Printing sprites (coordinates are given in familiarity).

Technology sprites - Part 9: Printing sprites (coordinates given in pixels).

Technology sprites - Part 10: a review of programs to work with sprites and graphics.

world of sound Spectrum - Chapter 1: The Physics of Sound.

world of sound Spectrum - Chapter 2: Operator BEEP, Creating effects on BEEPe, Making Music on BEEPe.

world of sound Spectrum - Chapter 3: How is the sound device (BEEP'ra and methods of sound production).

world of sound Spectrum - Chapter 4: Programming sound in assembler.

world of sound Spectrum - Chapter 4.1: Programming sound effects - Tone, Noise, Complexes effects.

world of sound Spectrum - Chapter 4.2: Programming Sound Effects - Volume Control.

world of sound Spectrum - chapter 4.3: Sound Effects - Management timbre.

world of sound Spectrum - Chapter 4.4: Programming sound effects - music programming.

world of sound Spectrum - Chapter 4.5: Programming sound effects - Polyphonic ringtones (polyphonic).

world of sound Spectrum - chapter 4.6: Treatment of external signals - digitization.

world of sound Spectrum - Chapter 4.7: Handling of external signals - Reverberation.

world of sound Spectrum - chapter 4.8: Synthesis of speech.

world of sound Spectrum - Chapter 4.9: audio playback interrupt.

world of sound Spectrum - Chapter 5: The operator PLAY for music coprocessor AY- 3-8910 (AY-3-8912).

world of sound Spectrum - Chapter 5.1: Creating effects operator PLAY.

world of sound Spectrum - Chapter 5.2: Making Music on PLAYe.

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

world of sound Spectrum - Chapter 6.2: Programming effects and music under the musical coprocessor AY- 3-8910 (AY-3-8912).

world of sound Spectrum - Chapter 7: Software Review ZX-Spectrum to create sounds and music.

world of sound Spectrum - chapter 7.1: Editor, Sound Effects SUPER SOUND.

world of sound Spectrum - Chapter 7.2: Music Editor Wham the Music Box.

world of sound Spectrum - Annex 1, 2: Listings sound effects SUPER SOUND'a, tips assembler.


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

Similar articles:
Hall of Fame - Official information about the festival FunTop-98.
Business Card - an overview of electronic journals for the ZX Spectrum.

В этот день...   21 November