Browse Source

Deal with clap multi-IO audio, MIDI input

Signed-off-by: falkTX <falktx@falktx.com>
pull/1689/head
falkTX 2 years ago
parent
commit
728bbc30a5
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
5 changed files with 912 additions and 204 deletions
  1. +871
    -173
      source/backend/plugin/CarlaPluginCLAP.cpp
  2. +1
    -1
      source/backend/plugin/CarlaPluginLV2.cpp
  3. +1
    -1
      source/backend/plugin/CarlaPluginVST2.cpp
  4. +26
    -26
      source/backend/plugin/CarlaPluginVST3.cpp
  5. +13
    -3
      source/utils/CarlaClapUtils.hpp

+ 871
- 173
source/backend/plugin/CarlaPluginCLAP.cpp
File diff suppressed because it is too large
View File


+ 1
- 1
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -243,7 +243,7 @@ struct Lv2EventData {
port = nullptr;
}

const uint32_t rtype(type);
const uint32_t rtype = type;
type = 0x0;

if (rtype & CARLA_EVENT_DATA_ATOM)


+ 1
- 1
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -1326,7 +1326,7 @@ public:

if (pData->extNotes.mutex.tryLock())
{
ExternalMidiNote note = { 0, 0, 0 };
ExternalMidiNote note = { -1, 0, 0 };

for (; fMidiEventCount < kPluginMaxMidiEvents*2 && ! pData->extNotes.data.isEmpty();)
{


+ 26
- 26
source/backend/plugin/CarlaPluginVST3.cpp View File

@@ -431,7 +431,7 @@ public:
CarlaPluginVST3(CarlaEngine* const engine, const uint id)
: CarlaPlugin(engine, id),
fFirstActive(true),
fAudioOutBuffers(nullptr),
fAudioAndCvOutBuffers(nullptr),
fLastKnownLatency(0),
fLastTimeInfo(),
fV3TimeContext(),
@@ -932,10 +932,10 @@ public:

if (aOuts + cvIns > 0)
{
fAudioOutBuffers = new float*[aOuts + cvIns];
fAudioAndCvOutBuffers = new float*[aOuts + cvIns];

for (uint32_t i=0; i < aOuts + cvIns; ++i)
fAudioOutBuffers[i] = nullptr;
fAudioAndCvOutBuffers[i] = nullptr;
}

const EngineProcessMode processMode = pData->engine->getProccessMode();
@@ -1700,7 +1700,7 @@ public:
if (pData->audioOut.count > 0)
{
CARLA_SAFE_ASSERT_RETURN(outBuffer != nullptr, false);
CARLA_SAFE_ASSERT_RETURN(fAudioOutBuffers != nullptr, false);
CARLA_SAFE_ASSERT_RETURN(fAudioAndCvOutBuffers != nullptr, false);
}

// --------------------------------------------------------------------------------------------------------
@@ -1741,13 +1741,13 @@ public:
{
uint32_t i=0;
for (; i < pData->audioOut.count; ++i)
bufferAudioOut[i] = fAudioOutBuffers[i]+timeOffset;
bufferAudioOut[i] = fAudioAndCvOutBuffers[i]+timeOffset;
for (; i < pData->cvOut.count; ++i)
bufferAudioOut[i] = fAudioOutBuffers[i]+timeOffset;
bufferAudioOut[i] = fAudioAndCvOutBuffers[i]+timeOffset;
}

for (uint32_t i=0; i < pData->audioOut.count + pData->cvOut.count; ++i)
carla_zeroFloats(fAudioOutBuffers[i], frames);
carla_zeroFloats(fAudioAndCvOutBuffers[i], frames);

// --------------------------------------------------------------------------------------------------------
// Set MIDI events
@@ -1813,7 +1813,7 @@ public:
for (uint32_t k=0; k < frames; ++k)
{
bufValue = inBuffer[c][k+timeOffset];
fAudioOutBuffers[i][k] = (fAudioOutBuffers[i][k] * pData->postProc.dryWet) + (bufValue * (1.0f - pData->postProc.dryWet));
fAudioAndCvOutBuffers[i][k] = (fAudioAndCvOutBuffers[i][k] * pData->postProc.dryWet) + (bufValue * (1.0f - pData->postProc.dryWet));
}
}

@@ -1825,7 +1825,7 @@ public:
if (isPair)
{
CARLA_ASSERT(i+1 < pData->audioOut.count);
carla_copyFloats(oldBufLeft, fAudioOutBuffers[i], frames);
carla_copyFloats(oldBufLeft, fAudioAndCvOutBuffers[i], frames);
}

float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
@@ -1836,14 +1836,14 @@ public:
if (isPair)
{
// left
fAudioOutBuffers[i][k] = oldBufLeft[k] * (1.0f - balRangeL);
fAudioOutBuffers[i][k] += fAudioOutBuffers[i+1][k] * (1.0f - balRangeR);
fAudioAndCvOutBuffers[i][k] = oldBufLeft[k] * (1.0f - balRangeL);
fAudioAndCvOutBuffers[i][k] += fAudioAndCvOutBuffers[i+1][k] * (1.0f - balRangeR);
}
else
{
// right
fAudioOutBuffers[i][k] = fAudioOutBuffers[i][k] * balRangeR;
fAudioOutBuffers[i][k] += oldBufLeft[k] * balRangeL;
fAudioAndCvOutBuffers[i][k] = fAudioAndCvOutBuffers[i][k] * balRangeR;
fAudioAndCvOutBuffers[i][k] += oldBufLeft[k] * balRangeL;
}
}
}
@@ -1851,17 +1851,17 @@ public:
// Volume (and buffer copy)
{
for (uint32_t k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = fAudioOutBuffers[i][k] * pData->postProc.volume;
outBuffer[i][k+timeOffset] = fAudioAndCvOutBuffers[i][k] * pData->postProc.volume;
}
}

