#!/usr/bin/env lua --- Transforms a code into a list of file to stitch ---@param code string the code to parse ---@return table local function parse(code) if type(code) ~= "string" then error("parse expects a string") end local filemap = { ["1"] = "1.wav", ["2"] = "2.wav", ["3"] = "3.wav", ["4"] = "4.wav", ["5"] = "5.wav", ["6"] = "6.wav", ["7"] = "7.wav", ["8"] = "8.wav", ["9"] = "9.wav", ["0"] = "0.wav", ["*"] = "Star.wav", ["#"] = "Octothorpe.wav", ["A"] = "A.wav", ["B"] = "B.wav", ["C"] = "C.wav", ["D"] = "D.wav", ["-"] = "skip.wav", } local seq = {} for i = 1, #code do table.insert(seq, filemap[code:sub(i, i)] or filemap["-"]) end return seq end local args = {...} local i = 1 while i <= #args do local code = args[i] local out = args[i+1] or "out.wav" local sequence = parse(code) local list = io.open(out .. ".filelist", "w") if not list then io.stderr:write("Cannot open `" .. out .. ".filelist\n") io.stderr:write("Abborting\n") os.exit(1) end for _, v in ipairs(sequence) do list:write("file '" .. v .. "'\n") end list:close() os.execute("ffmpeg -f concat -safe 0 -i " .. out .. ".filelist -c copy " .. out) i = i + 2 end