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.

139 lines
6.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_MPEZONE_H_INCLUDED
  18. #define JUCE_MPEZONE_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. This struct represents an MPE Zone.
  22. An MPE Zone occupies one master MIDI channel and an arbitrary
  23. number of note channels that immediately follow the master channel.
  24. It also defines a pitchbend range (in semitones) to be applied for per-note
  25. pitchbends and master pitchbends, respectively.
  26. @see MPEZoneLayout
  27. */
  28. struct JUCE_API MPEZone
  29. {
  30. /** Constructor.
  31. Creates an MPE zone with the given master channel and
  32. number of note channels.
  33. @param masterChannel The master MIDI channel of the new zone.
  34. All master (not per-note) messages should be send to this channel.
  35. Must be between 1 and 15. Otherwise, the behaviour
  36. is undefined.
  37. @param numNoteChannels The number of note channels that the new zone
  38. should use. The first note channel will be one higher
  39. than the master channel. The number of note channels
  40. must be at least 1 and no greater than 16 - masterChannel.
  41. Otherwise, the behaviour is undefined.
  42. @param perNotePitchbendRange The per-note pitchbend range in semitones of the new zone.
  43. Must be between 0 and 96. Otherwise the behaviour is undefined.
  44. If unspecified, the default setting of +/- 48 semitones
  45. will be used.
  46. @param masterPitchbendRange The master pitchbend range in semitones of the new zone.
  47. Must be between 0 and 96. Otherwise the behaviour is undefined.
  48. If unspecified, the default setting of +/- 2 semitones
  49. will be used.
  50. */
  51. MPEZone (int masterChannel,
  52. int numNoteChannels,
  53. int perNotePitchbendRange = 48,
  54. int masterPitchbendRange = 2) noexcept;
  55. /* Returns the MIDI master channel of this zone. */
  56. int getMasterChannel() const noexcept;
  57. /** Returns the number of note channels occupied by this zone. */
  58. int getNumNoteChannels() const noexcept;
  59. /* Returns the MIDI channel number of the lowest-numbered note channel of this zone. */
  60. int getFirstNoteChannel() const noexcept;
  61. /* Returns the MIDI channel number of the highest-numbered note channel of this zone. */
  62. int getLastNoteChannel() const noexcept;
  63. /** Returns the MIDI channel numbers of the note channels of this zone as a Range. */
  64. Range<int> getNoteChannelRange() const noexcept;
  65. /** Returns true if the MIDI channel (in the range 1-16) is used by this zone
  66. either as a note channel or as the master channel; false otherwise. */
  67. bool isUsingChannel (int channel) const noexcept;
  68. /** Returns true if the MIDI channel (in the range 1-16) is used by this zone
  69. as a note channel; false otherwise. */
  70. bool isUsingChannelAsNoteChannel (int channel) const noexcept;
  71. /** Returns the per-note pitchbend range in semitones set for this zone. */
  72. int getPerNotePitchbendRange() const noexcept;
  73. /** Returns the master pitchbend range in semitones set for this zone. */
  74. int getMasterPitchbendRange() const noexcept;
  75. /** Sets the per-note pitchbend range in semitones for this zone. */
  76. void setPerNotePitchbendRange (int rangeInSemitones) noexcept;
  77. /** Sets the master pitchbend range in semitones for this zone. */
  78. void setMasterPitchbendRange (int rangeInSemitones) noexcept;
  79. /** Returns true if the MIDI channels occupied by this zone
  80. overlap with those occupied by the other zone.
  81. */
  82. bool overlapsWith (MPEZone other) const noexcept;
  83. /** Tries to truncate this zone in such a way that the range of MIDI channels
  84. it occupies do not overlap with the other zone, by reducing this zone's
  85. number of note channels.
  86. @returns true if the truncation succeeded or if no truncation is necessary
  87. because the zones do not overlap. False if the zone cannot be truncated
  88. in a way that would remove the overlap (in this case you need to delete
  89. the zone to remove the overlap).
  90. */
  91. bool truncateToFit (MPEZone zoneToAvoid) noexcept;
  92. /** @returns true if this zone is equal to the one passed in. */
  93. bool operator== (const MPEZone& other) const noexcept;
  94. /** @returns true if this zone is not equal to the one passed in. */
  95. bool operator!= (const MPEZone& other) const noexcept;
  96. private:
  97. //==============================================================================
  98. int masterChannel;
  99. int numNoteChannels;
  100. int perNotePitchbendRange;
  101. int masterPitchbendRange;
  102. };
  103. #endif // JUCE_MPEZONE_H_INCLUDED