Inferno #06
03 декабря 2004

For Coderz - How to get the sound device more bits.

<b>For Coderz</b> - How to get the sound device more bits.
   How do I get the sound device

               more bits?



   Suppose we do not have DMA US, GS or
Such devices, which give the hardware volume. Otherwise there 
would the problem was solved too simple (one subchannel in, for 
example, left ear give a volume of 64, the other in the same ear

- With volume 1). We have a standard Spectrum with no more than 
Covox'om. 


   So, for him there were at
least three fundamentally different methods.



  1. PWM (pulse width modulation).
Signal with a frequency divided by
intervals shorter than 1 / 20000 seconds in each of which 
contains two adjacent voltage levels. Depending on the ratio of 
durations of these levels within the time intervals at the exit 
from filter produced by these or other intermediate levels of 
stress. The condition of particle quency it is necessary that 
the signal is not whistling. 

  2. PWM. The same thing, but not alternate adjacent levels, 
and 0 and level. In addition to high ripple and low volume, 
this method contains the problem of implementation - unknown

how to arrange for him a table to
 encode 16-bit real-time.

  3. Method without a title. I thought to
it is the name of the PCM (Pulse Code Modulation), but Michael 
Klinkovsky flatly refused to accept it, but without showing 
their istochnikov.Zdes the DAC is given signal level, rounded 
to the nearest snizu.Oshibka a presentation stored in the 
register and when it exceeds unit, this unit is added to the 
next in this TsAP.Iz register with the She, of course, this 
method vychitaetsya.Esli implement in hardware, then under the 
same switching frequency, it provides a higher frequency 
whistles than the PWM (which is advantage: less whistle heard.) 
disadvantage it on the ZX that cycle when programming in Z80 is 
obtained is longer than the peak rate of change data for the 
PWM. In PWM for the peak velocity in the port just spit out a 
row 2 bytes and more are waiting until they pass a standard 
time interval. If you want a level closer to the first spit 
bytes, PWM, simply divide these vyplevyvaniya pause more. AND 
so on. Need only a small block of routines, they are even 
smaller than the variations of the fractional part of the 
voltage level. 


   In the case of Beeper'a methods (1) and (2) are equivalent 
and are being implemented particularly simply for 64 variants 
of fractional level (at a frequency of 22.4kHz, close to the 
standard 22100, it provides a margin of 96 strokes = 160-64

for thinking and crawling under subprogrammes).
In this case there are only four semiconductor output with 
different mikropauzami modulo 4 and four semiconductors with 
different pause mikropauzami on modulo 4. They contain a lot 
before NOP and invoked with different addresses to adjust the 
pauses. It is only 500 bytes, including transition table. Can 
be implemented and more fractional levels, but then the number 
of sub-bounce sharply (thinking will have to make all the 
routines). Beeper a good substitute Covox and perfectly (!) 
replaces the AY on MCC method of blessed memory Monster / Sage. 
No sounds only on emulators (Unreal Speccy, ZXMAK, ZX Emul DOS, 
ZX Emul WIN, Z80 Stealth and others probably too).



   In the case of Covox the same 64-level fractional
impossible to implement. Beeper for extreme
levels were far from pure 0, and the net
1. They are difficult to use because distance
to the adjacent levels due to the finite speed Z80 would be 
greater than the distance between all other adjacent levels.

For Covox net (integer) levels yet
must be used as a bridge between
the highest possible level for the fractional previous pair 
(whole interleaved) and the lowest possible - for the next. A 
makeshift for These higher and lower differ from the nearest 
whole number of 11 processor cycles (themselves understand 
why). Consequently, between adjacent fractional levels should 
also be about 11 cycles of makeshift - for linearity. This is 
the ideal, in practice, have settle for 5 cycles and 32 levels

(Instead of 16) when the sampling rate of 22.4
kHz, ie, the length of time interval
PWM 5 * 32 = 160 cycles. It sounds a little worse
13-bit (instead of 12), t.k.dva fractional level
fall. But on hearing 13-bit and 8 bit sound
For as the heavens and the earth. Try it. We John'om
tried.


   Where in the case Covox take time out
the same thinking with the program? Done as follows:
with fractional level of <0.5 levels of spit at the port in 
order junior-senior, at> 0.5 - in order of senior-junior. Then, 
in any case remains poltsikla free time.



   For Covox on KR572PA1 method (1) does not work - the noise 
level generated more than the standard 8 bits. When I was at

