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 "PolyString.h"
  13. #include "PolyLogger.h"
  14. #include "PolyGlobals.h"
  15. #include <string>
  16. #include <vector>
  17. #include "al.h"
  18. #include "alc.h"
  19. #include "OSBasics.h"
  20. using std::string;
  21. using std::vector;
  22. #define ALNoErrorStr "No AL error occurred"
  23. #define ALInvalidNameStr "AL error: a bad name (ID) was passed to an OpenAL function"
  24. #define ALInvalidEnumStr "AL error: an invalid enum value was passed to an OpenAL function"
  25. #define ALInvalidValueStr "AL error: an invalid value was passed to an OpenAL function"
  26. #define ALInvalidOpStr "AL error: the requested operation is not valid"
  27. #define ALOutOfMemoryStr "AL error: the requested operation resulted in OpenAL running out of memory"
  28. #define ALOtherErrorStr "AL error: unknown error"
  29. #define BUFFER_SIZE 32768
  30. namespace Polycode {
  31. class _PolyExport Sound {
  32. public:
  33. Sound(String fileName);
  34. ~Sound();
  35. void Play(bool once);
  36. void Stop();
  37. ALuint loadWAV(String fileName);
  38. ALuint loadOGG(String fileName);
  39. ALuint GenSource(ALuint buffer);
  40. ALuint GenSource();
  41. void checkALError(String operation);
  42. void soundError(String err);
  43. void soundCheck(bool result, String err);
  44. static unsigned long readByte32(const unsigned char buffer[4]);
  45. static unsigned short readByte16(const unsigned char buffer[2]);
  46. private:
  47. ALuint soundSource;
  48. };
  49. }