tm_sound
Free spatial audio for FiveM. It plays sounds from files and web links, in the world, on vehicles and on players, and it is a drop-in replacement for xsound and InteractSound: scripts written for either keep working without edits.
Everything is tuned in game from the tm_lib admin panel (/tmadmin). There is no config file.
Features
- Spatial audio. Heading based stereo panning and distance falloff, computed in the browser layer so the game thread stays idle.
- Entity sounds. A sound follows a networked entity, waits for it to stream in and resumes at the right point after it streams out.
- Acoustics. Sounds are muffled through walls, in other interiors and inside vehicles (raycast occlusion, all tunable).
- Mixer. Pitch, a three band EQ and a biquad filter per sound, fades in and out, with every value clamped on the server.
- Many sources. Audio files, HLS and DASH streams, YouTube, Vimeo, Twitch, Spotify and more (see Sources).
- Server tracked. Sounds started from the server are remembered, so a player who joins later hears what is playing at the right point.
- Routing buckets. A sound can belong to an instance and is only heard inside it.
- Streamer mode.
/streamermodemutes everything for one player.
Requirements
| Needs | Notes |
|---|---|
tm_lib | The Twilight Moon library: settings, the admin panel, notifications and locales. |
ox_lib | Installed next to tm_lib, which depends on it. tm_sound itself only uses tm_lib. |
| OneSync | Required for entity attached sounds. |
Install
- Put
tm_soundin your resources folder and start it aftertm_lib:
cfg
ensure ox_lib
ensure tm_lib
ensure tm_sound- Remove the original
xsoundandinteract-soundresources. tm_sound provides both names, so two resources would answer to the same export. - Put your InteractSound files in
tm_sound/sounds(see xsound and InteractSound). - Open the admin panel (
/tmadmin) and pick Sound to adjust anything.
A release already contains the built interface. If you build from source, run pnpm install and pnpm build in tm_sound/ui (see Development).
Quick start
lua
-- client: a sound for this player only
exports.tm_sound:PlayUrl('welcome', 'https://example.com/welcome.ogg', 0.5)
-- server: a sound at a position, heard by everyone nearby
exports.tm_sound:PlayUrlPos(-1, 'alarm', 'sounds/alarm.ogg', 1.0, vec3(-1037.0, -2737.0, 20.0), 40.0, true)
-- server: a sound on a vehicle, with a fade in
exports.tm_sound:Play({ source = -1, id = 'radio_' .. netId, url = url, volume = 0.6, entityId = netId, distance = 12.0, loop = true, fadeInMs = 1500 })Every export is also available with the first letter's case flipped: exports.tm_sound:playUrl(...) and exports.tm_sound:PlayUrl(...) are the same function.
Pages
| Page | What it covers |
|---|---|
| Client exports | Everything you can call from a client script. |
| Server exports | Everything you can call from a server script, including tracking, buckets and late joiners. |
| Sources | Which links play, and how file paths are found. |
| xsound and InteractSound | What is compatible and how to migrate. |
| Settings | Every setting in the admin panel. |
| Events | Local events you can listen to. |
| Development | Building the interface and how the pieces fit. |
Changelog
| Version | Notes |
|---|---|
| 0.1.0 | First release. Spatial audio, entity sounds, acoustics, mixer, routing buckets, xsound and InteractSound compatibility, settings in the admin panel. |