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.

125 lines
4.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. // #include "juce_AudioProcessor.h"
  18. AudioProcessor::AudioProcessor()
  19. {
  20. cachedTotalIns = 0;
  21. cachedTotalOuts = 0;
  22. playHead = nullptr;
  23. currentSampleRate = 0;
  24. blockSize = 0;
  25. latencySamples = 0;
  26. suspended = false;
  27. nonRealtime = false;
  28. }
  29. AudioProcessor::~AudioProcessor()
  30. {
  31. }
  32. //==============================================================================
  33. void AudioProcessor::setPlayHead (AudioPlayHead* const newPlayHead)
  34. {
  35. playHead = newPlayHead;
  36. }
  37. void AudioProcessor::setPlayConfigDetails (const int newNumIns,
  38. const int newNumOuts,
  39. const double newSampleRate,
  40. const int newBlockSize)
  41. {
  42. cachedTotalIns = newNumIns;
  43. cachedTotalOuts = newNumOuts;
  44. setRateAndBufferSizeDetails (newSampleRate, newBlockSize);
  45. }
  46. void AudioProcessor::setRateAndBufferSizeDetails (double newSampleRate, int newBlockSize) noexcept
  47. {
  48. currentSampleRate = newSampleRate;
  49. blockSize = newBlockSize;
  50. }
  51. //==============================================================================
  52. void AudioProcessor::setNonRealtime (const bool newNonRealtime) noexcept
  53. {
  54. nonRealtime = newNonRealtime;
  55. }
  56. void AudioProcessor::setLatencySamples (const int newLatency)
  57. {
  58. if (latencySamples != newLatency)
  59. latencySamples = newLatency;
  60. }
  61. void AudioProcessor::suspendProcessing (const bool shouldBeSuspended)
  62. {
  63. const CarlaRecursiveMutexLocker cml (callbackLock);
  64. suspended = shouldBeSuspended;
  65. }
  66. void AudioProcessor::reset() {}
  67. void AudioProcessor::processBypassed (AudioSampleBuffer& buffer, MidiBuffer&)
  68. {
  69. for (int ch = getTotalNumInputChannels(); ch < getTotalNumOutputChannels(); ++ch)
  70. buffer.clear (ch, 0, buffer.getNumSamples());
  71. }
  72. void AudioProcessor::processBlockBypassed (AudioSampleBuffer& buffer, MidiBuffer& midi) { processBypassed (buffer, midi); }
  73. //==============================================================================
  74. bool AudioPlayHead::CurrentPositionInfo::operator== (const CurrentPositionInfo& other) const noexcept
  75. {
  76. return timeInSamples == other.timeInSamples
  77. && ppqPosition == other.ppqPosition
  78. && editOriginTime == other.editOriginTime
  79. && ppqPositionOfLastBarStart == other.ppqPositionOfLastBarStart
  80. && frameRate == other.frameRate
  81. && isPlaying == other.isPlaying
  82. && isRecording == other.isRecording
  83. && bpm == other.bpm
  84. && timeSigNumerator == other.timeSigNumerator
  85. && timeSigDenominator == other.timeSigDenominator
  86. && ppqLoopStart == other.ppqLoopStart
  87. && ppqLoopEnd == other.ppqLoopEnd
  88. && isLooping == other.isLooping;
  89. }
  90. bool AudioPlayHead::CurrentPositionInfo::operator!= (const CurrentPositionInfo& other) const noexcept
  91. {
  92. return ! operator== (other);
  93. }
  94. void AudioPlayHead::CurrentPositionInfo::resetToDefault()
  95. {
  96. zerostruct (*this);
  97. timeSigNumerator = 4;
  98. timeSigDenominator = 4;
  99. bpm = 120;
  100. }