Sound.pkg 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. $#include "IO/File.h"
  2. $#include "Audio/Sound.h"
  3. class Sound : public Resource
  4. {
  5. Sound();
  6. ~Sound();
  7. bool LoadRaw(Deserializer& source);
  8. bool LoadWav(Deserializer& source);
  9. bool LoadOggVorbis(Deserializer& source);
  10. tolua_outside bool SoundLoadRaw @ LoadRaw(const String fileName);
  11. tolua_outside bool SoundLoadWav @ LoadWav(const String fileName);
  12. tolua_outside bool SoundLoadOggVorbis @ LoadOggVorbis(const String fileName);
  13. void SetSize(unsigned dataSize);
  14. void SetData(const void* data, unsigned dataSize);
  15. void SetFormat(unsigned frequency, bool sixteenBit, bool stereo);
  16. void SetLooped(bool enable);
  17. void SetLoop(unsigned repeatOffset, unsigned endOffset);
  18. void FixInterpolation();
  19. float GetLength() const;
  20. unsigned GetDataSize() const;
  21. unsigned GetSampleSize() const;
  22. float GetFrequency() const;
  23. unsigned GetIntFrequency() const;
  24. bool IsLooped() const;
  25. bool IsSixteenBit() const;
  26. bool IsStereo() const;
  27. bool IsCompressed() const;
  28. tolua_readonly tolua_property__get_set float length;
  29. tolua_readonly tolua_property__get_set unsigned dataSize;
  30. tolua_readonly tolua_property__get_set unsigned sampleSize;
  31. tolua_readonly tolua_property__get_set float frequency;
  32. tolua_readonly tolua_property__get_set int intFrequency;
  33. tolua_property__is_set bool looped;
  34. tolua_readonly tolua_property__is_set bool sixteenBit;
  35. tolua_readonly tolua_property__is_set bool stereo;
  36. tolua_readonly tolua_property__is_set bool compressed;
  37. };
  38. ${
  39. #define TOLUA_DISABLE_tolua_AudioLuaAPI_Sound_new00
  40. static int tolua_AudioLuaAPI_Sound_new00(lua_State* tolua_S)
  41. {
  42. return ToluaNewObject<Sound>(tolua_S);
  43. }
  44. #define TOLUA_DISABLE_tolua_AudioLuaAPI_Sound_new00_local
  45. static int tolua_AudioLuaAPI_Sound_new00_local(lua_State* tolua_S)
  46. {
  47. return ToluaNewObjectGC<Sound>(tolua_S);
  48. }
  49. static bool SoundLoadRaw(Sound* sound, const String& fileName)
  50. {
  51. if (!sound)
  52. return false;
  53. File file(sound->GetContext());
  54. if (!file.Open(fileName, FILE_READ))
  55. return false;
  56. return sound->LoadRaw(file);
  57. }
  58. static bool SoundLoadWav(Sound* sound, const String& fileName)
  59. {
  60. if (!sound)
  61. return false;
  62. File file(sound->GetContext());
  63. if (!file.Open(fileName, FILE_READ))
  64. return false;
  65. return sound->LoadWav(file);
  66. }
  67. static bool SoundLoadOggVorbis(Sound* sound, const String& fileName)
  68. {
  69. if (!sound)
  70. return false;
  71. File file(sound->GetContext());
  72. if (!file.Open(fileName, FILE_READ))
  73. return false;
  74. return sound->LoadOggVorbis(file);
  75. }
  76. $}