EDIT: neither of these work, see
this post for one that does
If you replaced the sound using the filepath trick (World of Warcraft\Sound etc):
Lua Code:
local f=CreateFrame('frame')
f:SetScript('OnEvent',function(self,_,handle)
if handle==self.handle then
SetCVar('Sound_MasterVolume',self.master)
end
end)
f:RegisterEvent('SOUNDKIT_FINISHED')
hooksecurefunc('PlaySound',function(id,_,_,_,_,_,_,own)
if id==8960 and not own then
local played,handle=PlaySound(64,'Master',false)
if played and handle then
StopSound(handle) StopSound(handle-1)
played,handle=PlaySound(8960,'Master',true,true,nil,nil,nil,true)
if played and handle then
f.handle=handle
f.master=GetCVar('Sound_MasterVolume')
SetCVar('Sound_MasterVolume',1)
end
end
end
end)
If your sound is just in a folder (for example, Interface\AddOns\YourAddOn\sound.ogg):
Lua Code:
local f=CreateFrame('frame')
f:SetScript('OnEvent',function(self,_,handle)
if handle==self.handle then
SetCVar('Sound_MasterVolume',self.master)
end
end)
f:RegisterEvent('SOUNDKIT_FINISHED')
hooksecurefunc('PlaySound',function(id)
if id==8960 then
local played,handle=PlaySound(64,'Master',false)
if played and handle then
StopSound(handle) StopSound(handle-1)
played,handle=PlaySoundFile('Interface\\path\\to\\sound.ogg','Master',true,true)
if played and handle then
f.handle=handle
f.master=GetCVar('Sound_MasterVolume')
SetCVar('Sound_MasterVolume',1)
end
end
end
end)
Just in case you aren't sure what to do with this, go to
http://addon.bool.no, name this whatever you want at the top, copy one of these pieces of code into the big box, then download and install like any other addon.