Esc to clear, Enter to open the best match, click an export to open it in its page
Voice

Voice for other resources

Your resource can use voice (a call, an intercom, a dispatch channel, a bugged room) without knowing which voice system runs. Never call one by name: Whip.voice, in @whip_core/lib/satellite.lua, calls whichever is running.

A line is a set of players who hear each other wherever they are, through a sound you choose: with their talk key (a 'voice' line) or the radio key ('radio'). The people around them still hear them. A line is yours, and closes when your resource stops. Everything here is server side, except asking which voice system runs. Recordings played on a line or from an NPC are in whip_voice/docs/LINES.md.

Lines

Whip.voice(name, …) · Whip.voiceSystem()SERVER CLIENT#

Whip.voice calls one of the running voice system's exports (below) and returns what it returns, or false, 'no voice system is running'. Whip.voiceSystem() returns which voice system runs (GetVoiceSystem's result), or false.

Returns: the export's result, or false, reason
local lineId, why = Whip.voice('OpenLine', { members = { visitor, guard } })   -- an intercom
if not lineId then return false, why end
OpenLine(spec)SERVER#

Opens a line: Whip.voice('OpenLine', spec). Members are players with a character loaded; one not in voice yet is linked once they are.

FieldTypeDescription
membersnumber[]Server ids, at most 32. More later with AddLineMember
trackstring?'voice' (default: the talk key) or 'radio' (the radio key)
recipetable|string?How it sounds at the far end: a list of sound blocks, or a name from RegisterSound. None: the plain voice
speakerRangenumber?1-30 m (default 8): how far a member's device on speaker carries
pickupboolean?On speaker, the people near the device are heard on the line too, where the voice system has the pickup feature (whip_voice does)
qualitytable?{ clear = metres, range = metres }: worse with distance, gone past range
sameWorldboolean?Only members in the same routing bucket hear each other
minMembersnumber?Fewer members than this (default 2) and the line closes by itself
onEndfunction?(lineId, why): the line closed by itself ('empty'). Not called when you close it
onLeavefunction?(lineId, src, why): a member went ('left', 'logout', 'removed')
Returns: the line's id (yours to keep), or false, reason
-- A call between two players, sounding like a phone. With minMembers 2 it closes
-- by itself when either leaves or logs out.
local lineId, why = Whip.voice('OpenLine', {
    members = { caller, callee }, pickup = true, minMembers = 2,
    recipe  = { { 'band', low = 300, high = 3400 }, { 'compress', threshold = -24, ratio = 4 } },
    onEnd   = function(id, reason) print(('call %s over: %s'):format(id, reason)) end,
})
The other line callsSERVER#

All through Whip.voice, and only on your own lines.

CallDoes
CloseLine(lineId)Everyone on it lets go at once. A line already closed returns true
AddLineMember(lineId, src) · RemoveLineMember(lineId, src)Puts a player on it, or takes one off
SetLineSpeaker(lineId, src, on)That member's device plays the line out loud to the people near it
SetLineMuted(lineId, src, on)The line stops hearing that member. The people near them still do
SetLineRecipe(lineId, recipe)A new sound for the line
GetLine(lineId){ id, track, members = { [src] = { speaker, muted } }, pickup, sameWorld, speakerRange, minMembers }
RegisterSound(name, recipe)Keeps a recipe under a name (letters, digits, -, _) for recipe = name. Returns its full name, '<your_resource>:<name>'
IsVoiceReady(src)Whether that player is connected to voice
Returns: true (GetLine: the table; RegisterSound: the name), or false, reason
Whip.voice('SetLineSpeaker', lineId, callee, true)   -- the callee's phone on speaker
Whip.voice('SetLineMuted', lineId, caller, true)     -- the far side stops hearing the caller
Whip.voice('CloseLine', lineId)                         -- hang up

Sound recipes#

A recipe is a list of blocks, in order, each with its settings: { { 'band', low = 300, high = 3400 }, { 'drive', k = 1.5 } }. It's data, never code, checked before it plays: a setting left out takes its default, a number out of range is brought into it, and an unknown block is refused. At most 24 blocks, 4 of them ones that make sound of their own (noise, breakup, radio, hum, chorus, vibrato, tremolo, ringmod, reverb). whip_voice plays every block.

BlockSettings (default)Does
gaindb (0)Louder or quieter
lowpass · highpasshz (3000 · 300), q (0.7)Cuts the highs above, or the lows below, hz
bandpass · notchhz (1200 · 1000), q (0.7)Only a band around hz, or that band taken out
bandlow (300), high (3400), qKeeps low to high: a telephone
peak · lowshelf · highshelfhz, db (0), qBoosts or cuts a band, the lows, or the highs
drivek (2.5), oversampleSoft clipping: grit, harder the bigger k
crushsteps (32)A digital edge
compressthreshold (-24), ratio (4), knee, attack, releaseLoud and quiet squeezed together, like a phone line
noisekind (white, pink, brown), level (0.02), hz, qA hiss under the voice, only while they talk
humhz (50), level (0.02)A mains hum under the voice, only while they talk
breakupstatic (0.06)Drops out more the weaker the line (its quality), with static in the gaps
beepsup, down, down2 (Hz), levelA beep as they start and stop talking
panto (-1 left to 1 right)Towards one ear
echo · reverbtime, feedback, mix · size, mixRepeats, or a room around the device
chorus · vibrato · tremolorate, depth (mix)A wavering copy, a wavering pitch, a pulsing loudness
ringmodhz (50), mix (1)A robot
radiostatic (0.06), distortion (1)whip_voice's walkie-talkie, breaking up with distance

Voice systems

GetVoiceSystem()SERVER CLIENT#

Which voice system runs, or false when none does. Offer only what its features say it can do. On the client, the local event whip_core:voice:systemChanged ({ resource, label, features }, all nil when none runs) says when it changes.

Featurewhip_voiceMeans
linestrueThe line calls above work
speakertrueSetLineSpeaker plays a line out loud near a device
pickuptrueOn speaker, the people near the device are heard on the line
qualitytrueA line's quality breaks up with distance
sounds'full''full': every sound block played. 'basic': a phone or radio filter at most
Returns: { resource, label, features }, or false
local v = Whip.voiceSystem()
if v and not v.features.pickup then
    -- on speaker, only the people near hear the other side: say so in your UI
end
RegisterVoiceSystem(info)SERVER#

For a voice resource of your own: makes it the voice system. One at a time: refused, naming the other, while another runs; let go when your resource stops. A voice system handles the line calls above, with the same arguments, registers the radio and megaphone items, turns whip_core:voice:rangeChanged (the Z key) into metres, and lights the HUD with SetVoiceTalking(talking, mode?).

Returns: true, or false, reason
Whip.register(function()
    local ok, why = exports.whip_core:RegisterVoiceSystem({
        label = 'my_voice',
        features = { lines = true, speaker = true, pickup = false, quality = false, sounds = 'basic' },
    })
    if not ok then print('voice stays off: ' .. why) return end
    -- ... the rest of your registrations
end)