to your chat_row, template, but then the sound will be played everytime a message shows. And as we know, the screen refreshes every now and then, which means you would be hearing a sound continuously, for each and every message shown. So, what we need is a method to play that sound, only for the new messages and not for the older ones.
As for the sound when a user joins in, the only way I 've managed to do it, is by counting the users in the chat and if that number goes up, then play a sound. Still, it is not full-proof, since this info is taken from the session table. So if a user keeps going back and forth between the chat window and the main forums window, you end up hearing that sound again and again and again.