Sound.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. Polycore.__ptr_lookup[self.__ptr] = self
  13. end
  14. end
  15. function Sound:Play(once)
  16. local retVal = Polycore.Sound_Play(self.__ptr, once)
  17. end
  18. function Sound:Stop()
  19. local retVal = Polycore.Sound_Stop(self.__ptr)
  20. end
  21. function Sound:loadWAV(fileName)
  22. local retVal = Polycore.Sound_loadWAV(self.__ptr, fileName)
  23. if Polycore.__ptr_lookup[retVal] ~= nil then
  24. return Polycore.__ptr_lookup[retVal]
  25. else
  26. Polycore.__ptr_lookup[retVal] = ALuint("__skip_ptr__")
  27. Polycore.__ptr_lookup[retVal].__ptr = retVal
  28. return Polycore.__ptr_lookup[retVal]
  29. end
  30. end
  31. function Sound:loadOGG(fileName)
  32. local retVal = Polycore.Sound_loadOGG(self.__ptr, fileName)
  33. if Polycore.__ptr_lookup[retVal] ~= nil then
  34. return Polycore.__ptr_lookup[retVal]
  35. else
  36. Polycore.__ptr_lookup[retVal] = ALuint("__skip_ptr__")
  37. Polycore.__ptr_lookup[retVal].__ptr = retVal
  38. return Polycore.__ptr_lookup[retVal]
  39. end
  40. end
  41. function Sound:GenSource(buffer)
  42. local retVal = Polycore.Sound_GenSource(self.__ptr, buffer.__ptr)
  43. if Polycore.__ptr_lookup[retVal] ~= nil then
  44. return Polycore.__ptr_lookup[retVal]
  45. else
  46. Polycore.__ptr_lookup[retVal] = ALuint("__skip_ptr__")
  47. Polycore.__ptr_lookup[retVal].__ptr = retVal
  48. return Polycore.__ptr_lookup[retVal]
  49. end
  50. end
  51. function Sound:checkALError(operation)
  52. local retVal = Polycore.Sound_checkALError(self.__ptr, operation)
  53. end
  54. function Sound:soundError(err)
  55. local retVal = Polycore.Sound_soundError(self.__ptr, err)
  56. end
  57. function Sound:soundCheck(result, err)
  58. local retVal = Polycore.Sound_soundCheck(self.__ptr, result, err)
  59. end