Home » Archimedes archive » Acorn User » AU 1998-02 A.adf » PDScheme » ArtToSpr/WavePlayer/Help/TextHelp/4a-HowWork
ArtToSpr/WavePlayer/Help/TextHelp/4a-HowWork
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn User » AU 1998-02 A.adf » PDScheme |
Filename: | ArtToSpr/WavePlayer/Help/TextHelp/4a-HowWork |
Read OK: | ✔ |
File size: | 07B6 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
+---------------------------------------------------------------------------+ | WAVE PLAYER | | � 1997, Matthew Wilson | +---------------------------------------------------------------------------+ | HOW IT WORKS | +---------------------------------------------------------------------------+ This explanation requires the knowledge of the general sound system. For a brief description, see 'Sound System'. Wave Player operates using its own double-buffer system as well as the DAC's double-buffer system. However, whereas the DAC's buffer is only a matter of 200 or so bytes long, Wave Player's can be of the size of tens of kilobytes (10,000 bytes). This is because Wave Player has to fetch the data off of a disc. Even on a very fast harddisc, the time required to fetch a few kilobytes is quite significant. What makes this worse is the peculiar nature of discs that means that the time to load 200 bytes is the same as the time to load 1000 bytes !! And so, Wave Player fetches about two seconds� worth of data, and begins playing. When it has crossed the half-way mark, it loads a second�s worth of data over the part that has been played. When it has passed the two-second mark, it begins playing at the start of the buffer, which now contains the correct data; whilst this occurs, it loads the next part into the second half of the buffer. This is the same idea as above. That is why twice as much is taken than is given for the size of the buffer. But (there's always a but!!), a few bytes are taken before the buffer. Therefore, the slot size taken is one page (always 4Kb on RPC & A7000, 8Kb for older 1Mb machines, 16Kb for 2Mb machines or 32Kb for 4Mb machines) more than you may think it to be. To avoid this, set the buffer to be something like 31Kb, 63Kb or 127Kb etc...
00000000 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |+---------------| 00000010 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000040 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0a 7c 20 |------------+.| | 00000050 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 57 | W| 00000070 41 56 45 20 50 4c 41 59 45 52 20 20 20 20 20 20 |AVE PLAYER | 00000080 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000090 20 20 20 20 20 20 20 20 20 20 7c 0a 7c 20 20 20 | |.| | 000000a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000000b0 20 20 20 20 20 20 20 a9 20 31 39 39 37 2c 20 4d | . 1997, M| 000000c0 61 74 74 68 65 77 20 57 69 6c 73 6f 6e 20 20 20 |atthew Wilson | 000000d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000000e0 20 20 20 20 20 20 20 20 7c 0a 2b 2d 2d 2d 2d 2d | |.+-----| 000000f0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000130 2d 2d 2d 2d 2d 2d 2b 0a 7c 20 20 20 20 20 20 20 |------+.| | 00000140 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000150 20 20 20 20 20 20 20 20 48 4f 57 20 49 54 20 57 | HOW IT W| 00000160 4f 52 4b 53 20 20 20 20 20 20 20 20 20 20 20 20 |ORKS | 00000170 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000180 20 20 20 20 7c 0a 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d | |.+---------| 00000190 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000001d0 2d 2d 2b 0a 0a 20 20 54 68 69 73 20 65 78 70 6c |--+.. This expl| 000001e0 61 6e 61 74 69 6f 6e 20 72 65 71 75 69 72 65 73 |anation requires| 000001f0 20 74 68 65 20 6b 6e 6f 77 6c 65 64 67 65 20 6f | the knowledge o| 00000200 66 20 74 68 65 20 67 65 6e 65 72 61 6c 20 73 6f |f the general so| 00000210 75 6e 64 20 73 79 73 74 65 6d 2e 20 46 6f 72 20 |und system. For | 00000220 61 0a 62 72 69 65 66 20 64 65 73 63 72 69 70 74 |a.brief descript| 00000230 69 6f 6e 2c 20 73 65 65 20 27 53 6f 75 6e 64 20 |ion, see 'Sound | 00000240 53 79 73 74 65 6d 27 2e 0a 0a 20 20 57 61 76 65 |System'... Wave| 00000250 20 50 6c 61 79 65 72 20 6f 70 65 72 61 74 65 73 | Player operates| 00000260 20 75 73 69 6e 67 20 69 74 73 20 6f 77 6e 20 64 | using its own d| 00000270 6f 75 62 6c 65 2d 62 75 66 66 65 72 20 73 79 73 |ouble-buffer sys| 00000280 74 65 6d 20 61 73 20 77 65 6c 6c 20 61 73 20 74 |tem as well as t| 00000290 68 65 0a 44 41 43 27 73 20 64 6f 75 62 6c 65 2d |he.DAC's double-| 000002a0 62 75 66 66 65 72 20 73 79 73 74 65 6d 2e 20 48 |buffer system. H| 000002b0 6f 77 65 76 65 72 2c 20 77 68 65 72 65 61 73 20 |owever, whereas | 000002c0 74 68 65 20 44 41 43 27 73 20 62 75 66 66 65 72 |the DAC's buffer| 000002d0 20 69 73 20 6f 6e 6c 79 20 61 0a 6d 61 74 74 65 | is only a.matte| 000002e0 72 20 6f 66 20 32 30 30 20 6f 72 20 73 6f 20 62 |r of 200 or so b| 000002f0 79 74 65 73 20 6c 6f 6e 67 2c 20 57 61 76 65 20 |ytes long, Wave | 00000300 50 6c 61 79 65 72 27 73 20 63 61 6e 20 62 65 20 |Player's can be | 00000310 6f 66 20 74 68 65 20 73 69 7a 65 20 6f 66 20 74 |of the size of t| 00000320 65 6e 73 20 6f 66 0a 6b 69 6c 6f 62 79 74 65 73 |ens of.kilobytes| 00000330 20 28 31 30 2c 30 30 30 20 62 79 74 65 73 29 2e | (10,000 bytes).| 00000340 20 54 68 69 73 20 69 73 20 62 65 63 61 75 73 65 | This is because| 00000350 20 57 61 76 65 20 50 6c 61 79 65 72 20 68 61 73 | Wave Player has| 00000360 20 74 6f 20 66 65 74 63 68 20 74 68 65 20 64 61 | to fetch the da| 00000370 74 61 0a 6f 66 66 20 6f 66 20 61 20 64 69 73 63 |ta.off of a disc| 00000380 2e 20 45 76 65 6e 20 6f 6e 20 61 20 76 65 72 79 |. Even on a very| 00000390 20 66 61 73 74 20 68 61 72 64 64 69 73 63 2c 20 | fast harddisc, | 000003a0 74 68 65 20 74 69 6d 65 20 72 65 71 75 69 72 65 |the time require| 000003b0 64 20 74 6f 20 66 65 74 63 68 20 61 20 66 65 77 |d to fetch a few| 000003c0 0a 6b 69 6c 6f 62 79 74 65 73 20 69 73 20 71 75 |.kilobytes is qu| 000003d0 69 74 65 20 73 69 67 6e 69 66 69 63 61 6e 74 2e |ite significant.| 000003e0 20 57 68 61 74 20 6d 61 6b 65 73 20 74 68 69 73 | What makes this| 000003f0 20 77 6f 72 73 65 20 69 73 20 74 68 65 20 70 65 | worse is the pe| 00000400 63 75 6c 69 61 72 20 6e 61 74 75 72 65 0a 6f 66 |culiar nature.of| 00000410 20 64 69 73 63 73 20 74 68 61 74 20 6d 65 61 6e | discs that mean| 00000420 73 20 74 68 61 74 20 74 68 65 20 74 69 6d 65 20 |s that the time | 00000430 74 6f 20 6c 6f 61 64 20 32 30 30 20 62 79 74 65 |to load 200 byte| 00000440 73 20 69 73 20 74 68 65 20 73 61 6d 65 20 61 73 |s is the same as| 00000450 20 74 68 65 20 74 69 6d 65 0a 74 6f 20 6c 6f 61 | the time.to loa| 00000460 64 20 31 30 30 30 20 62 79 74 65 73 20 21 21 0a |d 1000 bytes !!.| 00000470 0a 20 20 41 6e 64 20 73 6f 2c 20 57 61 76 65 20 |. And so, Wave | 00000480 50 6c 61 79 65 72 20 66 65 74 63 68 65 73 20 61 |Player fetches a| 00000490 62 6f 75 74 20 74 77 6f 20 73 65 63 6f 6e 64 73 |bout two seconds| 000004a0 91 20 77 6f 72 74 68 20 6f 66 20 64 61 74 61 2c |. worth of data,| 000004b0 20 61 6e 64 20 62 65 67 69 6e 73 0a 70 6c 61 79 | and begins.play| 000004c0 69 6e 67 2e 20 57 68 65 6e 20 69 74 20 68 61 73 |ing. When it has| 000004d0 20 63 72 6f 73 73 65 64 20 74 68 65 20 68 61 6c | crossed the hal| 000004e0 66 2d 77 61 79 20 6d 61 72 6b 2c 20 69 74 20 6c |f-way mark, it l| 000004f0 6f 61 64 73 20 61 20 73 65 63 6f 6e 64 91 73 20 |oads a second.s | 00000500 77 6f 72 74 68 20 6f 66 0a 64 61 74 61 20 6f 76 |worth of.data ov| 00000510 65 72 20 74 68 65 20 70 61 72 74 20 74 68 61 74 |er the part that| 00000520 20 68 61 73 20 62 65 65 6e 20 70 6c 61 79 65 64 | has been played| 00000530 2e 20 57 68 65 6e 20 69 74 20 68 61 73 20 70 61 |. When it has pa| 00000540 73 73 65 64 20 74 68 65 20 74 77 6f 2d 73 65 63 |ssed the two-sec| 00000550 6f 6e 64 0a 6d 61 72 6b 2c 20 69 74 20 62 65 67 |ond.mark, it beg| 00000560 69 6e 73 20 70 6c 61 79 69 6e 67 20 61 74 20 74 |ins playing at t| 00000570 68 65 20 73 74 61 72 74 20 6f 66 20 74 68 65 20 |he start of the | 00000580 62 75 66 66 65 72 2c 20 77 68 69 63 68 20 6e 6f |buffer, which no| 00000590 77 20 63 6f 6e 74 61 69 6e 73 20 74 68 65 0a 63 |w contains the.c| 000005a0 6f 72 72 65 63 74 20 64 61 74 61 3b 20 77 68 69 |orrect data; whi| 000005b0 6c 73 74 20 74 68 69 73 20 6f 63 63 75 72 73 2c |lst this occurs,| 000005c0 20 69 74 20 6c 6f 61 64 73 20 74 68 65 20 6e 65 | it loads the ne| 000005d0 78 74 20 70 61 72 74 20 69 6e 74 6f 20 74 68 65 |xt part into the| 000005e0 20 73 65 63 6f 6e 64 20 68 61 6c 66 0a 6f 66 20 | second half.of | 000005f0 74 68 65 20 62 75 66 66 65 72 2e 20 54 68 69 73 |the buffer. This| 00000600 20 69 73 20 74 68 65 20 73 61 6d 65 20 69 64 65 | is the same ide| 00000610 61 20 61 73 20 61 62 6f 76 65 2e 0a 0a 20 20 54 |a as above... T| 00000620 68 61 74 20 69 73 20 77 68 79 20 74 77 69 63 65 |hat is why twice| 00000630 20 61 73 20 6d 75 63 68 20 69 73 20 74 61 6b 65 | as much is take| 00000640 6e 20 74 68 61 6e 20 69 73 20 67 69 76 65 6e 20 |n than is given | 00000650 66 6f 72 20 74 68 65 20 73 69 7a 65 20 6f 66 20 |for the size of | 00000660 74 68 65 0a 62 75 66 66 65 72 2e 20 42 75 74 20 |the.buffer. But | 00000670 28 74 68 65 72 65 27 73 20 61 6c 77 61 79 73 20 |(there's always | 00000680 61 20 62 75 74 21 21 29 2c 20 61 20 66 65 77 20 |a but!!), a few | 00000690 62 79 74 65 73 20 61 72 65 20 74 61 6b 65 6e 20 |bytes are taken | 000006a0 62 65 66 6f 72 65 20 74 68 65 0a 62 75 66 66 65 |before the.buffe| 000006b0 72 2e 20 54 68 65 72 65 66 6f 72 65 2c 20 74 68 |r. Therefore, th| 000006c0 65 20 73 6c 6f 74 20 73 69 7a 65 20 74 61 6b 65 |e slot size take| 000006d0 6e 20 69 73 20 6f 6e 65 20 70 61 67 65 20 28 61 |n is one page (a| 000006e0 6c 77 61 79 73 20 34 4b 62 20 6f 6e 20 52 50 43 |lways 4Kb on RPC| 000006f0 20 26 0a 41 37 30 30 30 2c 20 38 4b 62 20 66 6f | &.A7000, 8Kb fo| 00000700 72 20 6f 6c 64 65 72 20 31 4d 62 20 6d 61 63 68 |r older 1Mb mach| 00000710 69 6e 65 73 2c 20 31 36 4b 62 20 66 6f 72 20 32 |ines, 16Kb for 2| 00000720 4d 62 20 6d 61 63 68 69 6e 65 73 20 6f 72 20 33 |Mb machines or 3| 00000730 32 4b 62 20 66 6f 72 20 34 4d 62 0a 6d 61 63 68 |2Kb for 4Mb.mach| 00000740 69 6e 65 73 29 20 6d 6f 72 65 20 74 68 61 6e 20 |ines) more than | 00000750 79 6f 75 20 6d 61 79 20 74 68 69 6e 6b 20 69 74 |you may think it| 00000760 20 74 6f 20 62 65 2e 20 54 6f 20 61 76 6f 69 64 | to be. To avoid| 00000770 20 74 68 69 73 2c 20 73 65 74 20 74 68 65 20 62 | this, set the b| 00000780 75 66 66 65 72 20 74 6f 0a 62 65 20 73 6f 6d 65 |uffer to.be some| 00000790 74 68 69 6e 67 20 6c 69 6b 65 20 33 31 4b 62 2c |thing like 31Kb,| 000007a0 20 36 33 4b 62 20 6f 72 20 31 32 37 4b 62 20 65 | 63Kb or 127Kb e| 000007b0 74 63 2e 2e 2e 0a |tc....| 000007b6