Assume 128 buffer size for ildaeil and host audio peaks

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-11-26 00:17:57 +00:00
parent d02a5c6796
commit cd99938fa8
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
3 changed files with 14 additions and 24 deletions

View file

@ -127,20 +127,13 @@ struct HostAudio2 : HostAudio<2> {
#ifndef HEADLESS
// for stereo meter
uint32_t internalDataFrame = 0;
float internalDataBuffer[2][128];
float internalDataBufferL[128] = {};
float internalDataBufferR[128] = {};
volatile bool resetMeters = true;
float gainMeterL = 0.0f;
float gainMeterR = 0.0f;
#endif
HostAudio2()
: HostAudio<2>()
{
#ifndef HEADLESS
std::memset(internalDataBuffer, 0, sizeof(internalDataBuffer));
#endif
}
#ifndef HEADLESS
void onReset() override
{
@ -230,8 +223,8 @@ struct HostAudio2 : HostAudio<2> {
}
const uint32_t j = internalDataFrame++;
internalDataBuffer[0][j] = valueL;
internalDataBuffer[1][j] = valueR;
internalDataBufferL[j] = valueL;
internalDataBufferR[j] = valueR;
if (internalDataFrame == 128)
{
@ -240,10 +233,10 @@ struct HostAudio2 : HostAudio<2> {
if (resetMeters)
gainMeterL = gainMeterR = 0.0f;
gainMeterL = std::max(gainMeterL, d_findMaxNormalizedFloat(internalDataBuffer[0], 128));
gainMeterL = std::max(gainMeterL, d_findMaxNormalizedFloat128(internalDataBufferL));
if (in2connected)
gainMeterR = std::max(gainMeterR, d_findMaxNormalizedFloat(internalDataBuffer[1], 128));
gainMeterR = std::max(gainMeterR, d_findMaxNormalizedFloat128(internalDataBufferR));
else
gainMeterR = gainMeterL;

View file

@ -488,16 +488,16 @@ struct IldaeilModule : Module {
if (resetMeterIn)
meterInL = meterInR = 0.0f;
meterInL = std::max(meterInL, d_findMaxNormalizedFloat(audioDataIn1, BUFFER_SIZE));
meterInR = std::max(meterInR, d_findMaxNormalizedFloat(audioDataIn2, BUFFER_SIZE));
meterInL = std::max(meterInL, d_findMaxNormalizedFloat128(audioDataIn1));
meterInR = std::max(meterInR, d_findMaxNormalizedFloat128(audioDataIn2));
fCarlaPluginDescriptor->process(fCarlaPluginHandle, ins, outs, BUFFER_SIZE, midiEvents, midiEventCount);
if (resetMeterOut)
meterOutL = meterOutR = 0.0f;
meterOutL = std::max(meterOutL, d_findMaxNormalizedFloat(audioDataOut1, BUFFER_SIZE));
meterOutR = std::max(meterOutR, d_findMaxNormalizedFloat(audioDataOut2, BUFFER_SIZE));
meterOutL = std::max(meterOutL, d_findMaxNormalizedFloat128(audioDataOut1));
meterOutR = std::max(meterOutR, d_findMaxNormalizedFloat128(audioDataOut2));
resetMeterIn = resetMeterOut = false;
}

View file

@ -56,19 +56,16 @@ extern std::vector<Model*> hostTerminalModels;
* Find the highest absolute and normalized value within a float array.
*/
static inline
float d_findMaxNormalizedFloat(const float floats[], const std::size_t count)
float d_findMaxNormalizedFloat128(const float floats[128])
{
DISTRHO_SAFE_ASSERT_RETURN(floats != nullptr, 0.0f);
DISTRHO_SAFE_ASSERT_RETURN(count > 0, 0.0f);
static constexpr const float kEmptyFloats[128] = {};
static constexpr const float kEmptyFloats[8192] = {};
if (count <= 8192 && std::memcmp(floats, kEmptyFloats, count) == 0)
if (std::memcmp(floats, kEmptyFloats, sizeof(float)*128) == 0)
return 0.0f;
float tmp, maxf2 = std::abs(floats[0]);
for (std::size_t i=1; i<count; ++i)
for (std::size_t i=1; i<128; ++i)
{
if (!std::isfinite(floats[i]))
__builtin_unreachable();