Jump to content
The Dark Mod Forums

Adjusting speaker volume from script - NOT just on/off


BlackMagic

Recommended Posts

I want to adjust the volume of a speaker from script. I have a pan with "beef links" cooking on a stove. as the player takes them away (one by one) I want the "sizzle" sound to decrease. When all have been taken, I turn off the speaker from script. Works fine EXCEPT the volume is not changed. I tried $speaker_sausages.setKey("s_volume", 2);  as well as negative values, but it does not change. The starting value on the speaker is s_volume 10. What am I doing wrong?

Link to comment
Share on other sites

You're right; changing the s_volume key during play seems to do nothing.

 

You can fake it by using multiple speakers though. Place one speaker for each beef link in the same place on the stove. Give one the volume you want when all the beef links are present, another the volume you want when one has been taken, and so on. Have only the loudest one playing on map start. Then when you take a chunk of meat, turn that speaker off and the next loudest one on, cycling through until all the meat is gone and the quietest speaker is off. You should be able to accomplish this fairly easily with two trigger_sequencers.

My missions:           Stand-alone                                                      Duncan Lynch series                              

                                      Down and Out on Newford Road              the Factory Heist

                                                                                                  A House Call

                                                                                                  The House of deLisle                                                                                                  

                              

Link to comment
Share on other sites

Actually, I worked it out by setting the speakers minDistance to 0.05, and then tweaked the maxDistance to shrink in the script. Thanks for responding thebigh. (does that mean The Big H?) have a virtual Fosters on me! 😀

  • Like 1
Link to comment
Share on other sites

Huh, that's interesting that min and maxDistance are dynamically updated in-game but s_volume isn't.

Your method will have the issue that the sizzling will become inaudible at a shorter distance from the stove- if two steaks are audible ten meters away, realistically one steak should also be audible ten meters away but half as loud- but nobody will notice that if all the actual changes in volume will happen when you're standing right by the stove. And it does mean fewer speakers and less scripting.

Looking forward to seeing your mission and eating some of that beef!

My missions:           Stand-alone                                                      Duncan Lynch series                              

                                      Down and Out on Newford Road              the Factory Heist

                                                                                                  A House Call

                                                                                                  The House of deLisle                                                                                                  

                              

Link to comment
Share on other sites

$speaker_sausages.setKey("s_volume", 2);    That is a spawn time script function meaning what it does, only happens when a entity spawns, so would need to restart the mission for it to make effect, if you want to change something during gameplay, you need to call other functions like

/**
 * Fades the sound on this entity to a new level over a period of time.  Use SND_CHANNEL_ANY for all currently playing sounds.
 */
scriptEvent void		fadeSound(float channel, float newLevel, float fadeTime);

or

/**
 * Set the volume of the sound to play, must be issued before startSoundShader.
 */
scriptEvent void		setSoundVolume(float newLevel);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 2 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 5 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
×
×
  • Create New...