the first experiment, I heard this noise, then
Think for a glitch in the program, because 8 bits PA1
You can check directly, right in
 BASIC. Here's how:
 FOR n = 0 TO 255: OUT 251, n: OUT 251,0: NEXT n

   However, Vladimir Makarov, the question of
his interpretation of the issue said: "hang up the capacitor 
between the output and the land. "Like, will help. But there 
are very good reason to assume that the Makarov is wrong. The 
point of current switches. They, unlike from the R-2R matrix 
trigger slowly. This means that the rapid alternation of bytes 
sent to the DAC 127-128-127 ... cause flipping keys in 
different phases, that at certain moments may sound, even as 0 
or 255. If it switches instantly and issued only two adjacent 
levels, then the capacitor would not be needed. Capacitor 
voltage will only lead to the middle level, and what he is? He 
would have been in Between 127 and 128 (a necessary condition 
for the method sounds better than 8 bits) only for a very 
linear characteristic of the DAC. I do not believe so accurate 
it linearity. PA1 could probably be

more effective in method (2) with alternating 0 and level, but 
this method needs a large table, it is not suitable for 
practical use. 

   Naturally, I hang capacitor vsetaki tried it, but it does 
not help. 


   Under emulators Unreal Speccy, ZX Emul
0.34 (DOS) and Z80 Stealth PWM for Covox
improves the sound. Probably in the emulators used filters, 
smoothing out Covox, however, it is possible that it does sound 
karta.Drugie emulators have not been verified. 



   Source SHIM.H - in the appendix. To him
need 16-bit sempl.Pri hold buttons
"P" and "Enter" audio device varies
with Covox'a on Beeper or Covox-13, respectively. The default 
Beeper also emulated by Covox (to make it easier to compare the 
quality of sound), it is configured Tagged beeper. Port Covox 
configured Tagged covox. Before playing a sample deteriorates 
by 2 bits (divided by 4) to better hear the difference. But it 
is also possible to disable. 

A. Coder




Other articles:

Inferno - Entered from the editor.

Interview - Interview with AIG - coder from the group MKHG.

Softinka - ACE 0.888: different from 0.666

Softinka - macro assembler debugger ALASM 4.47: difference from 4.44

For Coderz - Arithmetic coding.

Inferno - The authors of the magazine.

Softinka - BGE 4 graphical editor for ZX.

Events - The Compo 2: The results of the vote.

For Coderz - Decompiling programs - the revival of the old prog.

Inferno - Errors in the previous numbers.

For Coderz - Small programmers' tricks.

DIY - The scheme of my elektrofumigatora.

Gameland - about passed games: Imperia 2, Hexagonal Filler, From Beyond.

Iron - device extended keyboard (58 keys).

Gamedev - Gaming cycle - a cycle within which caused all the sub games.

Gameland - the passage of Lords of Time on Level 9.

For Coderz - Macros Part 2 - makes your life in programming.

Inferno - Letters to the Editor.

Gameland - passing a level playing Raven Black.

For Coderz - Description of the modular structure of programs.

Inferno - On the shell.

Softinka - the benefits of packing algorithm Optimal LZH.

Events - Serpukhov Festival ParaDiGMus party 2003. As it was.

Events - Serpukhov Festival ParaDiGMus party 2003. Afterparty.

Gameland - the passing game The Price of Magik by Level 9.

Iron - Description of a block of memory from the printer Robotron CM 6329.01 M. Part 1.

Iron - Description of a block of memory from the printer Robotron CM 6329.01 M. Part 2.

Advertising - advertising and announcements.

DIY - advice on repair hours, Dream Cast and joystick.

Interview - An Interview with Shaitan / Stars of Keladan: Interred Inferno.

Gameland - the passing game from the Level 9 Snowball.

Iron - Video GoldStar RN800AW Art vision. The history of repair.

Iron - Video GoldStar RN800AW Art vision. Tips on disassembly and repair.

Interview - an interview with musician Visual ^ Extreme (Sergei Agapov).

Gamedev - the assembly of the game Wolfenstein 2004. Part 1.

Gamedev - the assembly of the game Wolfenstein 2004. Part 2.

For Coderz - How to get the sound device more bits.


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

Similar articles:
List BBS - A list of BBS. Opened a new Creative Station.
Expertise - parsing the game HIJACK.
world of sound Spectrum - Chapter 4.2: Programming Sound Effects - Volume Control.

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