Sound.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. class "Sound"
  2. function Sound:Sound(...)
  3. local arg = {...}
  4. for k,v in pairs(arg) do
  5. if type(v) == "table" then
  6. if v.__ptr ~= nil then
  7. arg[k] = v.__ptr
  8. end
  9. end
  10. end
  11. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  12. self.__ptr = Polycode.Sound(unpack(arg))
  13. end
  14. end
  15. function Sound:getSampleAsNumber(offset, channel, position, orientation)
  16. local retVal = Polycode.Sound_getSampleAsNumber(self.__ptr, offset, channel, position.__ptr, orientation.__ptr)
  17. return retVal
  18. end
  19. function Sound:Play(loop, restartSound)
  20. local retVal = Polycode.Sound_Play(self.__ptr, loop, restartSound)
  21. end
  22. function Sound:Stop()
  23. local retVal = Polycode.Sound_Stop(self.__ptr)
  24. end
  25. function Sound:setVolume(newVolume)
  26. local retVal = Polycode.Sound_setVolume(self.__ptr, newVolume)
  27. end
  28. function Sound:getVolume()
  29. local retVal = Polycode.Sound_getVolume(self.__ptr)
  30. return retVal
  31. end
  32. function Sound:setPitch(newPitch)
  33. local retVal = Polycode.Sound_setPitch(self.__ptr, newPitch)
  34. end
  35. function Sound:getPitch()
  36. local retVal = Polycode.Sound_getPitch(self.__ptr)
  37. return retVal
  38. end
  39. function Sound:isPlaying()
  40. local retVal = Polycode.Sound_isPlaying(self.__ptr)
  41. return retVal
  42. end
  43. function Sound:isLooped()
  44. local retVal = Polycode.Sound_isLooped(self.__ptr)
  45. return retVal
  46. end
  47. function Sound:setIsPositional(isPositional)
  48. local retVal = Polycode.Sound_setIsPositional(self.__ptr, isPositional)
  49. end
  50. function Sound:setSoundPosition(position)
  51. local retVal = Polycode.Sound_setSoundPosition(self.__ptr, position.__ptr)
  52. end
  53. function Sound:setSoundVelocity(velocity)
  54. local retVal = Polycode.Sound_setSoundVelocity(self.__ptr, velocity.__ptr)
  55. end
  56. function Sound:setSoundDirection(direction)
  57. local retVal = Polycode.Sound_setSoundDirection(self.__ptr, direction.__ptr)
  58. end
  59. function Sound:setOffset(offset)
  60. local retVal = Polycode.Sound_setOffset(self.__ptr, offset)
  61. end
  62. function Sound:getFileName()
  63. local retVal = Polycode.Sound_getFileName(self.__ptr)
  64. return retVal
  65. end
  66. function Sound:getPlaybackDuration()
  67. local retVal = Polycode.Sound_getPlaybackDuration(self.__ptr)
  68. return retVal
  69. end
  70. function Sound:getPlaybackTime()
  71. local retVal = Polycode.Sound_getPlaybackTime(self.__ptr)
  72. return retVal
  73. end
  74. function Sound:seekTo(time)
  75. local retVal = Polycode.Sound_seekTo(self.__ptr, time)
  76. end
  77. function Sound:getOffset()
  78. local retVal = Polycode.Sound_getOffset(self.__ptr)
  79. return retVal
  80. end
  81. function Sound:getSampleLength()
  82. local retVal = Polycode.Sound_getSampleLength(self.__ptr)
  83. return retVal
  84. end
  85. function Sound:getFrequency()
  86. local retVal = Polycode.Sound_getFrequency(self.__ptr)
  87. return retVal
  88. end
  89. function Sound:setPositionalProperties(referenceDistance, maxDistance)
  90. local retVal = Polycode.Sound_setPositionalProperties(self.__ptr, referenceDistance, maxDistance)
  91. end
  92. function Sound:setReferenceDistance(referenceDistance)
  93. local retVal = Polycode.Sound_setReferenceDistance(self.__ptr, referenceDistance)
  94. end
  95. function Sound:setMaxDistance(maxDistance)
  96. local retVal = Polycode.Sound_setMaxDistance(self.__ptr, maxDistance)
  97. end
  98. function Sound:getReferenceDistance()
  99. local retVal = Polycode.Sound_getReferenceDistance(self.__ptr)
  100. return retVal
  101. end
  102. function Sound:getMaxDistance()
  103. local retVal = Polycode.Sound_getMaxDistance(self.__ptr)
  104. return retVal
  105. end
  106. function Sound:soundCheck(result, err)
  107. local retVal = Polycode.Sound_soundCheck(self.__ptr, result, err)
  108. end
  109. function Sound:updateStream(streamCount)
  110. local retVal = Polycode.Sound_updateStream(self.__ptr, streamCount)
  111. end
  112. function Sound:__delete()
  113. if self then Polycode.delete_Sound(self.__ptr) end
  114. end