• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to properly import a wav sound for unit?

Status
Not open for further replies.
Hey all, I find it frustrating, when I imported 2 sounds to replace in asoundset, and the unit does not make that sound when I click on it?
I found this thread Importing custom sounds for a unit but it doesn't help me much.

I used 'replace internal' sound.
My sound files are .wav ofc

Any solutions here?
Has anyone used custom soundset?
upload_2020-5-7_12-6-56.png
 
Level 12
Joined
Jan 30, 2020
Messages
875
Yon don't have to use wav or even flac.

I imported my custom sounds in mp3 format and it seems WE can use it without conversion as it is still in mp3 in the Asset manager, and the sound works perfectly ingame.
 
Level 12
Joined
Jan 30, 2020
Messages
875
Well you need to remember, as many people are confused about that, that WAV isn't really an audio format.
Like MKV or AVI for video, WAV is a container.

In theory, WAV files can contain an audio stream compressed with MP3, AC-3 and others, but the most common compression used in WAV is usually PCM.

Now I don't know if wc3 1.26 only supports PCM compression in WAV containers, but it might be worth testing with at least mp3.

If it only supports PCM, your only option, as far as I know, would be to change the sample rate down to something like 32kHz or 22kHz, depending on how much quality you find acceptable to lose.

Hope this helps.
 
Level 12
Joined
Jan 30, 2020
Messages
875
Any success ? I am asking in case someone else would have a similar issue with the same version of wc3, as you're not the only one to still be using 1.26.
 
Level 12
Joined
Jan 30, 2020
Messages
875
Ok, I suppose 1.26 only supports PCM compression then, have you tried to lower the sample rate to 22kHz in Audacity ?
 
Level 12
Joined
Jan 30, 2020
Messages
875
OK I really wish it will work without too much loss of quality, it should as I heard mp3 rate was only around 18kHz.
Good luck with your project !
 
Level 12
Joined
Jan 30, 2020
Messages
875
Well I indeed use imported mp3 to play some sounds ingame with triggers. I am not sure the way the game handles these has changed much with more recent patches or even Reforged. But I cannot check to see if mp3 is actually handled properly by the older versions.

Just for the record, I made 2 functions to handle the sounds. One is meant to be heard globally, the other, dedicated to add sound effects locally or for SFX.
The main differences are the channels, the position and the volume.

Lua:
function PlaySFXSound(str, x, y, v, d)
    local snd=CreateSound(str, false, true, true, 0, 0, "SpellsEAX")
    SetSoundDuration(snd, d)
    SetSoundChannel(snd, 0)
    SetSoundVolume(snd, v)
    SetSoundPosition(snd, x, y, 0)
    StartSound(snd)
    KillSoundWhenDone(snd)
end

function PlayGlobalSound(str, d)
    local snd=CreateSound(str, false, false, false, 10, 10, "DefaultEAXON")
    SetSoundDuration(snd, d)
    SetSoundChannel(snd, 8)
    SetSoundVolume(snd, -1)
    SetSoundPitch(snd, 1.0)
    StartSound(snd)
    KillSoundWhenDone(snd)
end

But replacing sounds from unit soundsets might not be possible, although I never support that word.
 
Level 12
Joined
Jan 30, 2020
Messages
875
Yes, I started to make the switch a couple of months ago. Lua is amazing, and annoying at the same time :)

So powerful but as variables have no type with it (only values have), it is sometimes a bit of a nightmare to trace errors ^^
 
Status
Not open for further replies.
Top