Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Suggestions ➜ Allow setting the volume for a sound in the trigger dialog

Allow setting the volume for a sound in the trigger dialog

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Kahenraz   (75 posts)  Bio
Date Tue 27 Sep 2016 08:07 PM (UTC)
Message
Currently I have to either modify my sound files in Audacity to change their volume or use PlaySound() and run the effect as a script, which then requires me to use the world input debugger every time I want to test the volume.

Neither of these options are straightforward or convenient. It would be great if I could set the volume right there in the "sound" area of the trigger dialog.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 27 Sep 2016 08:54 PM (UTC)
Message
I don't really want to fiddle with the resources layout as people may have re-done those in different languages. See:

http://www.gammon.com.au/scripts/doc.php?general=plugin_callbacks

There is a callback: OnPluginPlaySound

That lets you handle the sound playing (for example for triggers). Here is an example plugin I made a while back that plays different volume levels and panning depending on the file name:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="Sound_Volume_Reducer"
   author="Nick Gammon"
   id="b1308ed1e6d5e4facdaf7bdd"
   language="Lua"
   purpose="Plays trigger sounds more quietly"
   date_written="2010-06-02 06:33:40"
   requires="4.40"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Install this to play trigger sounds at reduced volume.
]]>
</description>

</plugin>

<!--  Script  -->

<script>
<![CDATA[

volumes = {
  ["west"] = { volume = -6, pan = -100} ,
  ["east"] = { volume = -15, pan = 100} ,
  }
  
function OnPluginPlaySound (sound)

  -- defaults
  local volume = -12
  local pan = 0
  
  -- search file name for a keyword that affects its volume
  for k, v in pairs (volumes) do
    if string.match (sound, k) then
      volume = v.volume
      pan = v.pan
      break
    end -- if matched part of sound name
  end -- for
  
  PlaySound (0, sound, false, volume, pan)  -- play supplied sound as required
end -- function

]]>
</script>
</muclient>


You could do something similar that checks a variable and plays at that sound level. Then make an alias to alter the variable's value. You could make another alias to do a test sound.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,268 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.