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.

AudioProcessor.cpp 3.7KB

6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. ==============================================================================
  3. This file is part of the Water library.
  4. Copyright (c) 2015 ROLI Ltd.
  5. Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com>
  6. Permission is granted to use this software under the terms of the GNU
  7. General Public License as published by the Free Software Foundation;
  8. either version 2 of the License, or any later version.
  9. This program is distributed in the hope that it will be useful, but WITHOUT
  10. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. For a full copy of the GNU General Public License see the doc/GPL.txt file.
  13. ==============================================================================
  14. */
  15. #include "AudioProcessor.h"
  16. namespace water {
  17. AudioProcessor::AudioProcessor()
  18. {
  19. numAudioIns = 0;
  20. numAudioOuts = 0;
  21. numCVIns = 0;
  22. numCVOuts = 0;
  23. numMIDIIns = 0;
  24. numMIDIOuts = 0;
  25. currentSampleRate = 0;
  26. blockSize = 0;
  27. latencySamples = 0;
  28. suspended = false;
  29. nonRealtime = false;
  30. }
  31. AudioProcessor::~AudioProcessor()
  32. {
  33. }
  34. //==============================================================================
  35. void AudioProcessor::setPlayConfigDetails (const uint newNumIns,
  36. const uint newNumOuts,
  37. const uint newNumCVIns,
  38. const uint newNumCVOuts,
  39. const uint newNumMIDIIns,
  40. const uint newNumMIDIOuts,
  41. const double newSampleRate,
  42. const int newBlockSize)
  43. {
  44. numAudioIns = newNumIns;
  45. numAudioOuts = newNumOuts;
  46. numCVIns = newNumCVIns;
  47. numCVOuts = newNumCVOuts;
  48. numMIDIIns = newNumMIDIIns;
  49. numMIDIOuts = newNumMIDIOuts;
  50. setRateAndBufferSizeDetails (newSampleRate, newBlockSize);
  51. }
  52. void AudioProcessor::setRateAndBufferSizeDetails (double newSampleRate, int newBlockSize) noexcept
  53. {
  54. currentSampleRate = newSampleRate;
  55. blockSize = newBlockSize;
  56. }
  57. //==============================================================================
  58. void AudioProcessor::setNonRealtime (const bool newNonRealtime) noexcept
  59. {
  60. nonRealtime = newNonRealtime;
  61. }
  62. void AudioProcessor::setLatencySamples (const int newLatency)
  63. {
  64. if (latencySamples != newLatency)
  65. latencySamples = newLatency;
  66. }
  67. void AudioProcessor::suspendProcessing (const bool shouldBeSuspended)
  68. {
  69. const CarlaRecursiveMutexLocker cml (callbackLock);
  70. suspended = shouldBeSuspended;
  71. }
  72. void AudioProcessor::reset() {}
  73. void AudioProcessor::reconfigure() {}
  74. uint AudioProcessor::getTotalNumInputChannels(ChannelType t) const noexcept
  75. {
  76. switch (t)
  77. {
  78. case ChannelTypeAudio:
  79. return numAudioIns;
  80. case ChannelTypeCV:
  81. return numCVIns;
  82. case ChannelTypeMIDI:
  83. return numMIDIIns;
  84. }
  85. return 0;
  86. }
  87. uint AudioProcessor::getTotalNumOutputChannels(ChannelType t) const noexcept
  88. {
  89. switch (t)
  90. {
  91. case ChannelTypeAudio:
  92. return numAudioOuts;
  93. case ChannelTypeCV:
  94. return numCVOuts;
  95. case ChannelTypeMIDI:
  96. return numMIDIOuts;
  97. }
  98. return 0;
  99. }
  100. const String AudioProcessor::getInputChannelName(ChannelType t, uint) const
  101. {
  102. return t == ChannelTypeMIDI ? "events-in" : "";
  103. }
  104. const String AudioProcessor::getOutputChannelName(ChannelType t, uint) const
  105. {
  106. return t == ChannelTypeMIDI ? "events-out" : "";
  107. }
  108. }