The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

156 lines
5.8KB

  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. 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. fps23976 = 0,
  39. fps24 = 1,
  40. fps25 = 2,
  41. fps2997 = 3,
  42. fps30 = 4,
  43. fps2997drop = 5,
  44. fps30drop = 6,
  45. fps60 = 7,
  46. fps60drop = 8,
  47. fpsUnknown = 99
  48. };
  49. //==============================================================================
  50. /** This structure is filled-in by the AudioPlayHead::getCurrentPosition() method.
  51. */
  52. struct JUCE_API CurrentPositionInfo
  53. {
  54. /** The tempo in BPM */
  55. double bpm;
  56. /** Time signature numerator, e.g. the 3 of a 3/4 time sig */
  57. int timeSigNumerator;
  58. /** Time signature denominator, e.g. the 4 of a 3/4 time sig */
  59. int timeSigDenominator;
  60. /** The current play position, in samples from the start of the timeline. */
  61. int64 timeInSamples;
  62. /** The current play position, in seconds from the start of the timeline. */
  63. double timeInSeconds;
  64. /** For timecode, the position of the start of the timeline, in seconds from 00:00:00:00. */
  65. double editOriginTime;
  66. /** The current play position, in units of quarter-notes. */
  67. double ppqPosition;
  68. /** The position of the start of the last bar, in units of quarter-notes.
  69. This is the time from the start of the timeline to the start of the current
  70. bar, in ppq units.
  71. Note - this value may be unavailable on some hosts, e.g. Pro-Tools. If
  72. it's not available, the value will be 0.
  73. */
  74. double ppqPositionOfLastBarStart;
  75. /** The video frame rate, if applicable. */
  76. FrameRateType frameRate;
  77. /** True if the transport is currently playing. */
  78. bool isPlaying;
  79. /** True if the transport is currently recording.
  80. (When isRecording is true, then isPlaying will also be true).
  81. */
  82. bool isRecording;
  83. /** The current cycle start position in units of quarter-notes.
  84. Note that not all hosts or plugin formats may provide this value.
  85. @see isLooping
  86. */
  87. double ppqLoopStart;
  88. /** The current cycle end position in units of quarter-notes.
  89. Note that not all hosts or plugin formats may provide this value.
  90. @see isLooping
  91. */
  92. double ppqLoopEnd;
  93. /** True if the transport is currently looping. */
  94. bool isLooping;
  95. //==============================================================================
  96. bool operator== (const CurrentPositionInfo& other) const noexcept;
  97. bool operator!= (const CurrentPositionInfo& other) const noexcept;
  98. void resetToDefault();
  99. };
  100. //==============================================================================
  101. /** Fills-in the given structure with details about the transport's
  102. position at the start of the current processing block. If this method returns
  103. false then the current play head position is not available and the given
  104. structure will be undefined.
  105. You can ONLY call this from your processBlock() method! Calling it at other
  106. times will produce undefined behaviour, as the host may not have any context
  107. in which a time would make sense, and some hosts will almost certainly have
  108. multithreading issues if it's not called on the audio thread.
  109. */
  110. virtual bool getCurrentPosition (CurrentPositionInfo& result) = 0;
  111. /** Returns true if this object can control the transport. */
  112. virtual bool canControlTransport() { return false; }
  113. /** Starts or stops the audio. */
  114. virtual void transportPlay (bool shouldStartPlaying) { ignoreUnused (shouldStartPlaying); }
  115. /** Starts or stops recording the audio. */
  116. virtual void transportRecord (bool shouldStartRecording) { ignoreUnused (shouldStartRecording); }
  117. /** Rewinds the audio. */
  118. virtual void transportRewind() {}
  119. };
  120. } // namespace juce