Arkos Tracker 2 has a powerful support for sound effects. They are managed in a different way than Arkos Tracker 1, to be even more simple to use.
The sound effects must be composed in a separate song, and each instruments can then be exported as sound effects, at the desired frequency. This allows to use the same sound effect set among multiple songs (or to be used even without music), thing that was not possible with Arkos Tracker 1.
Creating the sound effects
- Create a new song or use the default one when launching AT2. It is advised to use a song specific to the sfxs! Do not use a subsong, it would not be as handy, and sometimes less efficient.
- Make sure the only subsong of the song has the right PSG parameters. Especially, makes sure the PSG frequency is the right one. To do that: Edit > Song properties.
- Create as many instruments as there are sound effects. Don't worry if you don't use them all: you will indicate what sound effects are actually used, on export.
- Don't hesitate to make tracks using the instruments to make sure they sound right. The tracks won't be exported, so there is no loss of memory.
Exporting the sound effects
If you want to test this quickly, you can load test sfxs. You can use either songs\STarKos\Targhan - Dead On Time - Sound Effects.sks, or songs\ArkosTracker2\3Channels\SoundEffects.aks (both are in the AT2 package). We'll use the first in the example below.
To export sound effects to use them in your productions, it's easy, click on File > Export > Export sound effects (AKX). A new window opens:
The list at the top shows all the instruments of the song. They are all considered "used" by default, but you can remove those you don't want by unticking the "export?" checkbox.
You can see that a sound effect relates to an "export note": this is the note at which the sound effect will be played, so it is obviously important to set it right. To do so, simply click on "C-4" and, just like in the Test Area, use the keyboard to listen and set the note.
You can also click on the "magnifying glass" on the right of a sound: it will search for the first note in the song that use this sound, and set its note accordingly!
Please heed the "play test parameters" below: they are used to configure the sound you hear, but they will not be exported (you will be able to set these on real-time when triggering your sound effects by calling the player). If the sound you play is too low, increase the "octave" and continue testing. When the current sound effect sounds right, simply click on the "C-4" of the next sound effect, and continue the procedure.
The "generate configuration file for players" should be checked: on export, a second tiny file will be generated, indicating to the player what features your sound need. The ones you don't won't be compiled, saving both CPU and memory! More information here.
When all the sounds effects are well set, you can press "OK" to save these new parameters and exit, or "Export" to export them for the sound effect player to use.
Using the sound effects
After you have clicked on "Export", generating either a binary or an AKX source file, it is time to play them on hardware.
Technical note: the sound effect player is somewhat decoupled from the players. Ideally, I wanted to have one sound effect player for all the available players. But this has proved inefficient: each player has its specificity. So each player has its sound-player counterpart, in another source file.
The sound effect player is always linked to a player: it may be AKY, AKG, Lightweight, AKM or Stand-alone. Finds the one you need and activate the sound effects in the Z80 code, at the beginning of the source. This is usually done by simply adding a flag in your source, such as:
PLY_AKG_MANAGE_SOUND_EFFECTS = 1
The label is "AKG" here, but of course, this changes according to the player (AKY, AKM, LW for Lightweight, SE for Stand Alone).
All is explained in the player source, don't worry!
Just like the music player, the sound effect player must be initialized. It's easy:
ld hl,soundEffects call PLY_AKG_InitSoundEffects
The "soundEffect" points on the data of the exported sound effects, which is either pure binary or source file.
Initializing the sound effect player can be done at any time, as long as it is done before playing a sound effect: you can even do it before initializing the music player.
Playing a sound effect
You have your music running and your sound effect player initialized. The character of your game jumps: let's call the "jump" noise!
ld a,soundEffectNumber ;(>=1) ld c,channel ;(0-2) ld b,invertedVolume ;(0-16 (0=full volume)) call PLY_AKG_PlaySoundEffect
That's it! The "soundEffectNumber" is the number, as seen in the Export window above: it is simply the instrument to play. For example, to play "ENEMYEXP", set A to 2.
The "channel" is from 0 to 2 and defines on which channel the sound is played.
The "invertedVolume" is the volume of the sound effect, from 0 to 16. 0 is the loudest, 16 is mute. Why 16 do you ask, as the CPC only has a volume range from 0 to 15? Because hardware sounds are also faded by this volume: they are considered a 16th volume. But fading them will also make them lose their "hardware" status: they will sound differently. But you will be able to fade them, at least.
One important thing to understand is that the PLY_xxx_PlaySoundEffect method only "triggers", or "programs" the sound effect. In itself, it does not do anything more than telling the player "this sound must be played". But the sound effect will only be played, frame by frame, each time the PLY_xxx_Play method of the player is called.
Stopping a sound effect
Your sound may loop and you want to stop it, or the player has pressed "esc" and you want to mute all the channels. This is possible:
ld a,channel call PLY_AKG_StopSoundEffectFromChannel
Once again, the channel is from 0 to 2. If you want to stop all the channels, call this method three time using the 0, 1, 2 values.
If a sound is played on the channel 1, playing another sound on the same channel will take priority on the previous sound.
You may want to manage priorities on the sound effects: for example, an explosion sound can not be stopped by a bullet firing sound. It's is not managed by the player, so you have to do it by yourself.
Sound effects without music
You may want to play sound effects but don't need music in your production. There are two ways of doing it:
- Use the stand-alone sound effects player, in the AT2 kit.
- Generates an empty music and use one of the player to play it (of course, nothing will be heard). Use the related sound effect player to play your sounds. There is of course big overhead since you integrate a full music player that is not required! However, this is a convenient solution if you already have a player at hand (AKG, Lightweight, AKM), no need to integrate a second one.