PolySound.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * PolySound.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 3/15/09.
  6. * Copyright 2009 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. // @package Sound
  10. #pragma once
  11. #include <vorbis/vorbisfile.h>
  12. #include "PolyLogger.h"
  13. #include "PolyGlobals.h"
  14. #include <string>
  15. #include <vector>
  16. #include "al.h"
  17. #include "alc.h"
  18. #include "OSBasics.h"
  19. using std::string;
  20. using std::vector;
  21. #define ALNoErrorStr "No AL error occurred"
  22. #define ALInvalidNameStr "AL error: a bad name (ID) was passed to an OpenAL function"
  23. #define ALInvalidEnumStr "AL error: an invalid enum value was passed to an OpenAL function"
  24. #define ALInvalidValueStr "AL error: an invalid value was passed to an OpenAL function"
  25. #define ALInvalidOpStr "AL error: the requested operation is not valid"
  26. #define ALOutOfMemoryStr "AL error: the requested operation resulted in OpenAL running out of memory"
  27. #define ALOtherErrorStr "AL error: unknown error"
  28. #define BUFFER_SIZE 32768
  29. namespace Polycode {
  30. class _PolyExport Sound {
  31. public:
  32. Sound(string fileName);
  33. ~Sound();
  34. void Play(bool once);
  35. void Stop();
  36. ALuint loadWAV(string fileName);
  37. ALuint loadOGG(string fileName);
  38. ALuint GenSource(ALuint buffer);
  39. ALuint GenSource();
  40. void checkALError(string operation);
  41. void soundError(string err);
  42. void soundCheck(bool result, string err);
  43. static unsigned long readByte32(const unsigned char buffer[4]);
  44. static unsigned short readByte16(const unsigned char buffer[2]);
  45. private:
  46. ALuint soundSource;
  47. };
  48. }