Play Soundloop for whole cell?

Post » Fri May 04, 2012 5:55 am

hi,

is it possible to play a stereo soundloop for a whole cell?
i want to have a cave wind loop to play in stereo all over the whole dungeon on the same volume.

currently i use invisible activators to play a soundloop, unfortunately they have a radius in wich you can hear the sound but it cant be heard everywhere in the cell.

i noticed when i set the ranges both to 255 the sound is played at the same volume in the whole radius, but still stops as soon as i leave that radius :dry: - is it possible to make the Player the soundsource? that should work i think ...

iam sure its something very easy that iam missing ... the only soundloop functions i was able to find are "http://www.uesp.net/morrow/editor/mw_cscommands.shtml#playloopsound3d" or "http://www.uesp.net/morrow/editor/mw_cscommands.shtml#playloopsound3dvp" isnt there just a "PlaySoundLoop"? how are the storm/rain loops are handled?

i hope this is even possible and i hope you understand what i mean.


thanks!
User avatar
Jeffrey Lawson
 
Posts: 3485
Joined: Tue Oct 16, 2007 5:36 pm

Post » Fri May 04, 2012 5:20 am

Maybe on of http://www.uesp.net/morrow/editor/mw_cscommands.shtml#playsound commands?
User avatar
Kaley X
 
Posts: 3372
Joined: Wed Jul 05, 2006 5:46 pm

Post » Fri May 04, 2012 7:51 am

i found out how to play a soundloop at the same volume all the time - via "player -> PlayLoopSound3DVP "PB_Loop_Cave_01", 0.5, 1.0".

still iam using a activator placed inside of the cave wich has the following script attached:

begin PB_Script_Cave_01if ( CellChanged == 0 )    if ( GetSoundPlaying "PB_Loop_Cave_01" == 0 )        player -> PlayLoopSound3DVP "PB_Loop_Cave_01", 0.5, 1.0    endifendifend

unfortunately the soundloop starts over and over again every frame ... thanks to the help i got from you guys in the past, i knew that this would happen but i just dont know how to fix it.

strangely the soundloop is working perfectly when i leave the cell ... and it never stops too :swear:
User avatar
Miguel
 
Posts: 3364
Joined: Sat Jul 14, 2007 9:32 am

Post » Fri May 04, 2012 3:51 am

unsure, but worth a try...
begin PB_Script_Cave_01if ( CellChanged == 0 )    if ( player->GetSoundPlaying "PB_Loop_Cave_01" == 0 )        player->PlaySound3DVP "PB_Loop_Cave_01" 0.5 1.0    endifendifend
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Fri May 04, 2012 6:17 am

its working! thanks to you abot!
i was trying for about 4 hours and didnt get anything done ...

there is just one little problem: the loop keeps playing until the soundfile is over when i leave the cell.
so how can the sound be stopped when i leave the cell?

this is what i was not able to understand - i know this is possible with "CellChanged" but i dont get it to work,


edit - i can hear a short break between the soundsamples when i use "PlaySound3DVP" instead of "PlayLoopSound3DVP" ... its late and i will better try again tomorrow, thanks for the help so far!
User avatar
kyle pinchen
 
Posts: 3475
Joined: Thu May 17, 2007 9:01 pm

Post » Thu May 03, 2012 10:47 pm

Never tried this with sound, but since you have the player as the calling object for the sound file, you may have found a limit with PlaySound.

All I can think of is to add a triple-check with current cell location and a StopSound;

begin PB_Script_Cave_01if ( GetInterior == 1 )  ;Not sure if this works if cell is marked as "behave like exterior"if ( CellChanged == 0 )	 if ( player->GetSoundPlaying "PB_Loop_Cave_01" == 0 )		  player->PlaySound3DVP "PB_Loop_Cave_01" 0.5 1.0          elseif ( GetPCCell, "my cell" == 0 )                Player->StopSound, PB_Loop_Cave_01                return	 endifendifendifend

Untested. *crosses fingers*
User avatar
ANaIs GRelot
 
Posts: 3401
Joined: Tue Dec 12, 2006 6:19 pm

Post » Thu May 03, 2012 9:06 pm

The script is attached to an in-cell object, right? So, if what you need is a sound playing unrelated to player's direction/distance toward a certain point, why not ditch the 3D in sounds altogether?
begin PB_Script_Cave_01if ( CellChanged == 0 )	if ( GetSoundPlaying "PB_Loop_Cave_01" == 0 )	    PlaySoundVP "PB_Loop_Cave_01" 0.5 1.0	endifendifend
User avatar
DeeD
 
Posts: 3439
Joined: Sat Jul 14, 2007 6:50 pm

Post » Thu May 03, 2012 10:23 pm

or try this...
begin PB_Script_Cave_01if ( CellChanged )	if ( ScriptRunning "PB_Script_Cave_01_stop" )	else		StartScript "PB_Script_Cave_01_stop"	endif	returnendifif ( player->GetSoundPlaying "PB_Loop_Cave_01" == 0 )	player->PlayLoopSound3DVP "PB_Loop_Cave_01" 0.5 1.0endifend

begin PB_Script_Cave_01_stopif ( GetInterior )	  ; or use if ( GetPCCell "yourInterior" )else	player->StopSound "PB_Loop_Cave_01"	StopScript PB_Script_Cave_01_stopendifend
User avatar
Jordan Fletcher
 
