The AKY player

The AKY player is some kind of YM-like format, but more clever :). Basically, the YM format (invented by Leonard/Oxygen) is a stream of the values sent to the PSG, frame by frame. Obviously, it takes quite a lot of space (about 45 kb per minute of music). The biggest advantage of such format is that, once decoded, playing a frame is trivial and fast.

A LZH compression is then added to reduce the size to a few kilobytes. Sadly, decoding it in real-time takes too much resources for most 8-bit computers.

Various formats exist to try to find a good compromise between memory and speed (AYC by Madram on CPC, MYM on MSX), with the raw YM stream as an input. Well, AKY is most of the times, much better than them :).

Basically, AKY relies on the structure of the song to determine when tracks and notes start and end, and try to code sub-sequences into bigger sequences, optimizing what is needed to be encoded.

Pros:

  • Short and very fast player.
  • Contrary to the aforementioned YM alternatives, AKY does NOT relies on any buffer! Only the song and the player have to be accounted for.

Cons:

  • Bigger song than with "generic" player (i.e. players that don't rely on a stream).

Inaccuracy?

A small technical explanation: in the AKY format, the AY register blocks are stored in an optimized way, most of the time only differences are encoded. The problem is that, in some cases, some shared values between channels (such as noise/hardware envelope/period) can be considered "the same" whereas they are not (one channel modifies the value, but the second channels considered it "equal, not changed"). As a result, the player might use the first value and not the second, which it should. Most of the times, only a few frames are different so you will probably not hear the difference.

So to sum up, the problems will arise only if you change the noise in two or three channels at the same time, in close vicinity (or you use 2 or 3 hardware sounds at the same time).

Such corner cases are not corrected, because neglecting them allows for even more speed.

How to make an optimized AKY

If you are working on a demo and you know you need a fast player, please read (or have your musician read) the following to have an efficiently built AKY song.

  • Tracks that sound the same are optimized away. I emphasize on "sound". Tracks may be the same in your song, but may sound differently (for example, an effect can affect the second iteration of the track (a change of volume, an arpeggio, etc.)). Make sure your tracks are as "unique" as they pretend to be: reset all the effects at the beginning of each track.
  • Avoid long and not repeated sequences, such as long slide. Each frame being different, they have to been fully encoded and the odds they can be reused is thin. Vibratos are fine.