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

    • taaaki

      Apologies for the unplanned downtime. A routine upgrade did not go to plan, and the rollback had its own issues
      · 2 replies
    • freyk

      Got tdm 2.12 running on my android phone. For more info, read the latest post in the topic on subforum techsupport.
      · 2 replies
    • snatcher

      TDM Modpack v4.5 released!
      Introducing... The Loop
      · 1 reply
    • Ansome

      Taking a break to alleviate burnout. In retrospect, I probably shouldn't have jumped into a map-making contest so quickly after just finishing another project and especially with my busy schedule, but I do believe I have something that the community will enjoy. No clue if I'll be able to finish it on time for the competition if I factor in a break, but I'd rather take my time and deliver something of quality rather than engage in development crunch or lose part of the map's soul to burnout.
      · 1 reply
    • Skaruts

      Working on an update for my mission By The Cookbook. If anyone that played it has any further bugs to report, please let me know.
      I posted more details about the update in the mission thread.
      · 1 reply
×
×
  • Create New...