Location: Main > View News

Dynamic Audio System

Drag[en]ginePosted Mon 25th Jan 2016 at 19:24:23 by Dragonlord Authorized by Dragonlord

This time around the Audio System received some overdue additions in preparation for what is to come.

Audio systems in games are notoriously static in nature. A buzz word is "sound shaders" but this is more parametrize play parameters than really dynamic sound. For this game project I need a sound system which supports dynamic sound and this is what I've cooked up in the last month.


At the core of the dynamic sound systems sit the Synthesizers. The link points to the wiki page which contains in-detail information I'm going to leave out here. In a nut-shell synthesizers allow to generate sound at run-time using sound production rules (or sources). Synthesizers are assigned to speakers and played back like regular sound files just that they are dynamic not static. Controllers can be defined to manipulate the generated sound at run-time, and live while playing back! The important feature here is that the synthesizers are generic in nature like the rest of the game engine. All of their actual use cases are implemented inside game scripts using/driving synthesizers instead of being hard-coded into the game engine. This provides much more flexibility to me and do you if you work later on with this game engine. For this the new synthesizer editor has been added so synthesizers can be easily created and tested.


[p]Two example implementations of synthesizer driving scripts are included in the game engine distribution: Dynamic music and announcers. Both use a simple synthesizer with a single chain source and are ready to use.

Dynamic music allows to modify music playing by transitioning through music parts using switches. As a test example I used the dynamic music files from Stalker Clear-Sky since they are well suited for this test-case. The included scripts load the dynamic music from an XML file created by hand. The file contains the music parts (sound files), switches used by the game and transitions between music parts depending on switch states. All is implemented in simple game scripts so it can be altered and extended without limits.

Announcers allow to produce in a simple way announcement systems like automated train announcement systems using a list of recorded words. As a test example I used the VOX files from half-life 1 since they are well suited for this test-case. The included scripts load the announcer from an XML file created by hand. The file defines where the word sound files are located. Once loaded a sentence can be given to the script and it plays back the announcement.

The video below shows these two scripts in action from inside the test project. This is a project included in the game engine distribution and is a sort of demo-project to learn the ropes. Copyrighted material as used for my implementation tests are obviously not included.

Dynamic Music and Announcer Test (IndieDB Video)

[p]These are only two small examples which the game will build upon. Since these are scripts it is simple to extend and improve. And now to something different.

Material Sounds

The game project uses reusable world geometry a lot. For this reason material sounds are not as simple as assiging a sound type to an object. Especially material-material impact sounds require usually a lot of work with recording tons of sound samples. Since I don't have a sound engineer and not this level of equipment I decided to cut down the number of sounds by using combined collision sounds. Instead of playing one sound for each individual material combination impacts play now a sound for each material involved. This reduces work a lot while allowing for more combinations. Material types support now a range of different sound events from impacts to actor movement sounds. Sounds are either pre-recorded sound samples or possibly synthesizers. Former is used right now for easier use but later can be used for special tricks.

To improve this the physics system has been also improved to properly handle kinematic and dynamic collisions in a similar way. Collision shape properties are now used on all elements to link collision shapes to object materials. The world editor supports now properties on component textures as seen in the screenshot below.

[p]This allows to assign arbitrary properties to textures while re-defining them in the editor. The game scripts use this to re-define per-texture material type in addition to those defined in element classes. The video below is work in progress on adding more material sounds as well as getting all objects their appropriate sounds assigned.

Material Sounds (IndieDB: Video)


With the synthesizer system in place I can now do this nifty little surprise I'm twiddling around in my head for a long time. I'm not going to say more for the time being :D .