Sound.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 = Polycore.Sound(unpack(arg))
  13. end
  14. end
  15. function Sound:getSampleAsNumber(offset, channel)
  16. local retVal = Polycore.Sound_getSampleAsNumber(self.__ptr, offset, channel)
  17. return retVal
  18. end
  19. function Sound:loadFile(fileName)
  20. local retVal = Polycore.Sound_loadFile(self.__ptr, fileName)
  21. end
  22. function Sound:Play(loop, restartSound)
  23. local retVal = Polycore.Sound_Play(self.__ptr, loop, restartSound)
  24. end
  25. function Sound:Stop()
  26. local retVal = Polycore.Sound_Stop(self.__ptr)
  27. end
  28. function Sound:setVolume(newVolume)
  29. local retVal = Polycore.Sound_setVolume(self.__ptr, newVolume)
  30. end
  31. function Sound:getVolume()
  32. local retVal = Polycore.Sound_getVolume(self.__ptr)
  33. return retVal
  34. end
  35. function Sound:setPitch(newPitch)
  36. local retVal = Polycore.Sound_setPitch(self.__ptr, newPitch)
  37. end
  38. function Sound:getPitch()
  39. local retVal = Polycore.Sound_getPitch(self.__ptr)
  40. return retVal
  41. end
  42. function Sound:isPlaying()
  43. local retVal = Polycore.Sound_isPlaying(self.__ptr)
  44. return retVal
  45. end
  46. function Sound:isLooped()
  47. local retVal = Polycore.Sound_isLooped(self.__ptr)
  48. return retVal
  49. end
  50. function Sound:setIsPositional(isPositional)
  51. local retVal = Polycore.Sound_setIsPositional(self.__ptr, isPositional)
  52. end
  53. function Sound:setSoundPosition(position)
  54. local retVal = Polycore.Sound_setSoundPosition(self.__ptr, position.__ptr)
  55. end
  56. function Sound:setSoundVelocity(velocity)
  57. local retVal = Polycore.Sound_setSoundVelocity(self.__ptr, velocity.__ptr)
  58. end
  59. function Sound:setSoundDirection(direction)
  60. local retVal = Polycore.Sound_setSoundDirection(self.__ptr, direction.__ptr)
  61. end
  62. function Sound:setOffset(offset)
  63. local retVal = Polycore.Sound_setOffset(self.__ptr, offset)
  64. end
  65. function Sound:getFileName()
  66. local retVal = Polycore.Sound_getFileName(self.__ptr)
  67. return retVal
  68. end
  69. function Sound:getPlaybackDuration()
  70. local retVal = Polycore.Sound_getPlaybackDuration(self.__ptr)
  71. return retVal
  72. end
  73. function Sound:getPlaybackTime()
  74. local retVal = Polycore.Sound_getPlaybackTime(self.__ptr)
  75. return retVal
  76. end
  77. function Sound:seekTo(time)
  78. local retVal = Polycore.Sound_seekTo(self.__ptr, time)
  79. end
  80. function Sound:getOffset()
  81. local retVal = Polycore.Sound_getOffset(self.__ptr)
  82. return retVal
  83. end
  84. function Sound:getSampleLength()
  85. local retVal = Polycore.Sound_getSampleLength(self.__ptr)
  86. return retVal
  87. end
  88. function Sound:getFrequency()
  89. local retVal = Polycore.Sound_getFrequency(self.__ptr)
  90. return retVal
  91. end
  92. function Sound:setPositionalProperties(referenceDistance, maxDistance)
  93. local retVal = Polycore.Sound_setPositionalProperties(self.__ptr, referenceDistance, maxDistance)
  94. end
  95. function Sound:setReferenceDistance(referenceDistance)
  96. local retVal = Polycore.Sound_setReferenceDistance(self.__ptr, referenceDistance)
  97. end
  98. function Sound:setMaxDistance(maxDistance)
  99. local retVal = Polycore.Sound_setMaxDistance(self.__ptr, maxDistance)
  100. end
  101. function Sound:getReferenceDistance()
  102. local retVal = Polycore.Sound_getReferenceDistance(self.__ptr)
  103. return retVal
  104. end
  105. function Sound:getMaxDistance()
  106. local retVal = Polycore.Sound_getMaxDistance(self.__ptr)
  107. return retVal
  108. end
  109. function Sound:loadBytes(data, size, channels, freq, format)
  110. local retVal = Polycore.Sound_loadBytes(self.__ptr, data.__ptr, size, channels, freq, format.__ptr)
  111. return retVal
  112. end
  113. function Sound:loadWAV(fileName)
  114. local retVal = Polycore.Sound_loadWAV(self.__ptr, fileName)
  115. return retVal
  116. end
  117. function Sound:loadOGG(fileName)
  118. local retVal = Polycore.Sound_loadOGG(self.__ptr, fileName)
  119. return retVal
  120. end
  121. function Sound:soundCheck(result, err)
  122. local retVal = Polycore.Sound_soundCheck(self.__ptr, result, err)
  123. end
  124. function Sound:updateStream(streamCount)
  125. local retVal = Polycore.Sound_updateStream(self.__ptr, streamCount)
  126. end
  127. function Sound:__delete()
  128. if self then Polycore.delete_Sound(self.__ptr) end
  129. end