SOUNDANALYZER
Very often in demos, you get to see so-called VU meters—a very neat thing if you know how to program them. Vision of TMG published a simple analyzer as a type-in listing in COMPUTER FLOHMARKT, a very simple 35-byte program, and it had a minor flaw which in turn was an advantage for others. Well, it read the values directly from the AY chip and used them to display the VU meters. This worked with all AY soundtracks, even if you only used the PLAY command and ran the analyzer in interrupts. 48K users without an AY chip were left out in the cold, but on my +2A you couldn't see anything at all either (I find this strange, maybe it's only like that on my +2A?).
However, there is definitely another way—at least with Soundtracker—to obtain the VU meter values, even without an AY chip. In the Soundtracker player that gets appended to the song by the compiler, there are three addresses representing three VU meter bars. If you know these addresses and are a reasonably decent assembly coder, it shouldn't be difficult at all to write a small machine code routine that reads these values and displays them in an eye-catching way.
Sure, compiled BASIC works too, but I wouldn't advise anyone to run something like that in interrupts; the BASIC program running alongside it would crawl at a snail's pace, depending on how complex the routine is. That's why, despite my lacking MC skills, I preferred to write the analyzer program in assembly. With my limited instruction vocabulary, that's not so easy, but I pulled it off anyway! My program is longer than Vision's and draws the bars in the opposite direction than usual—meaning from right to left instead of left to right, which is a bit unconventional!
If you want to see the effect in action, it can be seen in my latest game, Indian Patience, during control selection, and it runs in interrupts too! Now, for anyone wanting to cobble together their own analyzer, you need to know the VU meter memory cells; here they are:
Channel 1 (Values 0-15) Player+169
Channel 2 (Values 0-15) Player+170
Channel 3 (Values 0-15) Player+171
If, for example, the player is located at address 25000 in memory, the VU meter values are to be found at memory addresses 25169, 25170, and 25171. The actual address of the player depends on which address you choose when MERGEing the player.
With this, any kind of analyzer is conceivable: bars, needles like in LYRA II, or any other style—there are no limits to your imagination. An MC listing to display one channel COULD look like this:
Start: LD DE,22561 (DEstination=Attributes, top)
LD IX,(Player+169) (Read bar value into IX)
LD HL,bar (Address of the bar, which contains 16 empty
attributes, e.g. 07, and 16 bar attributes)
ADD HL,BC (HL=HL+BC)
LD BC,16 (ByteCounter=16, that many bytes to copy)
LDIR (Copy HL to DE, BC bytes)
RET (Return to program)
This is just a suggestion to show how it can be done. My program is structured a bit more elaborately, and if you like, you can also work with lookup tables in memory to create, say, a scrolling VU meter. As I mentioned before, the sky is the limit for the coder's imagination.
Aside from Indian Patience, I have also included my analyzer in the SONSTIGES (EXTRAS) section, along with a song and a description of the addresses where everything is located.
Oh yes, a suggestion for programmers: How about Bursttracker—a soundtracker that, like Wham-Music Box 48K, splits the sound channels, thus allowing up to six channels? You could split each of the three channels individually in software, couldn't you? And with that, I say goodbye until the next article.
Tiger's Claw of
Share your thoughts about the article