Basic README and sfxr.lua structure

This commit is contained in:
nucular 2014-04-11 20:16:20 +02:00
parent bcb4606b3c
commit 92c364c146
2 changed files with 67 additions and 3 deletions

View File

@ -1,4 +1,37 @@
sfxrlua
=======
sfxr.lua
========
A port of the sfxr sound effect synthesizer to Lua, mainly for usage with the Löve2D framework
A port of the sfxr sound effect synthesizer to Lua, designed to be used
together with the *awesome* Löve2D game framework.
Example usage
-------------
These examples should play a randomly generated sound.
With Löve2D 0.9:
```lua
local sfxr = require("sfxr")
function love.load()
local sound = sfxr.new()
sound:randomize()
love.audio.newSource(sound:generateSoundData()):play()
end
```
With lao:
```lua
require("ao")
local sfxr = require("sfxr")
local driverId = ao.defaultDriverId()
local device = ao.openLive(driverId, {bits = 16, rate = 44100, channels = 1})
local sound = sfxr.new()
sound:randomize()
local buffer = sound:generateString()
device:play(buffer, #buffer)
```

31
sfxr.lua Normal file
View File

@ -0,0 +1,31 @@
-- sfxr.lua
-- original by Tomas Pettersson, ported to Lua by nucular
--[[
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]--
local sfxr = {}
local function new()
return setmetatable({}, vector)
end
return setmetatable({new = new},
{__call = function(_, ...) return new(...) end})