• Looping Non-WAV files in Garry's Mod
    9 replies, posted
Hi. I am trying to make a map in the Hammer Editor for Garry's Mod, where there is a speaker that should loop a song constantly. I know that this can be done with ambient_generic and loop cues created in GoldWave or similar software, but since WAV files are rather massive, I would like to loop an MP3 file within the map. MP3 files don't seem to be compatible with loop cues, so it got me thinking, since you can have a map file run a Lua file upon load, would it be possible to have a Lua file play a sound at a certain point in the map, and loop it depending on the length of the sound file, by using a timer? If so, there are a few things I would like confirmation on: I fear that if the player pauses the game in single player, the timer will stop but the music will not, so if they unpause, there will be a delay on the loop depending on how long the player paused the game. Is there any way to prevent this? When putting MP3 files on ambient_generic, the music will stop playing when the player is a certain distance away from it. Is this true here, too? Is it posisble to stop a sound played through x:EmitSound()? If not, is there a better function where this can be done? I know it sounds rather redundant, but I feel that the amount of space saved that can be used from disposing of WAV files and using MP3 files is way too significant to ignore. Thank you.
Single player, yes True, it will completely cancel and this is not fixable. Yes it is Entity/StopSound
it's completely against your point but you're far better off using a wav, source's mp3 support is dreadful
Thank you. It certainly seems like it. I was able to solve most of the problems aside from the problem where the sound just disappears when the player draws distance away from the entity. Oh well.
This has nothing to do with "mp3 support" though, the mp3 file format does not have support for looping markers like wav does. You definitely should be using wav for looping sounds, do not use timers, its just a horrible idea.
There still is a bug with mp3 being muted when dormant, with the sound still showing as playing.
I was able to actually have the sound loop in a reliable way using timers. Setting the channel of the sound to NPC voices, it will pause when the game pauses so the timer won't desync. I don't know if there are any ramifications of doing so. But even then, indeed, the bug where the sound completely disappears and refuses to play once the player leaves the maximum audible range, still persists, so I guess I will just have to settle for WAV files.
He also mentioned though the file is large, hence why he wants to use MP3. If it's a music loop of around 30mins, a decently quality WAV file can be upwards of 500mb. That file size is impractical if even possible within the limits of a source map (particularly if you want to upload to the workshop). Much better in the case of using extremely long sounds to use a LUA timer of some kind.
Don't make problems for yourself, so u would not run into them. Don't make your life harder, convert sounds to wav and give them some more bytes yay!
The sound disappears when becoming dormant, nothing else. If you only play on shitty optimized maps, you wont have problems
Sorry, you need to Log In to post a reply to this thread.