项目作者: sonoro1234

项目描述 :
autogenerated LuaJIT bindings for SDL2 with threads and audio
高级语言: Lua
项目地址: git://github.com/sonoro1234/LuaJIT-SDL2.git
创建时间: 2018-11-19T13:03:18Z
项目社区:https://github.com/sonoro1234/LuaJIT-SDL2

开源协议:

下载


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

  1. local sndf = require"LuaJIT-libsndfile"
  2. local AudioPlayer = require"sdlAudioPlayer"
  3. --copy specs from file
  4. local info = sndf.get_info(filename)
  5. local audioplayer,err = AudioPlayer({
  6. --device = device_name, --nil as device
  7. freq = info.samplerate,
  8. format = sdl.AUDIO_S16SYS,
  9. channels = info.channels,
  10. samples = 1024})
  11. --insert several files
  12. for i=1,10 do
  13. --filename, level, timeoffset
  14. audioplayer:insert(filename,(11-i)*0.1,i*0.6)
  15. end
  16. --show them
  17. for node in audioplayer:nodes() do
  18. print("node",node.sf)
  19. end
  20. --play them 7 secs
  21. audioplayer:start()
  22. sdl.Delay(7000);
  23. --close
  24. audioplayer:close()