ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
STALKER and Stereo Playback ...

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  09:52:12  23 April 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
04/23/2012 9:54:26
Messages: 567
STALKER and Stereo Playback ...

So, my research has shown me that SoC doesn't actually play back anything in stereo, not even the music.

I believe gamedata\scripts\sr_sound2d.script is responsible for stereo audio playback. If it is asked to play something in stereo, it will check to make sure there is a sound_l.ogg and sound_r.ogg and combine them. However it still comes out mono in-game. Take this example:


[sr_sound_act@outdoor_day]
theme = outdoor_white_noise_day
delay = 0
max_delay = 0
stereo = true


This code will play the files outdoor_l.ogg (mono) and outdoor_r.ogg (mono) at the same time. However, the end result is still mono.

There is some code in sr_sound2d.script that I believe is responsible for positioning the L and R mono files to create a stereo effect:

function action_sound2d:get_source_positions ()
    local actor = db.actor
    local dir = actor:direction ()
    dir.y = 0.0
    local dir_left = vector_rotate_y (dir, 45)
    local dir_right = vector_rotate_y (dir, -45)
    dir_left:normalize ()
    dir_right:normalize ()
    local pos = actor:position ()
    pos.y = pos.y + 1.5
    local pos_l = pos;
    return pos_l:add (dir_left:mul (1.5)), pos:add (dir_right:mul (1.5))
end


You'll notice, though, that it rotates the channels along the Y axis. I think this needs to be along the X axis to make true stereo. However, changing it to:

    local dir_left = vector_rotate_x (dir, -90)
    local dir_right = vector_rotate_x (dir, 90)


results in a crash (not because of the 90, but because of vector_rotate_x).


Does anyone have any ideas? All of the game music, and even any sr_sound_act, actually play in mono, regardless of a sound_l.ogg and sound_r.ogg files.
  12:50:11  23 April 2012
profilee-mailreply Message URLTo the Top
Bangalore
Robberbaron
(Resident)

 

 
On forum: 02/17/2008
 

Message edited by:
Bangalore
04/23/2012 12:56:57
Messages: 1158
The vector_rotate_x is an undefined value in gamedata\scripts, so this function crashes.

You should create a vector_rotate_x (global) function in .script or in _g.script, similar to the vector_rotate_y function, what you can find there in .script (and in _g.script).
And you have to figure out the mathematic algorythm for this.
  14:44:01  23 April 2012
profilee-mailreply Message URLTo the Top
{imperialreign}
Звуковой Шаман
(Resident)

 

 
On forum: 10/29/2008
Messages: 3075
I can't verify the musics, but the only thing I know of that x-ray does play in stereo are "system" sounds . . . i.e., those that are called specificaly by script logics and/or hard-coded engine sounds. One good example of each: Sid's opening monologue (triggered by an i_p, IIRC), and the other type being a controller aura's.

There's actually a couple of different bugs within x-rays audio engine where the stereo playback can become evident. Especially with controllers. For some odd reason, the engine will "hiccup" and only playback one track instead of both - usually the right side, for some odd reason. Sometimes even restarting the game won't take care of the issue, as whatever triggers this one-sided playback seems to get saved into the current save game . . .

Otherwise, the engine can't handle positional stereo playback (i.e. world sounds originating from a specific "source" in-game), and will resort to using only one track of the two (typically the right channel track).


Regarding x/y axis in audio, the thinking is quite different than how we've come to view spatial plotting thanks to being taught math in schools. X continues to remain left to right, Y is up and down, z is near and far.

http://raffayhamid.com/ICIP_2004.pdf

To make matters even more convoluted (like they wouldn't be with x-ray), v1.5 and 1.6 oif the engine make use of a rather "unique" positioning formula (especially for ambient audio) that's rather unheard of:

http://en.wikipedia.org/wiki/Ambisonics

It's not exactly the same, but similiar - I can't find the link to the white sheet on this type of audio positioning ATM. But, it uses some asinine x,y,z,w to plot out movement and sound direction.
  23:18:25  23 April 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
Very informative, thanks.

Why wouldn't STALKER use some obscure, audio rendering technique? If it isn't overly difficult, it has no place in this game.
  14:46:27  25 April 2012
profilee-mailreply Message URLTo the Top
{imperialreign}
Звуковой Шаман
(Resident)

 

 
On forum: 10/29/2008
Messages: 3075
Exactly

Everything I've described in the past about how x-ray seems to handle audio processing tends to be entirelly backwards from how every other game devs impliments things.

Granted, this is all just speculation based on modding, testing, tweaking and observing how things are called/processed within game, as I haven't cracked open the engine or libraries to really check things out, but . . . it's not that hard to figure out audio implimentation (at least, for me, IMHO).

Most games use some type of object-oriented processing, focusing around the object a sound originates from, and how it relates to the player/actor (usually leaving sounds to be played regardless of if the player is within range to hear them) . . . x-ray uses an actor-oriented design, instead focusing on the actor's relation to a sound object (meaning sounds are only played if the actor can actually hear them).

Yeah, it's backwards, but IMHO a brilliant design for a game that's VERY CPU intensive - it removes a lot of the audio workload off the CPU unless it needs to processed.
  01:02:32  3 May 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
05/03/2012 1:02:52
Messages: 567
I loaded up Call of Pripyat to see if it uses stereo sounds. It does.

I've been digging through the .script files, but I can't really pin it on any particular thing. It seems like bringing that code (and the libraries, I'm assuming) over into SoC would take a lot of work.
  14:47:42  3 May 2012
profilee-mailreply Message URLTo the Top
{imperialreign}
Звуковой Шаман
(Resident)

 

 
On forum: 10/29/2008
Messages: 3075
Yeah - both CS and CoP will use true stereo sounds. Mostly for music and some other odds and ends (i.e. ambient background, system, etc.)

It would require editing of the engine file, libraries, and OAL libraries.
  00:42:32  4 May 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Yeah - both CS and CoP will use true stereo sounds. Mostly for music and some other odds and ends (i.e. ambient background, system, etc.)

It would require editing of the engine file, libraries, and OAL libraries.
---END QUOTATION---


Damn, that it was I thought. That is most certainly out of my reach.
  01:34:45  4 July 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
I am beginning a strong effort to bring true stereo audio in SoC.

As mentioned before, CoP is able to play true stereo sound - SoC, however is not. It is my hope to take whatever magic is in CoP and apply it to SoC, or something along those lines.

I notice that SoC uses a sr_sound2d.script file (to have files appended with the _l and _r), but this still results in mono sound.

CoP seems to use a xrs_stereo.script file, which might be part of the puzzle.

I'm assuming xrSound.dll is different for SoC and CoP.


If anyone has anything to share on this, please, PLEASE let me know. I really want to get stereo audio working in SoC.

I'll post here if I have any updates.
  01:53:26  4 July 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
I can't verify the musics, but the only thing I know of that x-ray does play in stereo are "system" sounds . . . i.e., those that are called specificaly by script logics and/or hard-coded engine sounds. One good example of each: Sid's opening monologue (triggered by an i_p, IIRC), and the other type being a controller aura's.
---END QUOTATION---


Hm, it appears that sid's opening monologue is in mono, actually.

I'm looking in \sounds\characters_voice\dialogs.

The psy aura in \sounds\monsters\controller does have the _l _r designation, but this method will not work with "true" stereo files, as they are both mono.

For example, I can't create a stereo track with a wide left and right field and convert it into a mono_l and a mono_r track. All of the stereo data is lost. The method in SoC just copies the same mono file into each channel, resulting in the same mono sound.
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2020 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.