Page 1 of 1

sound help please.

Posted: Sun Sep 01, 2013 4:18 am
by Ryeath_Greystalk
I'm trying to get my custom gong to work in game but I am having an issue with the sound.

I have a define sound in my .lua file
SpoilerShow
defineSound{
name = "gong_hit",
filename = "mod_assets/RG_assets/RG_gong/sounds/gong.wav",
loop = false,
volume = 2,
minDistance = 2,
maxDistance = 10,
}


Then I put a lua script activated by a wall button that opens a door and playSound("gong_hit"). That works ok, door opens and sound plays fine.
In my gong definition I have a function call onDamage which calls the lua script and again the door opens and the gong sound plays.
SpoilerShow
defineObject{
name = "RG_gong",
class = "Blockage",
model = "mod_assets/RG_assets/RG_gong/models/RG_gong.fbx",
brokenModel = "mod_assets/RG_assets/RG_gong/models/RG_gong.fbx",
placement = "floor",
health = 300000,
evasion = -10000,
-- hitSound = "barrel_hit",
-- hitEffect = "hit_wood",
onDamage = function(self)
gong.soundGong()
end,
editorIcon = 56,
}
When I take out the dashes in front of the hitSound parameter (and edit out the playSound() in the lua script) then the barrel_hit sound plays whenever the party hits the the gong.

Everything is great to this point. But when I change the hitSound to hitSound = "gong_hit" as soon as I hit the gong the game crashes to desktop with no error report generated. I have gone over my typing a dozen times looking for something but can't find anything.

In summary gong_hit sound works in a playSound() lua script, gong calls the function when hit, gong plays stock sound ok but when it tries to play the custom sound (which works in a playSound() script) game crashes without error report.

Any ideas?

Re: sound help please.

Posted: Sun Sep 01, 2013 4:30 am
by JohnWordsworth
One thing to check is the format of the Wav file to be played. I know that Grimrock can be very picky with audio files. I've had success with 44,100 Hz, Mono saved as a 16-bit Wav file. I don't know anything about the hitSound, but I would just do a quick sanity check to make sure the file format is correct.

Other things that might help... In your mod's "init.lua" file, make sure that the line import "mod_assets/scripts/sounds.lua" comes before "mod_assets/scripts/objects.lua". Not 100% sure of the names off the top of my head, and I can't imagine that it would matter - but just incase it does, this makes sure the relevant defineSound comes before the defineObject for your object.

No other ideas immediately - let me know how you get on with the above!

Re: sound help please.

Posted: Sun Sep 01, 2013 5:10 am
by Ryeath_Greystalk
Downloaded Audacity and checked and it was a stereo file. Changed it to mono and it's working now.

Re: sound help please.

Posted: Sun Sep 01, 2013 6:41 am
by JohnWordsworth
Brilliant! For future notice, if anyone else if making wav files for Grimrock, here's a Guide on the Grimwiki to making custom sounds.