[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Suggestions
. . -> [Subject]  Allow setting the volume for a sound in the trigger dialog
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

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] Refresh page


Posted by Kahenraz   (42 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] 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.


1,517 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]