Deja Vu #05
31 мая 1998 |
|
Topic - DIGITAL sound like it is (a player. Wav files).
SoundTrack: SUNNY BY SECTOR / SERIOUS '97 (!) __________________________________________ (C) M.M.A aka UnBELIEVER / SPEED CO. / XTM '98 __________________________________________ SAMPLING OF CONTINUOUS TIME Harmonic oscillations or DIGITAL SOUND LIKE HE IS ------------------------ This is not a lecture, and even no practice This student drinking Beer "Baltika" ------------------------ Instead epigraph .... * Recently, at our heads had fallen a lot of games, demo, magazines and even software programs that actively used graphics converted from other platforms (AMMY / PC). None one is surprised to see on the screen 'scan' $ 100, face the author of the program or even a bare ass (if only ass!). However, occasionally audible from the speakers of your sound devaysa human speech, excerpts of famous songs or (Again) just lustful women's sighs are of interest, and sometimes even surprising. How did they sound in komputer stuck? Here's how ... First, a little theory. I will not pretend to be true in the last instance, but set out below is the case. These things you may well trained in VUZ'e, on subjects SIGNAL THEORY, digital signal processing and the like. I want to express osnovnyyu essence, moreover, a brief and accessible. Hope higher education wise comrades did not deem This simplified version of lamerstvo ... So, we have a signal. What is takoediky howling King Kong or a fiery speech Vladimir Zhirinovsky - is not important. This may even be 220 volts from razetki at specific approach. Not to be unfounded, I drew a piece of unidentified signal in the figure at number one. Axis coordinate is the time (horizontal) and amplitude (vertical). Those who do not understand explaining, if it's voice, then it changes in time and in each of the moments has some instantaneous amplitude (in other words the volume). The process of translating this sound on the "language of numbers" friendly car is to carry out two operations - sampling and quantization. √ l √ l @ √ l `√ l A √ n and √ n √ l p √ l √ l √ l @ √ l `√ l For sampling, we need to break the axis time into equal parts with a certain step. Discretization step vybiraetsya arbitrary and, as you know, what it is, the better the sound will be. Why? Because after the partition of the time axis, we begin to assume that between two adjacent strokes (Fig. 2) our signal has a constant value, that is on the schedule it should be a horizontal line. How many probably already understood, the discretization step is and is in some sense the very 4,8,16, 22.44 kHz. Now, from each point (taken from a selected step) on the time axis, we can draw a straight line, and dropping a perpendicular to the axis of the amplitudes of the points of intersection and schedule, to get some value in the signal amplitude at a given time. However, in order to know the value of the amplitude at any given time, you need this same axis amplitude mark - split with some step, as is the case with time. This process is called scientific quantization. Not need to be RST # 7, to understand the importance that the quantization step was as low as possible and therefore levels were as much as possible. Compare Figures 3 and 4. On the third of seven levels of quantization and the schedule (under schedule of the signal) consists of large steps. At the fourth level is 16 and a step (if they hold) are less closer to the original. A √ n and √ n √ l p √ l √ l √ l @ √ l `√ l A √ n and √ n √ l p √ l By the way, the distance from the step up to the actual point on the graph, ie difference between "real" value of the signal at this point, and its quantized value is called quantization noise. For the most part, all a hiss, which heard from speakers in playback time of digitization and the noise is quantization formed at the stage of getting digitization. It is logical to assume that discretization step tends to zero, and the number of quantization levels to beskoechnosti, the noise disappears completely. That is, in principle, and all teoriya.Takim, after transformations we obtain array of instantaneous values of amplitude (volume) of the signal at certain times. How can choose the parameters of sampling and quantization, so that the sound was more real and possible match the original? Is optimal discretization of the signal with a frequency of 44kHz. Where does it number? There is a theorem of Kotelnikov which is both simple and complex. So Now, it is (if a little thought) said us that to fully restore the signal needed to discretize it with a frequency two times greater than that in which the spectral density of the signal is nonzero. The human ear perceives as sound vibrations from 2Hz to 20KHz, that is in the range of 20KHz. That's it then we multiply by 2 getting somewhere 40-44KGts. Achievable if a playback speed by SPECCY? Of course not! All that we hear (DIGITAL SOUND) in numerous demos and special music editors, in general, has a frequency 4-8kHz. In rare cases, 15-16kHz (one of ringtones on E'97 MUSIC COMPO) and even 22 kHz (ZY-ZY and ACTION by VAV). As experimentation Samara programmer MONSTR'u from the SAGE GROUP able to reach such speeds sound playing when the frequency digitization can reach 30 kHz and a practical limits to the standard Z80A 3.5MGts. However, for all these achievements, people continue to distill the sound mainly with the frequency 8kHz. What's fumbled a dog? But the fact that, as described above, than the sampling frequency is another parameter - the number of quantization levels. Immensely increasing one of these parameters and without changing the other, koordinalno improvement quality, we do not get! Number of quantization levels is generally measured in bits per sample, for example, the phrase "at This card pyatibitovy sound "means that this unit can reproduce sound quantized on 32 levels (11,111 = 31% + 1). A what SPECTRUM? 1bit - Level 2 - beeper 4bit - 16 levels - AY-CHIP 7bit - 128 levels - a number COVOX'ov 8bit - 256 levels - SOUNDRIVE Thus, if the discretization step, we can choose a wide range (software), then the number of levels in our digitization of the same (hardware) and modify it can only be down (at COVOX'e listen 1bit sound). Now, I think, the most savvy realize that the sound for SOUNDRIVE'a takes 10 seconds on the clock, in memory Computer eat as much - 10 * X KHz, where X is the frequency. Of course, you want a zatsifrovat zvuchek at 22KHZ (especially since no one prevent!), but the memory is 220KB eat! And the devices themselves playing more than 4bit is not all - the standard is still coprocessor! Outlined below and converter oriented player on him. How do you get the digitized version of desired sound? For this you need device called ADC - analog to digital converter. There are a number of schemes this device for SPECCY, but in my look to get the digitization of our own computer does not make sense. You can use the big "professional" ADCs are available literally everywhere - IBM PC. All the software exists on the PC and is designed for sampling / audio processing can be made to unload the data in a format . WAV. Moreover, since . WAV is a standard format for audio wINDOWS, without problems can find a large number of already ready-made sounds in the catalogs of any "vindoznoy" program (the whole of their rookery can be found on the disk with Office'97). Finding or getting to the pc file format . Wav, make sure that this sound is the "eight-bit" and "mono". More common sounds and 16bit stereo. They, of course, can also be converted to SPECCY, but for This requires a different (than below) converter, plus such files will be very difficult to translate because of the large amount of redundant information. . WAV can be of any sampling frequency, because extra samples can recline already SPECCY, by "throwing" every second byte of data. Frequency at this reduced by half. ----------------------------------------- A small recommendation to transfer from MS-DOS in TR-DOS. This is usually done by IS-DOS, but if the file is large, it will be difficult then convert - will have to cut. Moreover, if the file will be more than 255 sectors, even the IS-DOS does not help. I recommend the program to use MSDOS-RD. This thing is though, and writing quite buggy, but it allows you to copy files any length, cutting at the same time to equal chunks of 16384 bytes. Just remember that file name and extension must be typed in capital letters strictly. ----------------------------------------- Remembering the fact that we of the "pisishnyh" 8bit need only 4bit, there is a problem to transfer data. At the same time you can be glad for the fact that in one byte after the Translation fit two readings: all bytes 1010 0101 the first count to the second count Clear the degree that, in this case, the memory fits twice as much data. This fact can not but rejoice, but for him would have to pay a decrease in performance. So how do you translate 8bit in 4bit'a? The simplest and most radical method is divide by 16. We take from each "octet" reference just over 4 bits. But there is a better way ... - "Rondo" (C) Advertisement We will devote our bit by some approximating function. Why? To get higher quality sound! The following proposed approximating curve was taken ALK'om from some one his well-known reasons. You can try to create an array and its BASIC'e see how to change the sound. The following is an image, which simultaneously shows our function (top) and the line showing the version when the state is the first 4 bit (below). √ l √ l @ √ l `√ l A √ n ap √ l with √ n The beginning and end of both plots is identical, but in the middle there is a difference. This seemingly unimportant difference plays a significant role in quality. ----------------------------------------- To obtain its approximating curve to tamp BASIC'e program that will build a continuous function of 0 255 X and a height of not more than 16 points (on axis Y). Then instead of the command PLOT POKE put and wait a bit, you get array of numbers in memory. But what do I explain "? Now the user an advanced off! Understands with two words): ----------------------------------------- So, first run the converter - procedure under the label KONVERT. Plate approximation were transferred to the screen (can be any other place, if only the address has been smooth - the low byte # 00) and the process has begun! A few seconds later, we already have in memory from the same address where you downloaded . Wav, ready-to-use digitizing. Her length exactly two times smaller than the size Source. wav'a. Now go ahead and start player by setting the right registers address of the location and length of the sound multiplied by two (the length of the original. wav'a). So he _Z_V_U_K_, JETS OF YOUR SPEAKER! Adjust the speed of playback can be produced with the help of tags TORMOZ. However, even if the minimum value TORMOZ = 1 is for you. wav'a slow, you can killing procedure itself Brakes, winning while a few kilohertz. You should worry about now is not the speed, and a suspicious-clicking in the beginning digitization. This is none other than the title. Wav'a where he kept some of its parameters. You and I accidentally moved and is now playing as the beginning sound. To get rid of this contradiction click Run protsedurku CORRECT, which copies the top audio array of numbers that are rising from # 00 to # 0A amplitude. This array is completely overwrite the converted handle. wav'a, and with it the nasty-clicking. That is, in principle, and everything you need to know to begin experimentation with digital sound. Can be selected fellows will show that I laid it all on-and lamerski naive to think of myself as a genius in the conversion of sound. Not at all! I just wanted to convey truth to most users, the most simple and accessible language. All those who are interested in this stuff, I want to give a little advice: use the "power" of the calculator for the benefit of IBM PC SPECCY and remember that in addition to digitizing the sound it is still possible and handle it (removing noise / filters / effects) in a number of editors like COOL'95, SOUND FORGE, etc. Quality will improve! Here, as with conversion charts - it is possible to blockhead, and you can sit in Photoshop! ;------------------------------------; PLAYER. WAV FILE! ; ; WRITTEN BY ALK / STARS OF KELADAN'97 ; CORRECTED BY M.M.A / SPEED CO. '97 ; LAST EDITION ON 10.04.98 ;------------------------------------; EXAMPLE PLAYER ; ; LD HL, # C000; ADDRESS THE BEGINNING OF DATA ; LD DE, # 3800 * 2 (long beeps) * 2 ; CALL PLAY ; EI ; RET ;------------------------------------ TORMOZ EQU 2; DELAY when playing , Is chosen depending ; On the frequency of digitization. DATA EQU # 8000; Address Location ; SOURCE. WAV FILE ; FOR TRANSFER SAMP EQU # 4000; ADDRESS APPROXIMATING ; TABLES FOR TRANSFER ; 8bit> 4bit LENGHT EQU # 8000; LENGTH Transferable. WAV ; FILE ; PLAYER ;-------------------------------------- PLAY1 PUSH HL; for the first call PUSH DE CALL INIAY POP DE POP HL ;-------------------------------------- PLAY DI; Subsequent calls PR2 CALL PLAYAY CALL INIAY RET PLAYAY EXX LD DE, # FFBF LD C, # FD LD L, 8 EXX LD B, 0 LPLAY LD A, (HL) MAS1 AND # F0 CT1 RRCA RRCA RRCA RRCA EX AF, AF EXX LD A, L LD B, D OUT (C), A EX AF, AF LD B, E OUT (C), A EX AF, AF INC A LD B, D OUT (C), A EX AF, AF LD B, E OUT (C), A EX AF, AF INC A LD B, D OUT (C), A EX AF, AF LD B, E OUT (C), A EXX LD A, (CT1) XOR # 0F LD (CT1), A LD (CT1 +1), A LD (CT1 +2), A LD (CT1 +3), A LD A, (MAS1 +1) CPL LD (MAS1 +1), A RLCA AND 1 LD C, A ADD HL, BC DELAYAY LD A, TORMOZ; ERASE THESE LINES LPB DEC A; FOR ACHIEVEMENT JR NZ, LPB; MAXIMUM SPEED DEC DE LD A, D OR E JR NZ, LPLAY RET INIAY LD HL, BUFAY XOR A LD DE, # FFBF LD C, # FD LIA LD B, D OUT (C), A LD B, E OUTI INC A CP 1914 JR NZ, LIA RET BUFAY DW 1,1,1 DB 0, # 3F, 0,0,0; can be put DB 0,0,0; # 38 - H and u E ; But quieter! ;--------------------------------; CONVERTER ;-------------------------------- KONVERT LD HL, SAMPTAB LD DE, # 4000 LD BC, # 0100 LDIR LD HL, DATA LD DE, DATA LD BC, LENGHT LPRE LD A, (DE) CALL PREOSA RLCA RLCA RLCA RLCA LD (HL), A INC DE LD A, (DE) CALL PREOSA OR (HL) LD (HL), A INC DE INC HL DEC BC LD A, C OR B JR NZ, LPRE RET PREOSA PUSH HL LD HL, SAMP LD L, A LD A, (HL) POP HL RET ;--------------------------------------; TABLE FOR THE TRANSLATION 8bit> 4bit ;--------------------------------------; Assemble STRICTLY WITH EXACTLY ADDRESSES ; TYPE # 5B00, # C000, 4000, ETC ; Table Size - # 100 bytes. ;-------------------------------------- SAMPTABLE DEFB # 00, # 00, # 00, # 00, # 00, # 00, # 01, # 01 DEFB # 01, # 01, # 01, # 01, # 01, # 01, # 01, # 01 DEFB # 01, # 02, # 02, # 02, # 02, # 02, # 02, # 02 DEFB # 02, # 02, # 02, # 02, # 03, # 03, # 03, # 03 DEFB # 03, # 03, # 03, # 03, # 03, # 03, # 03, # 04 DEFB # 04, # 04, # 04, # 04, # 04, # 04, # 04, # 04 DEFB # 04, # 04, # 05, # 05, # 05, # 05, # 05, # 05 DEFB # 05, # 05, # 05, # 05, # 05, # 06, # 06, # 06 DEFB # 06, # 06, # 06, # 06, # 06, # 06, # 06, # 06 DEFB # 06, # 07, # 07, # 07, # 07, # 07, # 07, # 07 DEFB # 07, # 07, # 07, # 07, # 07, # 07, # 08, # 08 DEFB # 08, # 08, # 08, # 08, # 08, # 08, # 08, # 08 DEFB # 08, # 08, # 09, # 09, # 09, # 09, # 09, # 09 DEFB # 09, # 09, # 09, # 09, # 09, # 09, # 09, # 09 DEFB # 0A, # 0A, # 0A, # 0A, # 0A, # 0A, # 0A, # 0A DEFB # 0A, # 0A, # 0A, # 0A, # 0A, # 0A, # 0B, # 0B DEFB # 0B, # 0B, # 0B, # 0B, # 0B, # 0B, # 0B, # 0B DEFB # 0B, # 0B, # 0B, # 0B, # 0B, # 0B, # 0C, # 0C DEFB # 0C, # 0C, # 0C, # 0C, # 0C, # 0C, # 0C, # 0C DEFB # 0C, # 0C, # 0C, # 0C, # 0C, # 0C, # 0C, # 0C DEFB # 0D, # 0D, # 0D, # 0D, # 0D, # 0D, # 0D, # 0D DEFB # 0D, # 0D, # 0D, # 0D, # 0D, # 0D, # 0D, # 0D DEFB # 0D, # 0D, # 0D, # 0D, # 0D, # 0D, # 0E, # 0E DEFB # 0E, # 0E, # 0E, # 0E, # 0E, # 0E, # 0E, # 0E DEFB # 0E, # 0E, # 0E, # 0E, # 0E, # 0E, # 0E, # 0E DEFB # 0E, # 0E, # 0E, # 0E, # 0E, # 0E, # 0E, # 0E DEFB # 0E, # 0E, # 0E, # 0E, # 0E, # 0F, # 0F, # 0F DEFB # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F DEFB # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F DEFB # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F DEFB # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F DEFB # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F, # 0F ;-------------------------------------; UNIT FOR SMOOTHING PRIMARY CLICK , Length - 22 bytes. (C) MY! ;------------------------------------- CORRECT LD HL, RISING LD DE, DATA LD BC, 22 LDIR RET RISING DB # 00, # 01, # 11, # 12, # 22, # 23, # 33 DB # 34, # 44, # 45, # 55, # 56, # 66, # 67 DB # 77, # 78, # 88, # 89, # 99, # 9A, # AA DB # AA
Other articles:
Similar articles:
В этот день... 21 November