tSIP: local keypad DTMFs with sox

This script (for "on dial" event, added in tSIP 0.1.58) generates local audible DTMF feedback for keypad buttons and when entering number directly into main number edit.

local key = GetExecSourceId(); -- holds key code
local file
if key == string.byte("1",1) then
	file = '1.wav' 
elseif key == string.byte("2",1) then
	file = '2.wav'
elseif key == string.byte("3",1) then
	file = '3.wav'
elseif key == string.byte("4",1) then
	file = '4.wav'
elseif key == string.byte("5",1) then
	file = '5.wav'
elseif key == string.byte("6",1) then
	file = '6.wav'
elseif key == string.byte("7",1) then
	file = '7.wav'
elseif key == string.byte("8",1) then
	file = '8.wav'
elseif key == string.byte("9",1) then
	file = '9.wav'
elseif key == string.byte("0",1) then
	file = '0.wav'
elseif key == string.byte("*",1) then
	file = 'star.wav'
elseif key == string.byte("#",1) then
	file = 'hash.wav'
elseif key == string.byte("A",1) then
	file = 'A.wav'
elseif key == string.byte("B",1) then
	file = 'B.wav'
elseif key == string.byte("C",1) then
	file = 'C.wav'
elseif key == string.byte("D",1) then
	file = 'D.wav'
else
	-- print(string.format("on_dial.lua: no wav file to play for key code [%d]\n", key))
	return
end
-- add directory containing actual files
file = 'sox\\' .. file
-- specify audio device to be used, e.g. \"USB Phone\" or \"SPDIF Interface\"
local params = file .. " --buffer 1024 -t waveaudio \"Speakers\""
-- print(string.format("params = %s\n", params))
ShellExecute("open", "sox\\sox.exe", params, nil, 0)

Setup:

Back to howto list.