Source.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * Copyright (c) 2006-2014 LOVE Development Team
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. **/
  20. #ifndef LOVE_AUDIO_SOURCE_H
  21. #define LOVE_AUDIO_SOURCE_H
  22. // LOVE
  23. #include "common/Object.h"
  24. #include "common/StringMap.h"
  25. namespace love
  26. {
  27. namespace audio
  28. {
  29. class Source : public Object
  30. {
  31. public:
  32. enum Type
  33. {
  34. TYPE_STATIC = 1,
  35. TYPE_STREAM,
  36. TYPE_MAX_ENUM
  37. }; // Type
  38. enum Unit
  39. {
  40. UNIT_SECONDS = 1,
  41. UNIT_SAMPLES,
  42. UNIT_MAX_ENUM
  43. };
  44. Source(Type type);
  45. virtual ~Source();
  46. virtual Source *clone() = 0;
  47. virtual void play() = 0;
  48. virtual void stop() = 0;
  49. virtual void pause() = 0;
  50. virtual void resume() = 0;
  51. virtual void rewind() = 0;
  52. virtual bool isStopped() const = 0;
  53. virtual bool isPaused() const = 0;
  54. virtual bool isFinished() const = 0;
  55. virtual bool update() = 0;
  56. virtual void setPitch(float pitch) = 0;
  57. virtual float getPitch() const = 0;
  58. virtual void setVolume(float volume) = 0;
  59. virtual float getVolume() const = 0;
  60. virtual void seek(float offset, Unit unit) = 0;
  61. virtual float tell(Unit unit) = 0;
  62. // all float * v must be of size 3
  63. virtual void setPosition(float *v) = 0;
  64. virtual void getPosition(float *v) const = 0;
  65. virtual void setVelocity(float *v) = 0;
  66. virtual void getVelocity(float *v) const = 0;
  67. virtual void setDirection(float *v) = 0;
  68. virtual void getDirection(float *v) const = 0;
  69. virtual void setCone(float innerAngle, float outerAngle, float outerVolume) = 0;
  70. virtual void getCone(float &innerAngle, float &outerAngle, float &outerVolume) const = 0;
  71. virtual void setRelative(bool enable) = 0;
  72. virtual bool isRelative() const = 0;
  73. virtual void setLooping(bool looping) = 0;
  74. virtual bool isLooping() const = 0;
  75. virtual bool isStatic() const = 0;
  76. virtual void setMinVolume(float volume) = 0;
  77. virtual float getMinVolume() const = 0;
  78. virtual void setMaxVolume(float volume) = 0;
  79. virtual float getMaxVolume() const = 0;
  80. virtual void setReferenceDistance(float distance) = 0;
  81. virtual float getReferenceDistance() const = 0;
  82. virtual void setRolloffFactor(float factor) = 0;
  83. virtual float getRolloffFactor() const = 0;
  84. virtual void setMaxDistance(float distance) = 0;
  85. virtual float getMaxDistance() const = 0;
  86. virtual int getChannels() const = 0;
  87. static bool getConstant(const char *in, Type &out);
  88. static bool getConstant(Type in, const char *&out);
  89. static bool getConstant(const char *in, Unit &out);
  90. static bool getConstant(Unit in, const char *&out);
  91. protected:
  92. Type type;
  93. private:
  94. static StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[];
  95. static StringMap<Type, TYPE_MAX_ENUM> types;
  96. static StringMap<Unit, UNIT_MAX_ENUM>::Entry unitEntries[];
  97. static StringMap<Unit, UNIT_MAX_ENUM> units;
  98. }; // Source
  99. } // audio
  100. } // love
  101. #endif // LOVE_AUDIO_SOURCE_H