Arkos Tracker 3 has a powerful support for sound effects. They are managed in a different way than Arkos Tracker 1 and 2, to be even more simple to use.
The sound effects must be composed in a separate song, and each instrument can then be exported as a sound effect, 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 AT1. The difference with AT2 is a detail explained below.
Preparing the sound effects song
- First of all, create a new song or use the default one when launching AT3. Make sure that the only subsong of the song is dedicated to the sound effects.
- Set the right PSG parameters. Especially, makes sure the PSG frequency is the right one. To do that: Edit > Song properties > <your subsong>.
Creating the sound effects
- Create as many instruments as there are sound effects.
- Name them properly to tell the important sound effects from possible test sound effects. They will not be exported if you don’t want to.
- Use them in the song: this is needed for two reasons:
- You can hear what they sound like by simply playing your song (and show them to your fellow programmer conveniently).
- AT3 will only export instruments that are used (this is a key difference from AT2), and use the note it found first. So you can have fun with a track containing the instrument 01 (“Boom”) with the notes
C-2
,B-4
,C-5
. But sinceC-2
is written first, the exporter will use this note.
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 package). We’ll use the second 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” if AT can find at least one note in your sfx song, or marked “Unused” otherwise. However, you can remove any sfx you don’t want by unticking the “Exported?” 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, and it directly extracted from your sfx song. As explained before, the first note found is what matters.
By clicking on the note of each sound effect, it is played in the note AT has found. You can change the volume it is played at in the “play test parameter” below. Note that it is only a test parameter, it does not change how the sounds are exported.
The “output index” besides each sound effect indicates the index to use when playing the sound effect. Indeed, unused and unexported instruments may create holes in the list, but they are actually skipped, making the sound effect output indexes linear.
The “generate a 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 you are satisfied with the sounds effects, 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, AKM or Stand-alone. Finds the one you need and activate the sound effects in the assembler 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, SE for Sound Effects).
All is explained in the player source, don’t worry!
Initialization
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 shoots: let’s call the “shoot” 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 “output index” of the instrument to play. For example, to play “Enemy explodes”, 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 PSG 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 ;(0-2)
call PLY_AKG_StopSoundEffectFromChannel
If you want to stop all the channels, call this method three time using the 0, 1, 2 values.
Sound priority
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 AT3 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, AKM, AKY), no need to integrate a second one.