autogenerated LuaJIT bindings for SDL2 with threads and audio
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SDL @ a2560fd
generator
luajit-async @ 819e85d
test
.gitmodules
CMakeLists.txt
README.md
sdl2_ffi.lua
sdlAudioPlayer.lua

README.md

LuaJIT-SDL2

autogenerated LuaJIT bindings for SDL2 2.0.9

Set CMake LUAJIT_BIN to the LuaJIT directory for installing.

See test folder examples for usage

luajit-async (taken from https://github.com/ColonelThirtyTwo/luajit-async) will be also installed for providing lua functions that can be called from another thread (sdl.MakeAudioCallback and sdl.MakeThreadFunc)

This repo is used in https://github.com/sonoro1234/LuaJIT-ImGui where you get very usefull GUI widgets.

sdlAudioPlayer

simple interface for playing sndfile files from disk

local sndf = require"LuaJIT-libsndfile"
local AudioPlayer = require"sdlAudioPlayer"

--copy specs from file
local info = sndf.get_info(filename)
local audioplayer,err = AudioPlayer({
    --device = device_name, --nil as device
    freq = info.samplerate, 
    format = sdl.AUDIO_S16SYS,
    channels = info.channels, 
    samples = 1024})

--insert several files
for i=1,10 do
	--filename, level, timeoffset
	audioplayer:insert(filename,(11-i)*0.1,i*0.6)
end
--show them
for node in audioplayer:nodes() do
    print("node",node.sf)
end

--play them 7 secs
audioplayer:start()
sdl.Delay(7000);
--close
audioplayer:close()