Post tutorial RSS Stereo Audio in Shadow of Chernobyl

Daemonion shows how to get stereo audio working within the older SoC XRay engine. These changes are included in LURK 1.2.

Posted by on - Basic Client Side Coding

Why go to the trouble of making stereo audio work?

Shadow of Chernobyl
is filled with audio that only plays in mono. While mono has it's uses, a game world needs stereo audio, as well, in order to feel complete. Only using mono, by itself, gives a very compressed feeling.

Mono is good for:
- 3D position sounds (static sound sources in XRay)
- Dialogue directly from an NPC- Environmental "one-shot" sounds (dogs barking, etc)
- Weapon mechanical noises (reloading, the bolt cycling, etc)

Stereo
is good for:
- Environmental ambiance (wind, crickets, rain)
- Music
- Weapon reports/reverberation (the reflections off the environment)
- Encompassing effects

When using these together, you can create a very full sound stage. As the lead audio designer for LURK 1.2, I knew I had to get stereo audio working in SoC.

To illustrate the differences, give these a listen.

Which one feels more encompassing?

Now you see why I went to the trouble :)


How?
Stereo files are made up of a left channel and a right channel. Mono has only a center channel. A stereo file is a combination of these left and right channels.

SoC's XRay engine can't actually use a true stereo file like the Call of Pripyat engine can. When XRay was being made, GSC came up with the idea to use two stereo-separated, mono files affixed with a _l and _r to indicate left or right.

The engine was then supposed to use an algorithm to play a _l file only in the left channel, and a _r file only in the right channel. When played together, this would make it sound as though stereo audio was playing, even though it was just two separate mono tracks.

This never worked, in-game, though. Until now.

**Note you can't just use any old mono track. You need to start with a true stereo file and convert it's left and right channels into separate mono tracks. This way, you have a left channel mono file and a right channel mono file.

You will need to first get your stereo sounds converted to split-track mono .ogg files (don't forget to comment them properly). I use Audacity to split a stereo track into two channel-dependent tracks. To split the tracks:


You will also need to replace your gamedata/scripts/sr_sound2d.script with my new sr_sound2d.script at the bottom of the post. My changes essentially add these lines of code, which switch to the .s2d function to place each file at particular x,y,z coordinates.

self.snd_obj_l:play_at_pos (actor, vector():set(-0.5,0.0,-0.3), d / 1000.0, sound_object.s2d)
self.snd_obj_r:play_at_pos (actor, vector():set( 0.5,0.0,0.3), d / 1000.0, sound_object.s2d)

Lastly, you will need a new wrap_oal.dll file, as the left and right channels are swapped with the vanilla .dll, also included at the bottom of the post.


Files

Place this new wrap_oal.dll into your /bin directory
Replace your sr_sound2d.script with this (back up your old file!) or PasteBin

Enjoy!

Thanks to:
Malandrinus
Artos
NatVac
AMK Forums
GSC Forums

Comments
Lоnerboner
Lоnerboner

Nice man! im going to try this out!

Reply Good karma Bad karma+3 votes
Daemonion Author
Daemonion

Please let me know if it works for you.

Reply Good karma+1 vote
Guest
Guest

This comment is currently awaiting admin approval, join now to view.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.