Skip to content

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. /streamermode mutes everything for one player.

Requirements ​

NeedsNotes
tm_libThe Twilight Moon library: settings, the admin panel, notifications and locales.
ox_libInstalled next to tm_lib, which depends on it. tm_sound itself only uses tm_lib.
OneSyncRequired for entity attached sounds.

Install ​

  1. Put tm_sound in your resources folder and start it after tm_lib:
cfg
ensure ox_lib
ensure tm_lib
ensure tm_sound
  1. Remove the original xsound and interact-sound resources. tm_sound provides both names, so two resources would answer to the same export.
  2. Put your InteractSound files in tm_sound/sounds (see xsound and InteractSound).
  3. 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 ​

PageWhat it covers
Client exportsEverything you can call from a client script.
Server exportsEverything you can call from a server script, including tracking, buckets and late joiners.
SourcesWhich links play, and how file paths are found.
xsound and InteractSoundWhat is compatible and how to migrate.
SettingsEvery setting in the admin panel.
EventsLocal events you can listen to.
DevelopmentBuilding the interface and how the pieces fit.

Changelog ​

VersionNotes
0.1.1The console prefix reads TM Sound and uses the Twilight Moon colors.
0.1.0First release. Spatial audio, entity sounds, acoustics, mixer, routing buckets, xsound and InteractSound compatibility, settings in the admin panel.