sgstream/sound.lua.example
2024-05-27 20:26:12 +05:00

39 lines
819 B
Plaintext

local sg = require "soundgen"
sg=(function(sg)
local obj = setmetatable({},sg)
obj.__index = obj
obj.proto = obj
-- custom methods here
return obj
end)(sg)
-- throw a bunch of random things together
local snd = sg:sine():freq(250)
:pm(sg:sine():freq(250/6):fade(0,0.3):amp(1/250),-1,1)
snd=snd:amp(0.8):freq(2):add(
sg:sine():freq(250)
:pm(sg:sine():freq(250),0,1/250):amp(0.3))
snd=snd:freq(1)
:pm(snd:phase(0):fade(0.3,0.0),0,0.001)
:freq(0.5)
-- fade in, fade out, reverb
snd=snd
:fade(0.01,0)
:fade(0,0.3)
:amp(0.5)
:reverb(4,1/250*30,0.4)
-- compose
local ssnd = sg.add(
snd:freq(1):phase(0),
snd:freq(0.99):phase(-0.5),
snd:freq(1.01):phase(-1),
snd:freq(1):phase(-1.4),
snd:freq(1.1):phase(-1.8)
):clamp(0,2.1,true):loop():amp(1)
return
ssnd, -- sound
1/250*6 -- oscillogram lookaround