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

    • JackFarmer

      @joebarnin
      Jeff, I sent you PM a few weeks back but you did not respond. Maybe your inbox is full?
      · 5 replies
    • The Black Arrow

      I was playing Skyrim, got bored fast. Got back to The Dark Mod just for one mission, played "Somewhere above the City" which is not really a great mission but still good, as in above-average.
      My biggest regret is living in this country, where there's a heat wave, I am sweating at 20c and I really wish for temperatures below 5c.
      · 10 replies
    • Skaruts

      Is there something wrong with the forums lately, or is it my browser? I've been having trouble formatting posts, and just now I couldn't format anything at all.
      I'm using Vivaldi.
      Usually I have to: select text, click bold, nothing happens, select again, click bold, then it works. 
      Same for other stuff, like creating spoilers, bullet points, links. Nothing works the first time. 
      · 1 reply
    • STiFU

      Back from a spontaneous 1-week trip to Lanzarote with wife and son. I hope beta testing has been going well...
      · 1 reply
    • datiswous

      Whenever I eat fried chicken these days I think of this scene in The Black Mage..

      · 1 reply
×
×
  • Create New...