tSIP softphone: Lua GenerateTones()
Tone generator for transmitted audio was added in tSIP 0.02.01.02. This audio block is controlled by Lua GenerateTones() function.
Tone generator is able to generate up to 4 sine waves at the same time, each one with separate amplitude and frequency setting. Sum of sine waves is saturated. Tone generator is placed before softvol module (software volume control sliders) in transmit chain and replaces "regular" audio source when is activated.
Following example script generates tones during the call when button #45 or button #46 (these are two first buttons from third console column) is pressed (held down). Buttons might be configured as "Disabled", script must be placed in /scripts subdirectory and assigned to "on button mouse up/down" scripting event in settings.
-- Determining event type and id (e.g. button id) that triggered script -- see: enum ScriptSource local execSourceType = GetExecSourceType() if execSourceType ~= 16 then -- button print(string.format("Invalid script trigger source (%d) - must be button up/down\n", execSourceType)) return end local btnId = GetExecSourceId() local mouseDown = GetButtonMouseDown(btnId) if btnId == 45 then if mouseDown == 1 then -- GenerateTones() takes up 4 pairs of amplitude + frequency -- amplitude is taken as fraction of full-scale (FS) print("Generate 1000 Hz at 0.2 FS\n") GenerateTones(0.2, 1000.0) else -- no parameters or amplitude = 0 => end tones print("Stop tones\n") GenerateTones() end elseif btnId == 46 then if mouseDown == 1 then print("Generate 1000 Hz at 0.2 FS + 3000 Hz at 0.1 FS\n") GenerateTones(0.2, 1000, 0.1, 3000) else print("Stop tones\n") GenerateTones() end end
Back to howto list