Customsounds work like sprays and have the same general limits. You can use them once every 10 seconds, based on the default decalfrequency. This can be changed on the server. The sound emits from the player using it, as if they were speaking.
To enable customsounds, all you need to do is add "cl_customsounds 1" to your autoexec.cfg file. You can also enter this in the console while in-game, though it will revert back to 0 when you restart TF2.
To create a customsound, you will need audio editing software. I recommend using Audacity, which is free, open source, and available on Windows, OS X, and Linux.
For more advanced audio modifications, such as loops, you can use Wavosaur.
FAQs:
How do I enable it?
cl_customsounds 1
How do I keep it enabled after restarting TF2?
autoexec.cfg
How do I use my customsound?
Bind "impulse 202" to any key. Make sure it's a key that isn't already in use.
Example: bind "j" "impulse 202"
Why does it only work sometimes?
There is a default delay of 10 seconds between uses, the same as sprays. It also shares its timer with sprays.
What is the max length of a customsound?
The audio can be as long as you want. The only limit is the max file size.
What is the max file size?
524288 bytes (512 KB)
Okay, but what is the max length you can fit in 512 KB?
I've managed to get 47 seconds by using 11025 bit rate with Microsoft ADPCM.
Example: http://www.mediafire.com/listen/ka04qj333bevw6h/because_of_you.wav
How can I make a customsound?
Using any audio editing software, export to a wav using any of the supported formats. The options required depend on the software you are using.
Where do I put my jingle.wav?
There are two options. One, use the default file name:
steamapps/common/Team Fortress 2/tf/custom/customsound/sound/player/jingle.wav
Or two, use the cl_soundfile command to name it something else:
cl_soundfile "sound/player/spy_loop.wav"
steamapps/common/Team Fortress 2/tf/custom/customsound/sound/player/spy_loop.wav
You can use cl_soundfile to change the folder name as well.
cl_soundfile "because_of_you.wav"
steamapps/common/Team Fortress 2/tf/custom/because_of_you.wav
How can I make my sound smaller?
Make it shorter, downmix to mono, use Microsoft ADPCM, and lower the bit rate. You should adjust these to get close to 512 KB without going over for the best quality.
How can I make my sound loop?
You must add cue points to it, see: https://developer.valvesoftware.com/wiki/Looping_a_Sound
I recommend using Wavosaur.
Example: http://www.mediafire.com/listen/oqt78n8cu85ia7r/spy_loop.wav
Which formats are supported?
The following formats have been tested and known to work:
Microsoft WAV:
Mono, Stereo, up to 7.1 probably works but is too large to test or use practically
Microsoft ADPCM
Unsigned 8 bit PCM
Signed 16 bit PCM
Bit rates: 11025, 22050, 44100
My customsound doesn't work!
Use my spy loop example and make sure it's in the correct folder with the correct file name. Once you get that working, try making your own.
Check the console for errors when you use "impulse 202".
Error: Failed to load sound "temp\38a11ec5.wav", file probably missing from disk/repository
Cause: The server rejected the file. It is probably an invalid format or too big.
Error: *** Invalid sample rate (4000) for sound 'temp\2c808d9e.wav'.
Cause: The sound file is not using a supported bit rate.
Error: Unsupported 24-bit wave file temp\934849aa.wav
Cause: The file format is not supported. Duh.