SDL Mixer in CRYENGINE
CRYENGINE includes a simple audio implementation system using SDL Mixer.
This implementation method is intended for simple projects that do not need the power of more professional solutions and as a base from where development teams can create their own in-house audio solutions.
This implementation method currently supports playing and stopping of Ogg Vorbis and WAVE files when ATL Triggers are executed.
Setting up Your Project
- Enable the SDL Mixer middleware in CRYENGINE by settting the "s_AudioSystemImplementationName" CVar to "CryAudioImplSDLMixer" before booting up your game or the Sandbox Editor. You can do this by adding the following line to your system.cfg or user.cfg file (located in the root folder of the ENGINE).
s_AudioSystemImplementationName = CryAudioImplSDLMixer
- Copy all your Ogg Vorbis or WAVE files to \<Your Game>\Sounds\sdlmixer
The SDL Mixer can only play 16 bit, 48 kHz sample rate, stereo or mono files in either *.wav or *.ogg formats!
Once you have setup your project (see above) you should be able to see all of your audio files when you open the Audio Controls Editor.
The AudioControlsEditor can be accessed via the Main Menu "View -> Open View Pane -> Audio Controls Editor" or through the "Music Note" icon on the Menu Bar (shown in the Screenshot below).
Selecting an ATL-Trigger in your project will allow you to connect the audio files that you want to play or stop when that trigger is executed. Simply drag and drop your audio file to the Connected Controls field in the Inspector Panel. Alternatively, you can drag the audio files directly over into the ATL Control panel and one ATL-Trigger will be created per audio file.
Once you have made the connection between an ATL-Trigger and your audio file (s) you can select the audio file in the Connected Controls pane to display its properties.
|Action||With this option you can choose to either Start or Stop playback of the audio file in the object where the trigger is executed. Other objects where the same sound is playing will not be affected by the Stop action.|
|Enable Panning||When enabled allows the audio to pan depending on the position of the object, where the trigger is executed and the listener's position.|
|Enable Distance Attenuation||Linearly attenuates the sound given the distance between the audio object and the listener's position.|
|Min Distance||Distance from the listener when the sound starts being attenuated if Enable Distance Attenuation is enabled.|
|Max Distance||Distance from the listener when the sound stops being audible if Enable Distance Attenuation is enabled.|
|Looping||Sets how many times to loop the sound. If Infinite is set the sound will loop until it is explicitly stopped (using the Stop action in another trigger) or when the object is destroyed.|
|Volume||The volume at which the sound is played.|
Placing an ATL-Trigger in the Game
If you have followed the above steps you can now select your ATL-Trigger in the Editor and play it back on an Audio Entity.
You can pre-listen to your ATL-Triggers in the Audio Controls Editor by either right-clicking on it and selecting "Execute Trigger" or hitting the space bar.
In order to hear your sound in the game, we are going to place an Audio Entity in the Level which will be executing the ATL-Trigger during Gameplay.
For each Level it is recommended to first create a dedicated Audio-Layer which will contain all your Audio Data.
For this, click on the Layer icon on the RollupBar, create a new Layer and name it Audio.
As long as the Audio Layer is selected all the Entities you are placing in the Level are going to be included in the layer.
Now go back to the Objects tab (RollupBar), select the Audio tab and then the AudioTriggerSpot Entity - place the Entity in the Level.
As a rule of thumb it is always useful to name your Audio Entities using abbreviations - this improves readability particularly when working on large projects. For example at Crytek we use ATS as the abbreviation for the AudioTriggerSpot, hence the sound of a small fire could/would be named ATS_small_fire on the AudioTriggerSpot.
Here are some audio specific abbreviations used at Crytek.
- AAA (AudioAreaAmbience)
- AAE (AudioAreaEntity)
- AAR (AudioAreaRandom)
- ATS (AudioTriggerSpot)
- ACE (AudioControlsEditor)
- ASh (AreaShape)
- AB (AreaBox)
- ASp (AreaSphere)
- FG (FlowGraph)
If you have followed the above steps correctly you can now select your created ATL trigger in the Properties of the AudioTriggerSpot.
It will be played back as soon as the AudioTriggerSpot Entity is enabled.
Congratulations, you now have imported and played back your first Audio Asset in CRYENGINE with the SDL-Mixer.
For further learning take a look at the functionality of the AudioTriggerSpot in combination with the SDL-Mixer here.