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.

145 lines
5.3KB

  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_AUDIOPLAYHEAD_H_INCLUDED
  18. #define JUCE_AUDIOPLAYHEAD_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A subclass of AudioPlayHead can supply information about the position and
  22. status of a moving play head during audio playback.
  23. One of these can be supplied to an AudioProcessor object so that it can find
  24. out about the position of the audio that it is rendering.
  25. @see AudioProcessor::setPlayHead, AudioProcessor::getPlayHead
  26. */
  27. class JUCE_API AudioPlayHead
  28. {
  29. protected:
  30. //==============================================================================
  31. AudioPlayHead() {}
  32. public:
  33. virtual ~AudioPlayHead() {}
  34. //==============================================================================
  35. /** Frame rate types. */
  36. enum FrameRateType
  37. {
  38. fps24 = 0,
  39. fps25 = 1,
  40. fps2997 = 2,
  41. fps30 = 3,
  42. fps2997drop = 4,
  43. fps30drop = 5,
  44. fpsUnknown = 99
  45. };
  46. //==============================================================================
  47. /** This structure is filled-in by the AudioPlayHead::getCurrentPosition() method.
  48. */
  49. struct JUCE_API CurrentPositionInfo
  50. {
  51. /** The tempo in BPM */
  52. double bpm;
  53. /** Time signature numerator, e.g. the 3 of a 3/4 time sig */
  54. int timeSigNumerator;
  55. /** Time signature denominator, e.g. the 4 of a 3/4 time sig */
  56. int timeSigDenominator;
  57. /** The current play position, in samples from the start of the edit. */
  58. int64 timeInSamples;
  59. /** The current play position, in seconds from the start of the edit. */
  60. double timeInSeconds;
  61. /** For timecode, the position of the start of the edit, in seconds from 00:00:00:00. */
  62. double editOriginTime;
  63. /** The current play position, in pulses-per-quarter-note. */
  64. double ppqPosition;
  65. /** The position of the start of the last bar, in pulses-per-quarter-note.
  66. This is the time from the start of the edit to the start of the current
  67. bar, in ppq units.
  68. Note - this value may be unavailable on some hosts, e.g. Pro-Tools. If
  69. it's not available, the value will be 0.
  70. */
  71. double ppqPositionOfLastBarStart;
  72. /** The video frame rate, if applicable. */
  73. FrameRateType frameRate;
  74. /** True if the transport is currently playing. */
  75. bool isPlaying;
  76. /** True if the transport is currently recording.
  77. (When isRecording is true, then isPlaying will also be true).
  78. */
  79. bool isRecording;
  80. /** The current cycle start position in pulses-per-quarter-note.
  81. Note that not all hosts or plugin formats may provide this value.
  82. @see isLooping
  83. */
  84. double ppqLoopStart;
  85. /** The current cycle end position in pulses-per-quarter-note.
  86. Note that not all hosts or plugin formats may provide this value.
  87. @see isLooping
  88. */
  89. double ppqLoopEnd;
  90. /** True if the transport is currently looping. */
  91. bool isLooping;
  92. //==============================================================================
  93. bool operator== (const CurrentPositionInfo& other) const noexcept;
  94. bool operator!= (const CurrentPositionInfo& other) const noexcept;
  95. void resetToDefault();
  96. };
  97. //==============================================================================
  98. /** Fills-in the given structure with details about the transport's
  99. position at the start of the current processing block. If this method returns
  100. false then the current play head position is not available and the given
  101. structure will be undefined.
  102. You can ONLY call this from your processBlock() method! Calling it at other
  103. times will produce undefined behaviour, as the host may not have any context
  104. in which a time would make sense, and some hosts will almost certainly have
  105. multithreading issues if it's not called on the audio thread.
  106. */
  107. virtual bool getCurrentPosition (CurrentPositionInfo& result) = 0;
  108. };
  109. #endif // JUCE_AUDIOPLAYHEAD_H_INCLUDED