I don't know how exactly GK does it, but the best way is to either put it in the animation (GANI) or show an animation.
PHP Code:
// play a sound
setAni("myflute", "mysound3.wav");
Then in the animation, put in a sound and put "PARAM1" for the file.
You can also make an empty GANI with just a sound in it, and use showani, but I don't recommend that.