sfxr.lua


sfxr.lua is a pure Lua port of the sfxr game sound generator. It performs fast enough for short sounds or pregenerated longer ones.

Screenshot

This single-file library allows you to dynamically create retro sound effects based on game-defined parameters. It also comes with a demo application as shown above based on Löve Frames.

Usage example (plays a random sound on every keypress):

local sfxr = require("sfxr")

function love.keypressed(key, rep)
    local sound = sfxr.newSound()
    sound:randomize()
    sound:play()
end

It supports all 7 preset generators for Pickup/Coin, Laser/Shoot, Explosion, Power-Up, Hit/Hurt, Jump and Blip/Select sounds and also both a randomizing and a mutating function. It also has all parameters from the original synthesizer, including basic envelopes, frequency slides, vibrato, change, square duty sweeping, phaser effect, low and high pass filters and sweep repeating.

You can also design sounds with the demo application and safe them either in a Lua-based format or the binary format of the original sfxr. Both formats can be loaded too, of course.