Re: Pure Lua port of the sfxr sound generator
Posted: Thu Jun 05, 2014 8:54 pm
Bumping a bit, also I added functions for generating a simple Lua file from the sound parameters and for loading it. You can use it like this if you want to work with the Löve file API instead of the basic Lua one:
If you pass a second argument to sound:save(), it will generate a somewhat smaller file because no indention and linebreaks are added.
Here are the results of these examples, compressed and uncompressed:
Code: Select all
local sound = sfxr.newSound()
sound:randomize()
local f = love.filesystem.newFile("sound.lua")
f:open("w")
sound:save(f)
f:flush()
f:close()
Code: Select all
local sound = sfxr.newSound()
local f = love.filesystem.newFile("sound.lua")
f:open("r")
sound:load(f)
f:close()
sound:play()
Here are the results of these examples, compressed and uncompressed:
Code: Select all
local
s={
change={
amount=0.39114666484126;
speed=0.53098955685005;
};
vibrato={
delay=-0.94992868273876;
depth=-0.024465061542777;
speed=0.84200208799958;
};
frequency={
slide=-0.027968131846831;
limit=0;
start=0.23970054770736;
dslide=0.59757475861064;
};
phaser={
sweep=0.4304590939705;
offset=-0.070899490398386;
};
duty={
ratio=-0.3660692363753;
sweep=-0.5988394794907;
};
repeatspeed=0.62650828993079;
highpass={
sweep=-0.19473133535069;
cutoff=0.6262447349085;
};
envelope={
attack=0.044302194827103;
punch=0.011362092672399;
decay=-0.55449086076159;
sustain=0.47922909089777;
};
volume={
};
lowpass={
resonance=-0.0013938250035848;
sweep=2.243246748532e-006;
cutoff=0.67252042718807;
};
};
return s, "0.0"
Code: Select all
local s={change={amount=0.39114666484126;speed=0.53098955685005;};vibrato={delay=-0.94992868273876;depth=-0.024465061542777;speed=0.84200208799958;};frequency={slide=-0.027968131846831;limit=0;start=0.23970054770736;dslide=0.59757475861064;};phaser={sweep=0.4304590939705;offset=-0.070899490398386;};duty={ratio=-0.3660692363753;sweep=-0.5988394794907;};repeatspeed=0.62650828993079;highpass={sweep=-0.19473133535069;cutoff=0.6262447349085;};envelope={attack=0.044302194827103;punch=0.011362092672399;decay=-0.55449086076159;sustain=0.47922909089777;};volume={};lowpass={resonance=-0.0013938250035848;sweep=2.243246748532e-006;cutoff=0.67252042718807;};};
return s, "0.0"