https://github.com/sonoro1234/luajit-sdl2
autogenerated LuaJIT bindings for SDL2 with threads and audio
https://github.com/sonoro1234/luajit-sdl2
audio luajit sdl2 threads
Last synced: 9 months ago
JSON representation
autogenerated LuaJIT bindings for SDL2 with threads and audio
- Host: GitHub
- URL: https://github.com/sonoro1234/luajit-sdl2
- Owner: sonoro1234
- Created: 2018-11-19T13:03:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-15T15:21:21.000Z (over 1 year ago)
- Last Synced: 2025-04-30T12:21:19.326Z (11 months ago)
- Topics: audio, luajit, sdl2, threads
- Language: Lua
- Homepage:
- Size: 844 KB
- Stars: 31
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LuaJIT-SDL2
autogenerated LuaJIT bindings for SDL2 2.30.3
if interested in SDL3 there is also https://github.com/sonoro1234/LuaJIT-SDL3
Set CMake LUAJIT_BIN to the LuaJIT directory for installing.
See test folder examples for usage
luajit-async (taken from https://github.com/sonoro1234/luajit-async) needs to be 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.
All above can be found at https://github.com/sonoro1234/anima
# sdlAudioPlayer
simple interface for playing sndfile files from disk
```lua
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()
```