Thread Tools Display Modes
04-25-15, 11:04 PM   #1
jandiarl
A Murloc Raider
Join Date: Apr 2015
Posts: 6
Trying to mute sounds on an event

Hello, I am trying to find a way to disable sounds like leveling up and similar sounds temporarily. I have searched for over an hour and could not find anything. Anyway, I tried thinking of a way to do it myself. So, what I did is try adding hooks on PlaySound and PlaySoundFile and suppress it there. Though, I cannot get any handle so I disable those specific sounds. I only get the sound path. So, I thought I could mute the sound and that worked but my problem is how to turn it back on after the sound is done playing. I even tried hooking on StopSound and unmuting but that wont work cause the event does not go there (I traced). Any ideas are appreciated. By the way, I am not trying to disable the sounds permanently. I know I could do that by putting empty files in the wow folder associated with the sounds to mute. That I do not want. Thank you.
  Reply With Quote
04-26-15, 02:29 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
  1. Find the path to the sound file within the game that plays when you level up.
  2. Create an empty txt file and rename the extension to .ogg, with the same file name as the file in step one (you don't need the whole path).
  3. In your AddOn, register for "PLAYER_LEVEL" and any other events you want to silence.
  4. PlaySoundFile(your_new_file)
  5. Profit!
  Reply With Quote
04-26-15, 10:51 AM   #3
jandiarl
A Murloc Raider
Join Date: Apr 2015
Posts: 6
myrroddin, thanks for the reply. Though, I have tried that trick earlier and it does not work. I silenced the sound file and added a new file. The main sound gets permanently silenced and the new file does not play at all.
  Reply With Quote
04-26-15, 08:08 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by myrroddin View Post
  1. Find the path to the sound file within the game that plays when you level up.
  2. Create an empty txt file and rename the extension to .ogg, with the same file name as the file in step one (you don't need the whole path).
  3. In your AddOn, register for "PLAYER_LEVEL" and any other events you want to silence.
  4. PlaySoundFile(your_new_file)
  5. Profit!
Steps 3 and 4 are totally unnecessary. Simply save your blank sound file to the same location as the file you wish to replace. Like this addon (and others like it) does: http://www.wowinterface.com/download...WoWSounds.html
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
04-27-15, 11:03 AM   #5
jandiarl
A Murloc Raider
Join Date: Apr 2015
Posts: 6
Thank you for the reply, Seerah. Though, like I said I have tried those solutions and I do not want to permanently disable the sounds. I want to disable/mute them temporarily like I said in my original post.

So, to clear any further confusion. Here is what I want. I want to selectively mute some of the sounds and enable others for the same event. For example, on the level up sound I want to mute it on level 10 while allowing it on level 20.

Thank you.
  Reply With Quote
04-27-15, 11:21 AM   #6
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
Could check the level on PLAYER_ENTERING_WORLD, get the player level, check a hash table with 9, 19, 29, etc. If the player's level == one of the levels in the hash table, enable the sound, so when you next level, it will play, else, disable. Then have it check on player level gain event.

The following is dry coded, but should give you a basic idea of what I mean.
Lua Code:
  1. local levelchecktable = {}
  2. local k
  3.  
  4. for i = 0, 9 do
  5.     k = 9 + 10*i
  6.     levelchecktable[k] = true
  7. end
  8.  
  9. local f = CreateFrame('Frame', nil, UIParent)
  10. f:RegisterEvent('PLAYER_ENTERING_WORLD')
  11. f:RegisterEvent('PLAYER_LEVEL_UP')
  12.  
  13. f:SetScript('OnEvent', function(self, event, ...)
  14.     k = UnitLevel('player')
  15.     if levelchecktable[k] then
  16.         --ensure the .ogg sound file is set to the correct sound file
  17.     else
  18.         --set the .ogg soundfile to a false file
  19.     end
  20. end)

Last edited by sirann : 04-27-15 at 12:21 PM.
  Reply With Quote
04-27-15, 01:52 PM   #7
jandiarl
A Murloc Raider
Join Date: Apr 2015
Posts: 6
Originally Posted by sirann View Post
--ensure the .ogg sound file is set to the correct sound file
else
--set the .ogg soundfile to a false file
end
end)[/highlight]
How do you set and check?
  Reply With Quote
04-28-15, 10:47 AM   #8
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
So basically, the only way I can think of doing this, is by tricking the game. The game is going to play that noise every time you hit a level. But, you don't want that. So we need to have the game play a "spoof" file, of nothing. So, you'll need an empty .ogg file that will be the exact name of the level up file. See:
Originally Posted by Phanx View Post

"Sound\\Interface\\Levelup.ogg"
"Sound\\Interface\\Levelup2.ogg"

Once you figure out which sound it is, you can create an empty text file with the same name, under the same directory structure:

World of Warcraft\Sound\Interface\Levelup.ogg

Create any folders that don't exist. The file can just be a plain text file, renamed with an .ogg extension.
This will disable the sound file the game will play. However, you still want to hear the noise every 10th level. So you could download the sound file, and have a PlaySoundFile(PATH\\TO\\YOUR\\SOUNDFILE\\THAT\\WILL\\ACTUALLY\\PLAY\\NOISE)

this code should do that, assuming you have the two spoof files, and the one file that will actually play the noise properly directed:
Lua Code:
  1. local levelchecktable = {}
  2.  
  3. for i = 10, 100, 10 do
  4.     levelchecktable[i] = true
  5. end
  6.  
  7. local f = CreateFrame('Frame', nil, UIParent)
  8. f:RegisterEvent('PLAYER_LEVEL_UP')
  9.  
  10. f:SetScript('OnEvent', function(self, event, ...)
  11.     if levelchecktable[UnitLevel('player')] then
  12.         PlaySoundFile(PATH\\TO\\YOUR\\SOUNDFILE\\THAT\\WILL\\ACTUALLY\\PLAY\\NOISE)
  13.     end
  14. end)

Last edited by sirann : 04-28-15 at 10:52 AM.
  Reply With Quote
04-28-15, 11:46 AM   #9
jandiarl
A Murloc Raider
Join Date: Apr 2015
Posts: 6
Originally Posted by jandiarl View Post
myrroddin, thanks for the reply. Though, I have tried that trick earlier and it does not work. I silenced the sound file and added a new file. The main sound gets permanently silenced and the new file does not play at all.
Thanks for the reply though, sirann. I guess it is not possible to do this, after all.
  Reply With Quote
04-28-15, 01:46 PM   #10
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
If the other sound wasn't playing, my guess was your implementation was incorrect. It's very doable to play a sound on an event, such as leveling up, or else how would certain boss modifications work! I believe my code should do what you need it to do, so long as you have the 2 spoof files to trick blizzards level hook, and the true file to play the actual sound.
  Reply With Quote
04-29-15, 12:20 AM   #11
jandiarl
A Murloc Raider
Join Date: Apr 2015
Posts: 6
Actually, I tested like this:

/run PlaySoundFile("path to file")

and

/run PlaySound("path to file")

I tried before and after silencing the sounds. The original files play fine without me adding muting files. They do not play with the muting files. Though, the new ones do not play at all. I cleared my cache too to make sure.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Trying to mute sounds on an event

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off