VolumeSound.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*******************************************************************************
  2. * Copyright 2015-2016 Juan Francisco Crespo Galán
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. ******************************************************************************/
  16. #pragma once
  17. /**
  18. * @file VolumeSound.h
  19. * @ingroup fx
  20. * The VolumeSound class.
  21. */
  22. #include "ISound.h"
  23. #include "VolumeStorage.h"
  24. #include <memory>
  25. AUD_NAMESPACE_BEGIN
  26. /**
  27. * This class allows to create a sound with its own volume.
  28. */
  29. class AUD_API VolumeSound : public ISound
  30. {
  31. private:
  32. /**
  33. * A pointer to a sound.
  34. */
  35. std::shared_ptr<ISound> m_sound;
  36. /**
  37. * A pointer to the shared volume being used.
  38. */
  39. std::shared_ptr<VolumeStorage> m_volumeStorage;
  40. // delete copy constructor and operator=
  41. VolumeSound(const VolumeSound&) = delete;
  42. VolumeSound& operator=(const VolumeSound&) = delete;
  43. public:
  44. /**
  45. * Creates a new VolumeSound.
  46. * \param sound The sound in which shall have its own volume.
  47. * \param volumeStorage A shared pointer to a VolumeStorage object. It allows to change the volume of various sound in one go.
  48. */
  49. VolumeSound(std::shared_ptr<ISound> sound, std::shared_ptr<VolumeStorage> volumeStorage);
  50. virtual std::shared_ptr<IReader> createReader();
  51. /**
  52. * Retrieves the shared volume of this sound.
  53. * \return A shared pointer to the VolumeStorage object that this sound is using.
  54. */
  55. std::shared_ptr<VolumeStorage> getSharedVolume();
  56. /**
  57. * Changes the shared volume of this sound, it'll only affect newly created readers.
  58. * \param volumeStorage A shared pointer to the new VolumeStorage object.
  59. */
  60. void setSharedVolume(std::shared_ptr<VolumeStorage> volumeStorage);
  61. };
  62. AUD_NAMESPACE_END