Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. namespace juce
  18. {
  19. //==============================================================================
  20. /**
  21. This class represents a single value for any of the MPE
  22. dimensions of control. It supports values with 7-bit or 14-bit resolutions
  23. (corresponding to 1 or 2 MIDI bytes, respectively). It also offers helper
  24. functions to query the value in a variety of representations that can be
  25. useful in an audio or MIDI context.
  26. */
  27. class JUCE_API MPEValue
  28. {
  29. public:
  30. //==============================================================================
  31. /** Default constructor. Constructs an MPEValue corresponding
  32. to the centre value.
  33. */
  34. MPEValue() noexcept;
  35. /** Constructs an MPEValue from an integer between 0 and 127
  36. (using 7-bit precision).
  37. */
  38. static MPEValue from7BitInt (int value) noexcept;
  39. /** Constructs an MPEValue from an integer between 0 and 16383
  40. (using 14-bit precision).
  41. */
  42. static MPEValue from14BitInt (int value) noexcept;
  43. /** Constructs an MPEValue corresponding to the centre value. */
  44. static MPEValue centreValue() noexcept;
  45. /** Constructs an MPEValue corresponding to the minimum value. */
  46. static MPEValue minValue() noexcept;
  47. /** Constructs an MPEValue corresponding to the maximum value. */
  48. static MPEValue maxValue() noexcept;
  49. /** Retrieves the current value as an integer between 0 and 127.
  50. Information will be lost if the value was initialised with a precision
  51. higher than 7-bit.
  52. */
  53. int as7BitInt() const noexcept;
  54. /** Retrieves the current value as an integer between 0 and 16383.
  55. Resolution will be lost if the value was initialised with a precision
  56. higher than 14-bit.
  57. */
  58. int as14BitInt() const noexcept;
  59. /** Retrieves the current value mapped to a float between -1.0f and 1.0f. */
  60. float asSignedFloat() const noexcept;
  61. /** Retrieves the current value mapped to a float between 0.0f and 1.0f. */
  62. float asUnsignedFloat() const noexcept;
  63. /** Returns true if two values are equal. */
  64. bool operator== (const MPEValue& other) const noexcept;
  65. /** Returns true if two values are not equal. */
  66. bool operator!= (const MPEValue& other) const noexcept;
  67. private:
  68. //==============================================================================
  69. MPEValue (int normalisedValue);
  70. int normalisedValue;
  71. };
  72. } // namespace juce