mirror of
https://github.com/nucular/sfxrlua.git
synced 2024-12-05 11:34:21 +00:00
Basic README and sfxr.lua structure
This commit is contained in:
parent
bcb4606b3c
commit
92c364c146
39
README.md
39
README.md
@ -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
31
sfxr.lua
Normal 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})
|
Loading…
Reference in New Issue
Block a user