@@ -934,12 +934,17 @@ public: | |||
// Information (peaks) | |||
/*! | |||
* TODO. | |||
* Get a plugin's peak values. | |||
*/ | |||
float* getPeaks(const uint pluginId) const noexcept; | |||
/*! | |||
* Get a plugin's input peak value. | |||
*/ | |||
float getInputPeak(const uint pluginId, const bool isLeft) const noexcept; | |||
/*! | |||
* TODO. | |||
* Get a plugin's output peak value. | |||
*/ | |||
float getOutputPeak(const uint pluginId, const bool isLeft) const noexcept; | |||
@@ -727,6 +727,12 @@ CARLA_EXPORT float carla_get_current_parameter_value(uint pluginId, uint32_t par | |||
*/ | |||
CARLA_EXPORT float carla_get_internal_parameter_value(uint pluginId, int32_t parameterId); | |||
/*! | |||
* Get a plugin's peak values. | |||
* @param pluginId Plugin | |||
*/ | |||
float* carla_get_peak_values(uint pluginId); | |||
/*! | |||
* Get a plugin's input peak value. | |||
* @param pluginId Plugin | |||
@@ -1612,6 +1612,13 @@ float carla_get_internal_parameter_value(uint pluginId, int32_t parameterId) | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
float* carla_get_peak_values(uint pluginId) | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, nullptr); | |||
return gStandalone.engine->getPeaks(pluginId); | |||
} | |||
float carla_get_input_peak_value(uint pluginId, bool isLeft) | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0.0f); | |||
@@ -516,11 +516,8 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, | |||
} | |||
EnginePluginData& pluginData(pData->plugins[id]); | |||
pluginData.plugin = plugin; | |||
pluginData.insPeak[0] = 0.0f; | |||
pluginData.insPeak[1] = 0.0f; | |||
pluginData.outsPeak[0] = 0.0f; | |||
pluginData.outsPeak[1] = 0.0f; | |||
pluginData.plugin = plugin; | |||
carla_zeroFloats(pluginData.peaks, 4); | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
if (oldPlugin != nullptr) | |||
@@ -670,11 +667,7 @@ bool CarlaEngine::removeAllPlugins() | |||
pluginData.plugin = nullptr; | |||
} | |||
pluginData.insPeak[0] = 0.0f; | |||
pluginData.insPeak[1] = 0.0f; | |||
pluginData.outsPeak[0] = 0.0f; | |||
pluginData.outsPeak[1] = 0.0f; | |||
carla_zeroFloats(pluginData.peaks, 4); | |||
callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr); | |||
} | |||
@@ -1134,19 +1127,42 @@ EngineTimeInfo CarlaEngine::getTimeInfo() const noexcept | |||
// ----------------------------------------------------------------------- | |||
// Information (peaks) | |||
float* CarlaEngine::getPeaks(const uint pluginId) const noexcept | |||
{ | |||
carla_zeroFloats(pData->peaks, 4); | |||
if (pluginId == MAIN_CARLA_PLUGIN_ID) | |||
{ | |||
// get peak from first plugin, if available | |||
if (const uint count = pData->curPluginCount) | |||
{ | |||
pData->peaks[0] = pData->plugins[0].peaks[0]; | |||
pData->peaks[1] = pData->plugins[0].peaks[1]; | |||
pData->peaks[2] = pData->plugins[count-1].peaks[2]; | |||
pData->peaks[3] = pData->plugins[count-1].peaks[3]; | |||
} | |||
return pData->peaks; | |||
} | |||
CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount, pData->peaks); | |||
return pData->plugins[pluginId].peaks; | |||
} | |||
float CarlaEngine::getInputPeak(const uint pluginId, const bool isLeft) const noexcept | |||
{ | |||
if (pluginId == MAIN_CARLA_PLUGIN_ID) | |||
{ | |||
// get peak from first plugin, if available | |||
if (pData->curPluginCount > 0) | |||
return pData->plugins[0].insPeak[isLeft ? 0 : 1]; | |||
return pData->plugins[0].peaks[isLeft ? 0 : 1]; | |||
return 0.0f; | |||
} | |||
CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount, 0.0f); | |||
return pData->plugins[pluginId].insPeak[isLeft ? 0 : 1]; | |||
return pData->plugins[pluginId].peaks[isLeft ? 0 : 1]; | |||
} | |||
float CarlaEngine::getOutputPeak(const uint pluginId, const bool isLeft) const noexcept | |||
@@ -1155,13 +1171,13 @@ float CarlaEngine::getOutputPeak(const uint pluginId, const bool isLeft) const n | |||
{ | |||
// get peak from last plugin, if available | |||
if (pData->curPluginCount > 0) | |||
return pData->plugins[pData->curPluginCount-1].outsPeak[isLeft ? 0 : 1]; | |||
return pData->plugins[pData->curPluginCount-1].peaks[isLeft ? 2 : 3]; | |||
return 0.0f; | |||
} | |||
CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount, 0.0f); | |||
return pData->plugins[pluginId].outsPeak[isLeft ? 0 : 1]; | |||
return pData->plugins[pluginId].peaks[isLeft ? 2 : 3]; | |||
} | |||
// ----------------------------------------------------------------------- | |||
@@ -1697,10 +1713,10 @@ void CarlaEngine::setPluginPeaks(const uint pluginId, float const inPeaks[2], fl | |||
{ | |||
EnginePluginData& pluginData(pData->plugins[pluginId]); | |||
pluginData.insPeak[0] = inPeaks[0]; | |||
pluginData.insPeak[1] = inPeaks[1]; | |||
pluginData.outsPeak[0] = outPeaks[0]; | |||
pluginData.outsPeak[1] = outPeaks[1]; | |||
pluginData.peaks[0] = inPeaks[0]; | |||
pluginData.peaks[1] = inPeaks[1]; | |||
pluginData.peaks[2] = outPeaks[0]; | |||
pluginData.peaks[3] = outPeaks[1]; | |||
} | |||
void CarlaEngine::saveProjectInternal(water::MemoryOutputStream& outStream) const | |||
@@ -892,24 +892,24 @@ void RackGraph::process(CarlaEngine::ProtectedData* const data, const float* inB | |||
if (oldAudioInCount > 0) | |||
{ | |||
pluginData.insPeak[0] = carla_findMaxNormalizedFloat(inBuf0, frames); | |||
pluginData.insPeak[1] = carla_findMaxNormalizedFloat(inBuf1, frames); | |||
pluginData.peaks[0] = carla_findMaxNormalizedFloat(inBuf0, frames); | |||
pluginData.peaks[1] = carla_findMaxNormalizedFloat(inBuf1, frames); | |||
} | |||
else | |||
{ | |||
pluginData.insPeak[0] = 0.0f; | |||
pluginData.insPeak[1] = 0.0f; | |||
pluginData.peaks[0] = 0.0f; | |||
pluginData.peaks[1] = 0.0f; | |||
} | |||
if (oldAudioOutCount > 0) | |||
{ | |||
pluginData.outsPeak[0] = carla_findMaxNormalizedFloat(outBufReal[0], frames); | |||
pluginData.outsPeak[1] = carla_findMaxNormalizedFloat(outBufReal[1], frames); | |||
pluginData.peaks[2] = carla_findMaxNormalizedFloat(outBufReal[0], frames); | |||
pluginData.peaks[3] = carla_findMaxNormalizedFloat(outBufReal[1], frames); | |||
} | |||
else | |||
{ | |||
pluginData.outsPeak[0] = 0.0f; | |||
pluginData.outsPeak[1] = 0.0f; | |||
pluginData.peaks[2] = 0.0f; | |||
pluginData.peaks[3] = 0.0f; | |||
} | |||
} | |||
@@ -555,21 +555,15 @@ void CarlaEngine::ProtectedData::doPluginRemove(const uint pluginId) noexcept | |||
plugin->setId(i); | |||
plugins[i].plugin = plugin; | |||
plugins[i].insPeak[0] = 0.0f; | |||
plugins[i].insPeak[1] = 0.0f; | |||
plugins[i].outsPeak[0] = 0.0f; | |||
plugins[i].outsPeak[1] = 0.0f; | |||
plugins[i].plugin = plugin; | |||
carla_zeroFloats(plugins[i].peaks, 4); | |||
} | |||
const uint id(curPluginCount); | |||
// reset last plugin (now removed) | |||
plugins[id].plugin = nullptr; | |||
plugins[id].insPeak[0] = 0.0f; | |||
plugins[id].insPeak[1] = 0.0f; | |||
plugins[id].outsPeak[0] = 0.0f; | |||
plugins[id].outsPeak[1] = 0.0f; | |||
plugins[id].plugin = nullptr; | |||
carla_zeroFloats(plugins[id].peaks, 4); | |||
} | |||
void CarlaEngine::ProtectedData::doPluginsSwitch(const uint idA, const uint idB) noexcept | |||
@@ -199,8 +199,7 @@ struct EngineNextAction { | |||
struct EnginePluginData { | |||
CarlaPlugin* plugin; | |||
float insPeak[2]; | |||
float outsPeak[2]; | |||
float peaks[4]; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
@@ -245,6 +244,7 @@ struct CarlaEngine::ProtectedData { | |||
#else | |||
EnginePluginData* plugins; | |||
#endif | |||
float peaks[4]; | |||
EngineInternalEvents events; | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
@@ -1799,7 +1799,8 @@ protected: | |||
if (! fUiServer.writeMessage(tmpBuf)) | |||
return; | |||
std::sprintf(tmpBuf, "%f:%f:%f:%f\n", plugData.insPeak[0], plugData.insPeak[1], plugData.outsPeak[0], plugData.outsPeak[1]); | |||
std::sprintf(tmpBuf, "%f:%f:%f:%f\n", | |||
plugData.peaks[0], plugData.peaks[1], plugData.peaks[2], plugData.peaks[3]); | |||
if (! fUiServer.writeMessage(tmpBuf)) | |||
return; | |||
@@ -400,7 +400,8 @@ void CarlaEngine::oscSend_control_set_peaks(const uint pluginId) const noexcept | |||
char targetPath[std::strlen(pData->oscData->path)+11]; | |||
std::strcpy(targetPath, pData->oscData->path); | |||
std::strcat(targetPath, "/set_peaks"); | |||
try_lo_send(pData->oscData->target, targetPath, "iffff", static_cast<int32_t>(pluginId), epData.insPeak[0], epData.insPeak[1], epData.outsPeak[0], epData.outsPeak[1]); | |||
try_lo_send(pData->oscData->target, targetPath, "iffff", static_cast<int32_t>(pluginId), | |||
epData.peaks[0], epData.peaks[1], epData.peaks[2], epData.peaks[3]); | |||
} | |||
void CarlaEngine::oscSend_control_exit() const noexcept | |||
@@ -94,6 +94,24 @@ static void event_stream_handler(void) | |||
for (auto session : gSessions) | |||
session->yield(OK, message); | |||
} | |||
if (const uint count = carla_get_current_plugin_count()) | |||
{ | |||
char msgBuf[1024]; | |||
float* peaks; | |||
for (uint i=0; i<count; ++i) | |||
{ | |||
peaks = carla_get_peak_values(i); | |||
CARLA_SAFE_ASSERT_BREAK(peaks != nullptr); | |||
std::snprintf(msgBuf, 1023, "Peaks: %u %f %f %f %f\n", i, peaks[0], peaks[1], peaks[2], peaks[3]); | |||
msgBuf[1023] = '\0'; | |||
for (auto session : gSessions) | |||
session->yield(OK, msgBuf); | |||
} | |||
} | |||
} | |||
// ------------------------------------------------------------------------------------------------------------------- | |||