Sound.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. function Sound(fileName) {
  2. if(arguments[0] != "__skip_ptr__") {
  3. this.__ptr = Polycode.Sound(fileName)
  4. }
  5. }
  6. Duktape.fin(Sound.prototype, function (x) {
  7. if (x === Sound.prototype) {
  8. return;
  9. }
  10. Polycode.Sound__delete(x.__ptr)
  11. })
  12. Sound.prototype.getSampleAsNumber = function(offset,channel,position,orientation) {
  13. return Polycode.Sound_getSampleAsNumber(this.__ptr, offset, channel, position, orientation)
  14. }
  15. Sound.prototype.loadFile = function(fileName) {
  16. Polycode.Sound_loadFile(this.__ptr, fileName)
  17. }
  18. Sound.prototype.Play = function(loop,restartSound) {
  19. Polycode.Sound_Play(this.__ptr, loop, restartSound)
  20. }
  21. Sound.prototype.Stop = function() {
  22. Polycode.Sound_Stop(this.__ptr)
  23. }
  24. Sound.prototype.setVolume = function(newVolume) {
  25. Polycode.Sound_setVolume(this.__ptr, newVolume)
  26. }
  27. Sound.prototype.getVolume = function() {
  28. return Polycode.Sound_getVolume(this.__ptr)
  29. }
  30. Sound.prototype.setPitch = function(newPitch) {
  31. Polycode.Sound_setPitch(this.__ptr, newPitch)
  32. }
  33. Sound.prototype.getPitch = function() {
  34. return Polycode.Sound_getPitch(this.__ptr)
  35. }
  36. Sound.prototype.isPlaying = function() {
  37. return Polycode.Sound_isPlaying(this.__ptr)
  38. }
  39. Sound.prototype.isLooped = function() {
  40. return Polycode.Sound_isLooped(this.__ptr)
  41. }
  42. Sound.prototype.setIsPositional = function(isPositional) {
  43. Polycode.Sound_setIsPositional(this.__ptr, isPositional)
  44. }
  45. Sound.prototype.setSoundPosition = function(position) {
  46. Polycode.Sound_setSoundPosition(this.__ptr, position)
  47. }
  48. Sound.prototype.setSoundVelocity = function(velocity) {
  49. Polycode.Sound_setSoundVelocity(this.__ptr, velocity)
  50. }
  51. Sound.prototype.setSoundDirection = function(direction) {
  52. Polycode.Sound_setSoundDirection(this.__ptr, direction)
  53. }
  54. Sound.prototype.setOffset = function(offset) {
  55. Polycode.Sound_setOffset(this.__ptr, offset)
  56. }
  57. Sound.prototype.getFileName = function() {
  58. return Polycode.Sound_getFileName(this.__ptr)
  59. }
  60. Sound.prototype.getPlaybackDuration = function() {
  61. return Polycode.Sound_getPlaybackDuration(this.__ptr)
  62. }
  63. Sound.prototype.getPlaybackTime = function() {
  64. return Polycode.Sound_getPlaybackTime(this.__ptr)
  65. }
  66. Sound.prototype.seekTo = function(time) {
  67. Polycode.Sound_seekTo(this.__ptr, time)
  68. }
  69. Sound.prototype.getOffset = function() {
  70. return Polycode.Sound_getOffset(this.__ptr)
  71. }
  72. Sound.prototype.getSampleLength = function() {
  73. return Polycode.Sound_getSampleLength(this.__ptr)
  74. }
  75. Sound.prototype.getFrequency = function() {
  76. return Polycode.Sound_getFrequency(this.__ptr)
  77. }
  78. Sound.prototype.setPositionalProperties = function(referenceDistance,maxDistance) {
  79. Polycode.Sound_setPositionalProperties(this.__ptr, referenceDistance, maxDistance)
  80. }
  81. Sound.prototype.setReferenceDistance = function(referenceDistance) {
  82. Polycode.Sound_setReferenceDistance(this.__ptr, referenceDistance)
  83. }
  84. Sound.prototype.setMaxDistance = function(maxDistance) {
  85. Polycode.Sound_setMaxDistance(this.__ptr, maxDistance)
  86. }
  87. Sound.prototype.getReferenceDistance = function() {
  88. return Polycode.Sound_getReferenceDistance(this.__ptr)
  89. }
  90. Sound.prototype.getMaxDistance = function() {
  91. return Polycode.Sound_getMaxDistance(this.__ptr)
  92. }
  93. Sound.prototype.loadWAV = function(fileName) {
  94. return Polycode.Sound_loadWAV(this.__ptr, fileName)
  95. }
  96. Sound.prototype.loadOGG = function(fileName) {
  97. return Polycode.Sound_loadOGG(this.__ptr, fileName)
  98. }
  99. Sound.prototype.soundCheck = function(result,err) {
  100. Polycode.Sound_soundCheck(this.__ptr, result, err)
  101. }
  102. Sound.prototype.updateStream = function(streamCount) {
  103. Polycode.Sound_updateStream(this.__ptr, streamCount)
  104. }