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