for (; i < pData->cvOut.count; ++i)
carla_copyFloats(outBuffer[i] + timeOffset, fAudioOutBuffers[i] + timeOffset, frames);
carla_copyFloats(outBuffer[i] + timeOffset, fAudioAndCvOutBuffers[i] + timeOffset, frames);

} // End of Post-processing
#else // BUILD_BRIDGE_ALTERNATIVE_ARCH
for (uint32_t i=0; i < pData->audioOut.count + pData->cvOut.count; ++i)
carla_copyFloats(outBuffer[i] + timeOffset, fAudioOutBuffers[i] + timeOffset, frames);
carla_copyFloats(outBuffer[i] + timeOffset, fAudioAndCvOutBuffers[i] + timeOffset, frames);
#endif

// --------------------------------------------------------------------------------------------------------
@@ -1880,9 +1880,9 @@ public:

for (uint32_t i=0; i < pData->audioOut.count + pData->cvOut.count; ++i)
{
if (fAudioOutBuffers[i] != nullptr)
delete[] fAudioOutBuffers[i];
fAudioOutBuffers[i] = new float[newBufferSize];
if (fAudioAndCvOutBuffers[i] != nullptr)
delete[] fAudioAndCvOutBuffers[i];
fAudioAndCvOutBuffers[i] = new float[newBufferSize];
}

v3_process_setup setup = {
@@ -1943,19 +1943,19 @@ public:
{
carla_debug("CarlaPluginVST2::clearBuffers() - start");

if (fAudioOutBuffers != nullptr)
if (fAudioAndCvOutBuffers != nullptr)
{
for (uint32_t i=0; i < pData->audioOut.count + pData->cvOut.count; ++i)
{
if (fAudioOutBuffers[i] != nullptr)
if (fAudioAndCvOutBuffers[i] != nullptr)
{
delete[] fAudioOutBuffers[i];
fAudioOutBuffers[i] = nullptr;
delete[] fAudioAndCvOutBuffers[i];
fAudioAndCvOutBuffers[i] = nullptr;
}
}

delete[] fAudioOutBuffers;
fAudioOutBuffers = nullptr;
delete[] fAudioAndCvOutBuffers;
fAudioAndCvOutBuffers = nullptr;
}

CarlaPlugin::clearBuffers();
@@ -2239,7 +2239,7 @@ private:
#endif

bool fFirstActive; // first process() call after activate()
float** fAudioOutBuffers;
float** fAudioAndCvOutBuffers;
uint32_t fLastKnownLatency;
EngineTimeInfo fLastTimeInfo;
v3_process_context fV3TimeContext;


+ 13
- 3
source/utils/CarlaClapUtils.hpp View File

@@ -43,14 +43,24 @@

extern "C" {

typedef struct clap_audio_buffer_const {
typedef struct clap_audio_buffer_with_offset {
float **data32;
double **data64;
uint32_t channel_count;
uint32_t latency;
uint64_t constant_mask;
uint32_t offset;
} clap_audio_buffer_with_offset_t;

typedef struct clap_audio_buffer_const_with_offset {
// Either data32 or data64 pointer will be set.
const float* const* data32;
const double* const* data64;
uint32_t channel_count;
uint32_t latency; // latency from/to the audio interface
uint32_t latency;
uint64_t constant_mask;
} clap_audio_buffer_const_t;
uint32_t offset;
} clap_audio_buffer_const_with_offset_t;

}



Loading…
Cancel
Save