VolumeStorage.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 VolumeStorage.h
  19. * @ingroup fx
  20. * The VolumeStorage class.
  21. */
  22. #include "Audaspace.h"
  23. #include <atomic>
  24. AUD_NAMESPACE_BEGIN
  25. /**
  26. * This class stores a volume value and allows to change if for a number of sounds in one go.
  27. */
  28. class AUD_API VolumeStorage
  29. {
  30. private:
  31. /**
  32. * Volume value.
  33. */
  34. std::atomic<float> m_volume;
  35. // delete copy constructor and operator=
  36. VolumeStorage(const VolumeStorage&) = delete;
  37. VolumeStorage& operator=(const VolumeStorage&) = delete;
  38. public:
  39. /**
  40. * Creates a new VolumeStorage instance with volume 1
  41. */
  42. VolumeStorage();
  43. /**
  44. * Creates a VolumeStorage instance with an initial value.
  45. * \param volume The value of the volume.
  46. */
  47. VolumeStorage(float volume);
  48. /**
  49. * Retrieves the current volume value.
  50. * \return The current volume.
  51. */
  52. float getVolume();
  53. /**
  54. * Changes the volume value.
  55. * \param volume The new value for the volume.
  56. */
  57. void setVolume(float volume);
  58. };
  59. AUD_NAMESPACE_END