allows you to make sounds of robot heads and horns
you can also run loop effects that will simulate engine sounds
with betterAPI, you can load ANY SOUND AT ALL!
the maximum number of audio effects is 32
the maximum number of loop effects is 32
number of simultaneously loaded samples: 32
component name - synthesizer


wave types (works only with betterAPI):


new sound api:


sound api (it is outdated, it is better not to use it):


loop api:


sample api (works only with betterAPI):


standard samples embedded in the mod (for load via synthesizer.loadSampleFromSComputers):


methods for unrestricted speaker from the power toys addon:

            --the sample api requires a betterAPI to work!
--https://steamcommunity.com/sharedfiles/filedetails/?id=3177944610

local synthesizer = getComponent("synthesizer")

synthesizer.loadSampleFromURL(1, "https://raw.githubusercontent.com/igorkll/trashfolder/refs/heads/main/sound/1.mp3")
synthesizer.loopSample(1, true)
synthesizer.setSampleVolume(1, 0.5)
synthesizer.startSample(1)

function callback_loop()
    if _endtick then
        synthesizer.loopSample(1, false)
        synthesizer.stopSample(1)
        return
    end
end
        
            --the sample api requires a betterAPI to work!
--https://steamcommunity.com/sharedfiles/filedetails/?id=3177944610

local timerhost = require("timer").createHost()
local synthesizer = getComponent("synthesizer")

synthesizer.loadSampleFromTTS(1, "hello world")
synthesizer.loadSampleFromTTS(2, "danger")
synthesizer.loadSampleFromTTS(3, "evacuation")

local timer = timerhost:createTimer(40, false, function ()
    synthesizer.startSample(1)

    local timer = timerhost:createTimer(80, false, function ()
        synthesizer.startSample(2)

        local timer = timerhost:createTimer(40, true, function ()
            synthesizer.startSample(3)
        end)
        timer:reset()
        timer:setEnabled(true)
    end)
    timer:reset()
    timer:setEnabled(true)
end)
timer:reset()
timer:setEnabled(true)

function callback_loop()
    if _endtick then
        synthesizer.stopSample(1)
        synthesizer.stopSample(2)
        synthesizer.stopSample(3)
        return
    end

    timerhost:tick()
end
        
            local utils = require("utils")
local synthesizer = getComponent("synthesizer")

function onTick(dt)
    local sin = math.sin(math.rad(getTick() * 4))
    synthesizer.ballBeep(utils.map(sin, -1, 1, 25, 40), 5)
end

function onStop()
    synthesizer.stop()
end

_enableCallbacks = true
        
            synthesizers = getComponents("synthesizer")

function calls(...)
    local args = {...}
    for i, cmp in ipairs(synthesizers) do
        cmp[args[1] ] (unpack(args, 2))
    end
end

calls("stop")

tick = 1
function callback_loop()
    if _endtick then
        calls("stop")
    else
        currentBeep = tick % 40 > 20

        if currentBeep ~= oldBeep then
            calls("stop")
            calls("clear")
            if currentBeep then
                calls("addBeep", 3, 0.5, 1, 40)
            else
                calls("addBeep", 3, 1, 1, 40)
            end
            calls("flush")
        end
        oldBeep = currentBeep
    end
    tick = tick + 1
end
        
            --the sample api requires a betterAPI to work!
--https://steamcommunity.com/sharedfiles/filedetails/?id=3177944610
--https://igorkll.github.io/synthesizer.html

local timerhost = require("timer").createHost()
local synthesizer = getComponent("synthesizer")

synthesizer.loadSampleFromTTS(1, "hello world")
synthesizer.loadSampleFromTTS(2, "danger")
synthesizer.loadSampleFromTTS(3, "evacuation")

local timer = timerhost:createTimer(40, false, function ()
    synthesizer.startSample(1)

    local timer = timerhost:createTimer(80, false, function ()
        synthesizer.startSample(2)

        local timer = timerhost:createTimer(40, true, function ()
            synthesizer.startSample(3)
        end)
        timer:reset()
        timer:setEnabled(true)
    end)
    timer:reset()
    timer:setEnabled(true)
end)
timer:reset()
timer:setEnabled(true)

function callback_loop()
    timerhost:tick()
end