2
0

Sound.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. class "Sound"
  2. function Sound:Sound(...)
  3. for k,v in pairs(arg) do
  4. if type(v) == "table" then
  5. if v.__ptr ~= nil then
  6. arg[k] = v.__ptr
  7. end
  8. end
  9. end
  10. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  11. self.__ptr = Polycore.Sound(unpack(arg))
  12. end
  13. end
  14. function Sound:Play(once)
  15. local retVal = Polycore.Sound_Play(self.__ptr, once)
  16. end
  17. function Sound:Stop()
  18. local retVal = Polycore.Sound_Stop(self.__ptr)
  19. end
  20. function Sound:loadWAV(fileName)
  21. local retVal = Polycore.Sound_loadWAV(self.__ptr, fileName)
  22. if Polycore.__ptr_lookup[retVal] ~= nil then
  23. return Polycore.__ptr_lookup[retVal]
  24. else
  25. Polycore.__ptr_lookup[retVal] = ALuint("__skip_ptr__")
  26. Polycore.__ptr_lookup[retVal].__ptr = retVal
  27. return Polycore.__ptr_lookup[retVal]
  28. end
  29. end
  30. function Sound:loadOGG(fileName)
  31. local retVal = Polycore.Sound_loadOGG(self.__ptr, fileName)
  32. if Polycore.__ptr_lookup[retVal] ~= nil then
  33. return Polycore.__ptr_lookup[retVal]
  34. else
  35. Polycore.__ptr_lookup[retVal] = ALuint("__skip_ptr__")
  36. Polycore.__ptr_lookup[retVal].__ptr = retVal
  37. return Polycore.__ptr_lookup[retVal]
  38. end
  39. end
  40. function Sound:GenSource(buffer)
  41. local retVal = Polycore.Sound_GenSource(self.__ptr, buffer.__ptr)
  42. if Polycore.__ptr_lookup[retVal] ~= nil then
  43. return Polycore.__ptr_lookup[retVal]
  44. else
  45. Polycore.__ptr_lookup[retVal] = ALuint("__skip_ptr__")
  46. Polycore.__ptr_lookup[retVal].__ptr = retVal
  47. return Polycore.__ptr_lookup[retVal]
  48. end
  49. end
  50. function Sound:checkALError(operation)
  51. local retVal = Polycore.Sound_checkALError(self.__ptr, operation)
  52. end
  53. function Sound:soundError(err)
  54. local retVal = Polycore.Sound_soundError(self.__ptr, err)
  55. end
  56. function Sound:soundCheck(result, err)
  57. local retVal = Polycore.Sound_soundCheck(self.__ptr, result, err)
  58. end