Sample+PSG player

A player with the possibility of playing one channel (at the time) of sample (with pitch variation) along with a 3-channel PSG is available. It is called the AKY+SPL player, and is available for Amstrad CPC, MSX and Spectrum out-of-the-box.

However, it is experimental. It uses the AKY player, on top of which samples are played, exactly like the digidrum player. However, while the latter worked very fine, playing tuned samples requires “bytes” to be sent very regularly to the PSG, and without pause. To do the job perfectly, the AKY player should have been “stopped” very often to play these sample bytes (more powerful machines like Atari ST would do that naturally via timers). This is tricky to do, and such work has not been done on the AKY player. To be honest, I thought playing samples along with the player would be good enough. It turns out it isn’t quite true.

As a result, the samples don’t sound very good, and may sound out-of-key, depending on the nature of the samples. Check the demo song by compiling one of the tester (such as PlayerAkySampleTester_CPC.asm) and judge by yourself (the result sounds much better on the hardware). Drums will sound pretty good though!

In the future, depending on how many people ask for it, I may “micro-code” the AKY player, or create a specific player for this need.

The process

Samples can be converted using the process explained here.

Make sure that the PSG has a sample replay frequency of 8000 Hz. The 8-bit player actually plays at 16 kHz, but its sample table frequency is shifted accordingly.

Playing samples is a 3-step process, provided that you have a song with samples:

  • Export the music to AKY (only the PSG data will be exported).
  • Export the sample music itself, exported via the Raw Linear Export.
  • Export the samples, via the Sample Export.

Do not worry, each of these steps are simple exports from AT, with just simple checks, and are explained below. You can also make the export via the command-line tools, automatising the process once and for all (more on this below).

Export via the software

Please check out the demo song available in the songs/ArkosTracker3/samples music folder called “Lo Pan’s Attack” to have a better grip on how samples are used. For this player, and contrary to the digidrum player, samples are written directly in the music sheet, which is more natural and convenient than using the Event track.

As you can see, the instrument 3 (Marimba) is a sample: it is directly used in the middle channel as any regular instrument.

Following the three steps mentioned above:

Export to AKY

This is simple and there is nothing to configure, except export as source without encoding an address. Also tick the “generate a configuration file”, though this is optional.

The AKY export will not export any sample data. So only the PSG data is exported. When a sample is played, the PSG sounds are stopped, which is exactly what is wanted.

Export to Raw Linear

Use the “Export to Raw Linear” option, with these values:

The “export only sample notes” is important because only the notes related to samples must be exported (the sample music sheet, if you will). Also, do not tick the “encode to address”.

Export samples

Finally, export the samples:

Besides the usual “export as” at the bottom, the top section is important. You must follow the values stated in this screenshot:

  • Ignored unused samples: ticked, to remove the useless data (why waste memory?).
  • Generate index table: so that the player knows all the sample addresses.
  • Amplitude: 16, because the samples are on all 4 bits (0-15), maximizing their quality.
  • Offset: 128, the player relies on an optimization when addressing the PSG. By setting the bit 7 to 1, we save a few cycles.
  • Padding length: as explained in the source, extra-bytes must be added, because the player does not stop the sound accurately (checking it would be too slow), so we add a padding at the end to make sure that no “crappy” values are sent to the PSG. The value depends on how fast the player reads the bytes. 400 is OK for the sample player.
  • Fade-out length: 20, to prevent “clicks” at the end of sample.
  • Padding/fade to min value: ticked, so that the “zero” is the same zero as the PSG, once again to prevent clicks and various volume problems.
  • Export only used length: ticked, as an optimization.

Listening to the result

You should have 4 files (or 3 if you didn’t export the “player configuration” in the AKY export). Feed them to the AKY+PSG tester, replacing the currently used files:

Compile it with Rasm, and enjoy the result!

Export via command-line tools

More streamlined than clicking on various buttons in AT3, the CLI tools are powerful and allow you to create a build chain, reusable at will. They are also powerful if you need to make many tests and want to generate the output music quickly. They are in the “tools” folder.

For explanations about the parameters, check the sections above.

Export to AKY

SongToAky --exportPlayerConfig <input song> <output AKY file>

Export to Raw Linear

SongToRawLinear --exportType samplesOnly <input song> <output Raw Linear file>

Export samples

SongToSamples -sma 16 -smo 128 -smfo 20 -smpl 400 -smmin -smonly <input song> <output samples file>

Listening to the result

Please refer to the section above :).