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.

153 lines
6.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. #ifndef JUCE_MPEZONE_H_INCLUDED
  24. #define JUCE_MPEZONE_H_INCLUDED
  25. //==============================================================================
  26. /**
  27. This struct represents an MPE Zone.
  28. An MPE Zone occupies one master MIDI channel and an arbitrary
  29. number of note channels that immediately follow the master channel.
  30. It also defines a pitchbend range (in semitones) to be applied for per-note
  31. pitchbends and master pitchbends, respectively.
  32. @see MPEZoneLayout
  33. */
  34. struct JUCE_API MPEZone
  35. {
  36. /** Constructor.
  37. Creates an MPE zone with the given master channel and
  38. number of note channels.
  39. @param masterChannel The master MIDI channel of the new zone.
  40. All master (not per-note) messages should be send to this channel.
  41. Must be between 1 and 15. Otherwise, the behaviour
  42. is undefined.
  43. @param numNoteChannels The number of note channels that the new zone
  44. should use. The first note channel will be one higher
  45. than the master channel. The number of note channels
  46. must be at least 1 and no greater than 16 - masterChannel.
  47. Otherwise, the behaviour is undefined.
  48. @param perNotePitchbendRange The per-note pitchbend range in semitones of the new zone.
  49. Must be between 0 and 96. Otherwise the behaviour is undefined.
  50. If unspecified, the default setting of +/- 48 semitones
  51. will be used.
  52. @param masterPitchbendRange The master pitchbend range in semitones of the new zone.
  53. Must be between 0 and 96. Otherwise the behaviour is undefined.
  54. If unspecified, the default setting of +/- 2 semitones
  55. will be used.
  56. */
  57. MPEZone (int masterChannel,
  58. int numNoteChannels,
  59. int perNotePitchbendRange = 48,
  60. int masterPitchbendRange = 2) noexcept;
  61. /* Returns the MIDI master channel number (in the range 1-16) of this zone. */
  62. int getMasterChannel() const noexcept;
  63. /** Returns the number of note channels occupied by this zone. */
  64. int getNumNoteChannels() const noexcept;
  65. /* Returns the MIDI channel number (in the range 1-16) of the
  66. lowest-numbered note channel of this zone.
  67. */
  68. int getFirstNoteChannel() const noexcept;
  69. /* Returns the MIDI channel number (in the range 1-16) of the
  70. highest-numbered note channel of this zone.
  71. */
  72. int getLastNoteChannel() const noexcept;
  73. /** Returns the MIDI channel numbers (in the range 1-16) of the
  74. note channels of this zone as a Range.
  75. */
  76. Range<int> getNoteChannelRange() const noexcept;
  77. /** Returns true if the MIDI channel (in the range 1-16) is used by this zone
  78. either as a note channel or as the master channel; false otherwise.
  79. */
  80. bool isUsingChannel (int channel) const noexcept;
  81. /** Returns true if the MIDI channel (in the range 1-16) is used by this zone
  82. as a note channel; false otherwise.
  83. */
  84. bool isUsingChannelAsNoteChannel (int channel) const noexcept;
  85. /** Returns the per-note pitchbend range in semitones set for this zone. */
  86. int getPerNotePitchbendRange() const noexcept;
  87. /** Returns the master pitchbend range in semitones set for this zone. */
  88. int getMasterPitchbendRange() const noexcept;
  89. /** Sets the per-note pitchbend range in semitones for this zone. */
  90. void setPerNotePitchbendRange (int rangeInSemitones) noexcept;
  91. /** Sets the master pitchbend range in semitones for this zone. */
  92. void setMasterPitchbendRange (int rangeInSemitones) noexcept;
  93. /** Returns true if the MIDI channels occupied by this zone
  94. overlap with those occupied by the other zone.
  95. */
  96. bool overlapsWith (MPEZone other) const noexcept;
  97. /** Tries to truncate this zone in such a way that the range of MIDI channels
  98. it occupies do not overlap with the other zone, by reducing this zone's
  99. number of note channels.
  100. @returns true if the truncation succeeded or if no truncation is necessary
  101. because the zones do not overlap. False if the zone cannot be truncated
  102. in a way that would remove the overlap (in this case you need to delete
  103. the zone to remove the overlap).
  104. */
  105. bool truncateToFit (MPEZone zoneToAvoid) noexcept;
  106. /** @returns true if this zone is equal to the one passed in. */
  107. bool operator== (const MPEZone& other) const noexcept;
  108. /** @returns true if this zone is not equal to the one passed in. */
  109. bool operator!= (const MPEZone& other) const noexcept;
  110. private:
  111. //==============================================================================
  112. int masterChannel;
  113. int numNoteChannels;
  114. int perNotePitchbendRange;
  115. int masterPitchbendRange;
  116. };
  117. #endif // JUCE_MPEZONE_H_INCLUDED