Posts: 3355
Joined: Tue Oct 16, 2007 5:27 am

Post » Thu May 03, 2012 9:35 pm

you people are awesome! thanks for spending time to help me.

abot, the last script you posted works 100% for me but there is one thing iam wondering:

you use "GetInterior" so what happens when i teleport to another interior cell? well i guess ill just test it.
the other option you mentioned via "GetPCCell" would require some annoying keyboard work but will work for sure.

with the "GetInterior" version i would just need to make one script for all cells that use the same soundloop, with "GetPCCell" ill need to make a single script for each cell, right?


with my awesomely bad scripting skills i had an idea:

Begin _asePB_scr_cave1Short InsideAddamasartusif ( GetPCCell Addamasartus == 1 )    if ( InsideAddamasartus == 0 )        messagebox INSIDE        player - PlayLoopSound3DVP _asePB_snd_cave1, 1.0 , 1.0        set InsideAddamasartus to 1    endifelseif ( GetPCCell Addamasartus == 0 )    if ( InsideAddamasartus == 1 )        messagebox OUTSIDE        player - StopSound _asePB_snd_cave1        set InsideAddamasartus to 0    endifelse    messagebox ELSEWHEREendifEnd

this is supposed to be a global script wich runs in the background all the time.
what do you guys think? will this kill performance if it handles hundeds of cells?
i added this as starting script, is that ok?
User avatar
Karl harris
 
Posts: 3423
Joined: Thu May 17, 2007 3:17 pm

Post » Fri May 04, 2012 12:56 am

damn, its like i expected - the loop continues to play when i teleport into another interior (with abots scripts).

Untested. *crosses fingers*
The script is attached to an in-cell object, right? So, if what you need is a sound playing unrelated to player's direction/distance toward a certain point, why not ditch the 3D in sounds altogether?
these scripts have the same problems like my first one - inside the cave the loop starts again every frame and continues to play outside the cave.
about the 3d sounds - i wanted to ditch them too but there is no non 3d loop function and when i use the regular playsound function there are short breaks when the sound gets looped.

when you tell me that my global script attempt will not work, then i will use abots scripts with "GetPCCell" instead of "GetInterior".

this should not be very bad for the performance even if its hundreds of scripts, correct?


EDIT: with "GetInterior" abots scripts work just perfect! even when i teleport to another interior.
so iam going to wait for your judgement over my global script OR how bad 200 scripts for the interior activators affect the performance. then i will start adding really immersive soundloops to vvardenfells interiors!
User avatar
sw1ss
 
Posts: 3461
Joined: Wed Nov 28, 2007 8:02 pm

Post » Thu May 03, 2012 8:58 pm

abot, i noticed that when i load a savegame where iam inside the cave the sound starts properly but wont stop when i leave the cell.
i cant think of a check to avoid this, but you maybe?
User avatar
Irmacuba
 
Posts: 3531
Joined: Sat Mar 31, 2007 2:54 am

Post » Thu May 03, 2012 10:40 pm

It should work well as auto started global script, GetPCCell is fast, this is slightly optimized
Begin _asePB_scr_cave1Short InsideAddamasartusif ( MenuMode )	returnendifif ( GetPCCell "Addamasartus" )	if ( player->GetSoundPlaying "_asePB_snd_cave1" )	else		player->PlayLoopSound3DVP "_asePB_snd_cave1" 1.0 1.0	endif	if ( InsideAddamasartus )	 else		set InsideAddamasartus to 1	endif	returnendifif ( InsideAddamasartus )	set InsideAddamasartus to 0	player->StopSound "_asePB_snd_cave1"endifEnd
User avatar
Sylvia Luciani
 
Posts: 3380
Joined: Sun Feb 11, 2007 2:31 am

Post » Fri May 04, 2012 11:00 am

this is working absolutelly flawless now! thanks alot!

i cant believe that my script actualy did what i wanted, iam learning.

i just hope it keeps working so good when i added all the >200 caves to the script, but thanks to your optimization i believe it will work well.



EDIT - one little question: do many spaces or slashes slow down the scripts? or can i use some slashes to get a better visual structure to the script? iam asking because most other scripts i see always have as few unnessesary characters as possible.
User avatar
Claire Mclaughlin
 
Posts: 3361
Joined: Mon Jul 31, 2006 6:55 am

Post » Fri May 04, 2012 12:42 am

i just hope it keeps working so good when i added all the >200 caves to the script, but thanks to your optimization i believe it will work well.
I FPS loss is noticeable, you could try splitting tests to no more than a few cells per frame
do many spaces or slashes slow down the scripts? or can i use some slashes to get a better visual structure to the script? iam asking because most other scripts i see always have as few unnessesary characters as possible.
No, it should not slow script down, it is converted to pseudo code when saved/compiled so spaces/comments are skipped. But it increases mod size so usually spaces/tabs are used only when needed (you must indent code to make it understandable). I do prefer something like
set i1 to 3; starting calculationsset i1 to ( i1 + 100 )
instead of
set i1 to 3; ===================================; starting calculations; ===================================set i1 to ( i1 + 100 )
, but it is a matter of preference.
[EDIT]typos
User avatar
Connie Thomas
 
Posts: 3362
Joined: Sun Nov 19, 2006 9:58 am


Return to III - Morrowind