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

« Previous 10 events | 1 2 | All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  04:38:47  28 August 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
08/28/2012 4:39:57
Messages: 567
I, with the help of someone good at maths, created a new algorithm for a new function called vector_rotate_x (in _g.script):


-- this function rotates audio along the X axis instead of the Y, hopefully to create a stereo effect from two mono files
function vector_rotate_x (v, angle)
    angle = angle * 0.017453292519943295769236907684886 --1 degree (converted from radians)
    local c = math.cos (angle)
    local s = math.sin (angle)
    return vector ():set (v.x, v.y * c - v.z * s, v.y * s + v.z * c)
end

-- I was also thinking of this equation: (v.y * c - v.z * s, v.x, v.y * s + v.z * c)
-- for reference, here is vector_rotate_y (originally used)
function vector_rotate_y (v, angle)
    angle = angle * 0.017453292519943295769236907684886
    local c = math.cos (angle)
    local s = math.sin (angle)
    return vector ():set (v.x * c - v.z * s, v.y, v.x * s + v.z * c)
end



Here is the altered action_sound2d:get_source_positioins function in sr_sound2d.script:

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


Before, XRay was being told to take mono sound files (sound_l and sound_r) and combine them while offsetting them along the Y axis to create a stereo sound based on the player's current position.

However, rotating sound on the Y axis won't create a stereo effect. It needs to be on the X axis, so I created this new algorithm to do so. The hope is to have the left channel offset by -90 degrees, and the right channel offset by +90 degrees from the player's position. This should create a stereo effect.

However, the functions still need a little tweaking. Does anyone have any feedback to give? Both channels don't seem to be offsetting in separate directions.
  13:54:42  16 October 2012
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4286
Daemonion, did you get my email on this topic?
  20:19:26  16 October 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Daemonion, did you get my email on this topic?
---END QUOTATION---


I did, but no one really responds to me here. I have been using the little bit of Russian I know to make posts in the AMK forums. Here are some things I have gotten back (translated from Russian):

Reply 1:
To play a pseudo-stereo uses metoody:

oSnd : play_no_feedback ( oActor , sound_object . S3D ,  2 , Vector (),  1.0 )  - /  ringing  in  the ears


or

oSnd:play_no_feedback(oActor, sound_object.s3d, 2, oActor:bone_position("bip01_spine"), 1.0) --/ звон в ушах


Sr_sound2d.script script is hardly ever used in the game, and I have it as follows: http://codepad.org/08hvgN2E

Also from here you can take something: http://codepad.org/QspAJs73
--------------------------------------------------------------------------------------------

Reply 2:
First, the engine can't really play stereo. It automatically reads separate channels in "_l" and "_r" files only for the main menu music, level soundtrack, and videotutorials. Even in this case stereo is just an imitation. The engine plays two sounds from points to the left and to the right from the actor, so two sounds are somehow mixed. You can notice that if you will take for two channels two completely differents tunes.

Second. To make the scheme from sr_sound2d.script play stereo, one needs to add stereo = 1 parameter into the logic section for this scheme.

Third, the scheme from sr_sound2d.script tries to imitate playing stereo the same way as the engine does, but with a little difference (and maybe just incorrectly). It plays two channels using this syntax:

self.snd_obj_l:play_at_pos (actor, pos_l, d / 1000.0, sound_object.s3d)
self.snd_obj_r:play_at_pos (actor, pos_r, d / 1000.0, sound_object.s3d)


But the engine internally uses the constant value equivalent to the sound_object.s2d

As a result, both channels are mixed almost completely. So, to imitate, what engine does in the main menu, one needs to do the following:

1. Replace these two lines in the function action_sound2d lay_sounds with

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)


That will make mixing less noticable

2. In the function action_sound2d:update remove or comment out the fragment

if self.st.stereo == true then
         ....
end


If not do so, sound will stop shortly after beginning.

After that (and don't forget about stereo = 1 in a logic section) stereo will play the same way as it plays in the main menu. Again, there will be some channels mixing anyway.
------------------------------------------------------------------------------------------

There, he meant to make sure that stereo = true is set in each instance of sr_sound_act in my space restrictor code, as I left some out for testing.
  21:28:21  16 October 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
but, yea, none of that seems to work.
  11:10:29  18 October 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
10/18/2012 11:11:25
Messages: 567
I GOT IT WORKING!

Pseudo-stereo (split mono left and right channels) now works properly in SoC!

A stereo file just needs to have the left and right channels split in, say, Audacity into two separate mono files. It works great!
  12:19:02  18 October 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519
Very cool! And the engine knows automatically by the left and right part's filename that it has to play it together as stereo, or do you still need to trigger both audio files by script?
  14:02:50  18 October 2012
profilee-mailreply Message URLTo the Top
ddraig
Senior Resident
 

 
On forum: 06/19/2012
Messages: 158

---QUOTATION---
I GOT IT WORKING!

Pseudo-stereo (split mono left and right channels) now works properly in SoC!

A stereo file just needs to have the left and right channels split in, say, Audacity into two separate mono files. It works great!
---END QUOTATION---



Aw man, don't keep it yourself! True stereo (or at least as close as you can get) would make so many mods so much better..

Hopefully it won't just be a LURK exclusive
  20:13:59  18 October 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
10/18/2012 23:09:02
Messages: 567
Meltac
The engine knows automatically. It works really smoothly. There is a little overlap in the center channel, as well, so it isn't jarring or way too wide of a sound stage.

ddraig
You bet I'll share it with the community! The engine still won't take actual stereo audio files (getting that to work is beyond my skill), but I have _l and _r mono files working just as well. The trick is that the modder has to take a audio file in true stereo and split the left and right channels into two separate mono tracks. If that isn't done properly than the audio will sound the same in-game, for the most part.

Here is my tutorial:
https://www.gsc-game.com/index.php?t=community&s=forums&s_game_type=xr&thm_page=1&thm_id=21756&sec_id=16
 
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.