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.

143 lines
6.0KB

  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 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 number (in the range 1-16) 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 (in the range 1-16) of the
  60. lowest-numbered note channel of this zone.
  61. */
  62. int getFirstNoteChannel() const noexcept;
  63. /* Returns the MIDI channel number (in the range 1-16) of the
  64. highest-numbered note channel of this zone.
  65. */
  66. int getLastNoteChannel() const noexcept;
  67. /** Returns the MIDI channel numbers (in the range 1-16) of the
  68. note channels of this zone as a Range.
  69. */
  70. Range<int> getNoteChannelRange() const noexcept;
  71. /** Returns true if the MIDI channel (in the range 1-16) is used by this zone
  72. either as a note channel or as the master channel; false otherwise.
  73. */
  74. bool isUsingChannel (int channel) const noexcept;
  75. /** Returns true if the MIDI channel (in the range 1-16) is used by this zone
  76. as a note channel; false otherwise.
  77. */
  78. bool isUsingChannelAsNoteChannel (int channel) const noexcept;
  79. /** Returns the per-note pitchbend range in semitones set for this zone. */
  80. int getPerNotePitchbendRange() const noexcept;
  81. /** Returns the master pitchbend range in semitones set for this zone. */
  82. int getMasterPitchbendRange() const noexcept;
  83. /** Sets the per-note pitchbend range in semitones for this zone. */
  84. void setPerNotePitchbendRange (int rangeInSemitones) noexcept;
  85. /** Sets the master pitchbend range in semitones for this zone. */
  86. void setMasterPitchbendRange (int rangeInSemitones) noexcept;
  87. /** Returns true if the MIDI channels occupied by this zone
  88. overlap with those occupied by the other zone.
  89. */
  90. bool overlapsWith (MPEZone other) const noexcept;
  91. /** Tries to truncate this zone in such a way that the range of MIDI channels
  92. it occupies do not overlap with the other zone, by reducing this zone's
  93. number of note channels.
  94. @returns true if the truncation succeeded or if no truncation is necessary
  95. because the zones do not overlap. False if the zone cannot be truncated
  96. in a way that would remove the overlap (in this case you need to delete
  97. the zone to remove the overlap).
  98. */
  99. bool truncateToFit (MPEZone zoneToAvoid) noexcept;
  100. /** @returns true if this zone is equal to the one passed in. */
  101. bool operator== (const MPEZone& other) const noexcept;
  102. /** @returns true if this zone is not equal to the one passed in. */
  103. bool operator!= (const MPEZone& other) const noexcept;
  104. private:
  105. //==============================================================================
  106. int masterChannel;
  107. int numNoteChannels;
  108. int perNotePitchbendRange;
  109. int masterPitchbendRange;
  110. };
  111. } // namespace juce