| @@ -234,8 +234,7 @@ public: | |||
| m_ctrlInChannel = 0; | |||
| m_latency = 0; | |||
| m_tempBufferIn = nullptr; | |||
| m_tempBufferOut = nullptr; | |||
| m_latencyBuffers = nullptr; | |||
| #ifndef BUILD_BRIDGE | |||
| osc.data.path = nullptr; | |||
| @@ -309,20 +308,12 @@ public: | |||
| custom.clear(); | |||
| } | |||
| if (m_tempBufferIn) | |||
| if (m_latencyBuffers) | |||
| { | |||
| for (uint32_t i=0; i < aIn.count; i++) | |||
| delete[] m_tempBufferIn[i]; | |||
| delete[] m_latencyBuffers[i]; | |||
| delete[] m_tempBufferIn; | |||
| } | |||
| if (m_tempBufferOut) | |||
| { | |||
| for (uint32_t i=0; i < aOut.count; i++) | |||
| delete[] m_tempBufferOut[i]; | |||
| delete[] m_tempBufferOut; | |||
| delete[] m_latencyBuffers; | |||
| } | |||
| m_count -= 1; | |||
| @@ -1387,49 +1378,31 @@ public: | |||
| */ | |||
| virtual void bufferSizeChanged(const uint32_t newBufferSize) | |||
| { | |||
| recreateTempBuffers(newBufferSize); | |||
| Q_UNUSED(newBufferSize); | |||
| } | |||
| /*! | |||
| * Recreate temporary audio buffers. | |||
| * Recreate latency audio buffers. | |||
| */ | |||
| void recreateTempBuffers(const uint32_t bufferSize) | |||
| void recreateLatencyBuffers() | |||
| { | |||
| if (m_tempBufferIn) | |||
| if (m_latencyBuffers) | |||
| { | |||
| for (uint32_t i=0; i < aIn.count; i++) | |||
| delete[] m_tempBufferIn[i]; | |||
| delete[] m_latencyBuffers[i]; | |||
| delete[] m_tempBufferIn; | |||
| delete[] m_latencyBuffers; | |||
| } | |||
| if (m_tempBufferOut) | |||
| if (aIn.count > 0 && m_latency > 0) | |||
| { | |||
| for (uint32_t i=0; i < aOut.count; i++) | |||
| delete[] m_tempBufferOut[i]; | |||
| delete[] m_tempBufferOut; | |||
| } | |||
| if (aIn.count > 0) | |||
| { | |||
| m_tempBufferIn = new float* [aIn.count]; | |||
| m_latencyBuffers = new float* [aIn.count]; | |||
| for (uint32_t i=0; i < aIn.count; i++) | |||
| m_tempBufferIn[i] = new float [bufferSize]; | |||
| } | |||
| else | |||
| m_tempBufferIn = nullptr; | |||
| if (aOut.count > 0) | |||
| { | |||
| m_tempBufferOut = new float* [aOut.count]; | |||
| for (uint32_t i=0; i < aOut.count; i++) | |||
| m_tempBufferOut[i] = new float [bufferSize]; | |||
| m_latencyBuffers[i] = new float [m_latency]; | |||
| } | |||
| else | |||
| m_tempBufferOut = nullptr; | |||
| m_latencyBuffers = nullptr; | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| @@ -2242,8 +2215,7 @@ protected: | |||
| int8_t m_ctrlInChannel; | |||
| uint32_t m_latency; | |||
| float** m_tempBufferIn; | |||
| float** m_tempBufferOut; | |||
| float** m_latencyBuffers; | |||
| // ------------------------------------------------------------------- | |||
| // Storage Data | |||
| @@ -743,12 +743,12 @@ public: | |||
| aIn.ports[i]->setLatency(m_latency); | |||
| x_client->recomputeLatencies(); | |||
| recreateLatencyBuffers(); | |||
| } | |||
| } | |||
| reloadPrograms(true); | |||
| recreateTempBuffers(x_engine->getBufferSize()); | |||
| x_client->activate(); | |||
| qDebug("DssiPlugin::reload() - end"); | |||
| @@ -1234,6 +1234,12 @@ public: | |||
| midiEventCount = MAX_MIDI_CHANNELS; | |||
| } | |||
| if (m_latency > 0) | |||
| { | |||
| for (i=0; i < aIn.count; i++) | |||
| memset(m_latencyBuffers[i], 0, sizeof(float)*m_latency); | |||
| } | |||
| if (ldescriptor->activate) | |||
| { | |||
| ldescriptor->activate(handle); | |||
| @@ -1305,7 +1311,7 @@ public: | |||
| for (k=0; k < frames; k++) | |||
| { | |||
| if (k < m_latency && m_latency < frames) | |||
| bufValue = (aIn.count == 1) ? m_tempBufferIn[0][k] : m_tempBufferIn[i][k]; | |||
| bufValue = (aIn.count == 1) ? m_latencyBuffers[0][k] : m_latencyBuffers[i][k]; | |||
| else | |||
| bufValue = (aIn.count == 1) ? inBuffer[0][k-m_latency] : inBuffer[i][k-m_latency]; | |||
| @@ -1358,7 +1364,7 @@ public: | |||
| if (m_latency > 0 && m_latency < frames) | |||
| { | |||
| for (i=0; i < aIn.count; i++) | |||
| memcpy(m_tempBufferIn[i], inBuffer[i] + (frames - m_latency), sizeof(float)*m_latency); | |||
| memcpy(m_latencyBuffers[i], inBuffer[i] + (frames - m_latency), sizeof(float)*m_latency); | |||
| } | |||
| } | |||
| else | |||
| @@ -712,10 +712,10 @@ public: | |||
| aIn.ports[i]->setLatency(m_latency); | |||
| x_client->recomputeLatencies(); | |||
| recreateLatencyBuffers(); | |||
| } | |||
| } | |||
| recreateTempBuffers(x_engine->getBufferSize()); | |||
| x_client->activate(); | |||
| qDebug("LadspaPlugin::reload() - end"); | |||
| @@ -925,6 +925,12 @@ public: | |||
| { | |||
| if (! m_activeBefore) | |||
| { | |||
| if (m_latency > 0) | |||
| { | |||
| for (i=0; i < aIn.count; i++) | |||
| memset(m_latencyBuffers[i], 0, sizeof(float)*m_latency); | |||
| } | |||
| if (descriptor->activate) | |||
| { | |||
| descriptor->activate(handle); | |||
| @@ -981,7 +987,7 @@ public: | |||
| for (k=0; k < frames; k++) | |||
| { | |||
| if (k < m_latency && m_latency < frames) | |||
| bufValue = (aIn.count == 1) ? m_tempBufferIn[0][k] : m_tempBufferIn[i][k]; | |||
| bufValue = (aIn.count == 1) ? m_latencyBuffers[0][k] : m_latencyBuffers[i][k]; | |||
| else | |||
| bufValue = (aIn.count == 1) ? inBuffer[0][k-m_latency] : inBuffer[i][k-m_latency]; | |||
| @@ -1034,7 +1040,7 @@ public: | |||
| if (m_latency > 0 && m_latency < frames) | |||
| { | |||
| for (i=0; i < aIn.count; i++) | |||
| memcpy(m_tempBufferIn[i], inBuffer[i] + (frames - m_latency), sizeof(float)*m_latency); | |||
| memcpy(m_latencyBuffers[i], inBuffer[i] + (frames - m_latency), sizeof(float)*m_latency); | |||
| } | |||
| } | |||
| else | |||
| @@ -1775,12 +1775,12 @@ public: | |||
| aIn.ports[i]->setLatency(m_latency); | |||
| x_client->recomputeLatencies(); | |||
| recreateLatencyBuffers(); | |||
| } | |||
| } | |||
| reloadPrograms(true); | |||
| recreateTempBuffers(x_engine->getBufferSize()); | |||
| x_client->activate(); | |||
| qDebug("Lv2Plugin::reload() - end"); | |||
| @@ -2520,6 +2520,12 @@ public: | |||
| midiEventCount = MAX_MIDI_CHANNELS*2; | |||
| } | |||
| if (m_latency > 0) | |||
| { | |||
| for (i=0; i < aIn.count; i++) | |||
| memset(m_latencyBuffers[i], 0, sizeof(float)*m_latency); | |||
| } | |||
| if (descriptor->activate) | |||
| { | |||
| descriptor->activate(handle); | |||
| @@ -2582,7 +2588,7 @@ public: | |||
| for (k=0; k < frames; k++) | |||
| { | |||
| if (k < m_latency && m_latency < frames) | |||
| bufValue = (aIn.count == 1) ? m_tempBufferIn[0][k] : m_tempBufferIn[i][k]; | |||
| bufValue = (aIn.count == 1) ? m_latencyBuffers[0][k] : m_latencyBuffers[i][k]; | |||
| else | |||
| bufValue = (aIn.count == 1) ? inBuffer[0][k-m_latency] : inBuffer[i][k-m_latency]; | |||
| @@ -2635,7 +2641,7 @@ public: | |||
| if (m_latency > 0 && m_latency < frames) | |||
| { | |||
| for (i=0; i < aIn.count; i++) | |||
| memcpy(m_tempBufferIn[i], inBuffer[i] + (frames - m_latency), sizeof(float)*m_latency); | |||
| memcpy(m_latencyBuffers[i], inBuffer[i] + (frames - m_latency), sizeof(float)*m_latency); | |||
| } | |||
| } | |||
| else | |||
| @@ -2771,8 +2777,6 @@ public: | |||
| void bufferSizeChanged(const uint32_t newBufferSize) | |||
| { | |||
| lv2Options.bufferSize = newBufferSize; | |||
| CarlaPlugin::bufferSizeChanged(newBufferSize); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| @@ -743,11 +743,11 @@ public: | |||
| aIn.ports[i]->setLatency(m_latency); | |||
| x_client->recomputeLatencies(); | |||
| recreateLatencyBuffers(); | |||
| } | |||
| reloadPrograms(true); | |||
| recreateTempBuffers(x_engine->getBufferSize()); | |||
| x_client->activate(); | |||
| qDebug("VstPlugin::reload() - end"); | |||
| @@ -1210,11 +1210,11 @@ public: | |||
| midiEventCount = MAX_MIDI_CHANNELS*2; | |||
| } | |||
| for (i=0; i < aIn.count; i++) | |||
| memset(m_tempBufferIn[i], 0, sizeof(float)*x_engine->getBufferSize()); | |||
| for (i=0; i < aOut.count; i++) | |||
| memset(m_tempBufferOut[i], 0, sizeof(float)*x_engine->getBufferSize()); | |||
| if (m_latency > 0) | |||
| { | |||
| for (i=0; i < aIn.count; i++) | |||
| memset(m_latencyBuffers[i], 0, sizeof(float)*m_latency); | |||
| } | |||
| effect->dispatcher(effect, effStartProcess, 0, 0, nullptr, 0.0f); | |||
| } | |||
| @@ -1277,7 +1277,7 @@ public: | |||
| for (k=0; k < frames; k++) | |||
| { | |||
| if (k < m_latency && m_latency < frames) | |||
| bufValue = (aIn.count == 1) ? m_tempBufferIn[0][k] : m_tempBufferIn[i][k]; | |||
| bufValue = (aIn.count == 1) ? m_latencyBuffers[0][k] : m_latencyBuffers[i][k]; | |||
| else | |||
| bufValue = (aIn.count == 1) ? inBuffer[0][k-m_latency] : inBuffer[i][k-m_latency]; | |||
| @@ -1330,7 +1330,7 @@ public: | |||
| if (m_latency > 0 && m_latency < frames) | |||
| { | |||
| for (i=0; i < aIn.count; i++) | |||
| memcpy(m_tempBufferIn[i], inBuffer[i] + (frames - m_latency), sizeof(float)*m_latency); | |||
| memcpy(m_latencyBuffers[i], inBuffer[i] + (frames - m_latency), sizeof(float)*m_latency); | |||
| } | |||
| } | |||
| else | |||
| @@ -1392,8 +1392,6 @@ public: | |||
| if (m_active) | |||
| effect->dispatcher(effect, effStartProcess, 0, 0, nullptr, 0.0f); | |||
| CarlaPlugin::bufferSizeChanged(newBufferSize); | |||
| } | |||
| // ------------------------------------------------------------------- | |||