diff --git a/source/backend/engine/CarlaEngineGraph.cpp b/source/backend/engine/CarlaEngineGraph.cpp index d17c4130f..0753e4e5d 100644 --- a/source/backend/engine/CarlaEngineGraph.cpp +++ b/source/backend/engine/CarlaEngineGraph.cpp @@ -22,17 +22,6 @@ #include "CarlaMathUtils.hpp" #include "CarlaMIDI.h" -#include "AppConfig.h" -#include "juce_audio_basics/juce_audio_basics.h" - -using juce::AudioBuffer; -using juce::FloatVectorOperations; -using juce::MemoryBlock; -using juce::String; -using juce::StringArray; -using juce::jmin; -using juce::jmax; - CARLA_BACKEND_START_NAMESPACE // ----------------------------------------------------------------------- @@ -799,7 +788,6 @@ void RackGraph::process(CarlaEngine::ProtectedData* const data, const float* inB uint32_t oldAudioOutCount = 0; uint32_t oldMidiOutCount = 0; bool processed = false; - juce::Range range; // process plugins for (uint i=0; i < data->curPluginCount; ++i) @@ -866,11 +854,8 @@ void RackGraph::process(CarlaEngine::ProtectedData* const data, const float* inB if (oldAudioInCount > 0) { - range = FloatVectorOperations::findMinAndMax(inBuf0, frames); - pluginData.insPeak[0] = carla_maxLimited(std::abs(range.getStart()), std::abs(range.getEnd()), 1.0f); - - range = FloatVectorOperations::findMinAndMax(inBuf1, frames); - pluginData.insPeak[1] = carla_maxLimited(std::abs(range.getStart()), std::abs(range.getEnd()), 1.0f); + pluginData.insPeak[0] = carla_findMaxNormalizedFloat(inBuf0, frames); + pluginData.insPeak[1] = carla_findMaxNormalizedFloat(inBuf1, frames); } else { @@ -880,11 +865,8 @@ void RackGraph::process(CarlaEngine::ProtectedData* const data, const float* inB if (oldAudioOutCount > 0) { - range = FloatVectorOperations::findMinAndMax(outBuf[0], frames); - pluginData.outsPeak[0] = carla_maxLimited(std::abs(range.getStart()), std::abs(range.getEnd()), 1.0f); - - range = FloatVectorOperations::findMinAndMax(outBuf[1], frames); - pluginData.outsPeak[1] = carla_maxLimited(std::abs(range.getStart()), std::abs(range.getEnd()), 1.0f); + pluginData.outsPeak[0] = carla_findMaxNormalizedFloat(outBuf[0], frames); + pluginData.outsPeak[1] = carla_findMaxNormalizedFloat(outBuf[1], frames); } else { diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 46a70e315..9331eed0b 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -35,13 +35,10 @@ #include "CarlaNative.hpp" #include "AppConfig.h" -#include "juce_audio_basics/juce_audio_basics.h" +#include "juce_core/juce_core.h" using juce::File; -using juce::FloatVectorOperations; using juce::MemoryOutputStream; -using juce::ScopedPointer; -using juce::SharedResourcePointer; using juce::String; using juce::XmlDocument; using juce::XmlElement; @@ -1348,10 +1345,10 @@ protected: if (pData->curPluginCount == 0) { if (outBuffer[0] != inBuffer[0]) - FloatVectorOperations::copy(outBuffer[0], inBuffer[0], static_cast(frames)); + carla_copyFloats(outBuffer[0], inBuffer[0], frames); if (outBuffer[1] != inBuffer[1]) - FloatVectorOperations::copy(outBuffer[1], inBuffer[1], static_cast(frames)); + carla_copyFloats(outBuffer[1], inBuffer[1], frames); for (uint32_t i=0; i < midiEventCount; ++i) { diff --git a/source/backend/plugin/CarlaPluginVST2.cpp b/source/backend/plugin/CarlaPluginVST2.cpp index 14f153b63..e9abcb545 100644 --- a/source/backend/plugin/CarlaPluginVST2.cpp +++ b/source/backend/plugin/CarlaPluginVST2.cpp @@ -1,6 +1,6 @@ /* * Carla VST Plugin - * Copyright (C) 2011-2016 Filipe Coelho + * Copyright (C) 2011-2017 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -23,8 +23,6 @@ #include "CarlaMathUtils.hpp" #include "CarlaPluginUI.hpp" -#include "juce_core/juce_core.h" - #include #undef VST_FORCE_DEPRECATED @@ -33,8 +31,6 @@ #undef kEffectMagic #define kEffectMagic (CCONST( 'V', 's', 't', 'P' )) -using juce::File; - CARLA_BACKEND_START_NAMESPACE // ----------------------------------------------------- @@ -1891,7 +1887,9 @@ protected: ret = kVstProcessLevelRealtime; } else + { ret = kVstProcessLevelUser; + } break; case audioMasterGetAutomationState: diff --git a/source/bridges-plugin/CarlaBridgeLV2.cpp b/source/bridges-plugin/CarlaBridgeLV2.cpp index 2eb1e31be..6551ac59a 100644 --- a/source/bridges-plugin/CarlaBridgeLV2.cpp +++ b/source/bridges-plugin/CarlaBridgeLV2.cpp @@ -27,9 +27,8 @@ #include "CarlaLv2Utils.hpp" #include "CarlaUtils.h" -#include "juce_audio_basics/juce_audio_basics.h" - -using juce::FloatVectorOperations; +#include "AppConfig.h" +#include "juce_core/juce_core.h" // --------------------------------------------------------------------------------------------------------------------- diff --git a/source/bridges-ui/CarlaBridgeUI-LV2.cpp b/source/bridges-ui/CarlaBridgeUI-LV2.cpp index b54e934aa..9e38f9526 100644 --- a/source/bridges-ui/CarlaBridgeUI-LV2.cpp +++ b/source/bridges-ui/CarlaBridgeUI-LV2.cpp @@ -21,6 +21,7 @@ #include "CarlaMIDI.h" #include "LinkedList.hpp" +#include "AppConfig.h" #include "juce_core/juce_core.h" #include diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index 384b9befa..33c4a916b 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -21,8 +21,6 @@ #include "CarlaMIDI.h" #include "LinkedList.hpp" -#include "AppConfig.h" - #ifdef BUILD_BRIDGE # undef HAVE_FLUIDSYNTH # undef HAVE_LINUXSAMPLER @@ -47,6 +45,7 @@ #include +#include "AppConfig.h" #include "juce_core/juce_core.h" #define DISCOVERY_OUT(x, y) std::cout << "\ncarla-discovery::" << x << "::" << y << std::endl; diff --git a/source/native-plugins/_data.cpp b/source/native-plugins/_data.cpp index bc174d465..17146c11f 100644 --- a/source/native-plugins/_data.cpp +++ b/source/native-plugins/_data.cpp @@ -259,90 +259,6 @@ static const NativePluginDescriptor sNativePluginDescriptors[] = { /* copyright */ "GNU GPL v2+", DESCFUNCS }, -{ - /* category */ NATIVE_PLUGIN_CATEGORY_OTHER, - /* hints */ static_cast(NATIVE_PLUGIN_IS_SYNTH - |NATIVE_PLUGIN_HAS_UI - //|NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS - |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD - |NATIVE_PLUGIN_USES_STATE - |NATIVE_PLUGIN_USES_TIME), - /* supports */ static_cast(NATIVE_PLUGIN_SUPPORTS_EVERYTHING), - /* audioIns */ 2, - /* audioOuts */ 2, - /* midiIns */ 1, - /* midiOuts */ 1, - /* paramIns */ 0, - /* paramOuts */ 0, - /* name */ "Carla-Patchbay", - /* label */ "carlapatchbay", - /* maker */ "falkTX", - /* copyright */ "GNU GPL v2+", - DESCFUNCS -}, -{ - /* category */ NATIVE_PLUGIN_CATEGORY_OTHER, - /* hints */ static_cast(NATIVE_PLUGIN_IS_SYNTH - |NATIVE_PLUGIN_HAS_UI - //|NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS - |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD - |NATIVE_PLUGIN_USES_STATE - |NATIVE_PLUGIN_USES_TIME), - /* supports */ static_cast(NATIVE_PLUGIN_SUPPORTS_EVERYTHING), - /* audioIns */ 3, - /* audioOuts */ 2, - /* midiIns */ 1, - /* midiOuts */ 1, - /* paramIns */ 0, - /* paramOuts */ 0, - /* name */ "Carla-Patchbay (sidechain)", - /* label */ "carlapatchbay3s", - /* maker */ "falkTX", - /* copyright */ "GNU GPL v2+", - DESCFUNCS -}, -{ - /* category */ NATIVE_PLUGIN_CATEGORY_OTHER, - /* hints */ static_cast(NATIVE_PLUGIN_IS_SYNTH - |NATIVE_PLUGIN_HAS_UI - //|NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS - |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD - |NATIVE_PLUGIN_USES_STATE - |NATIVE_PLUGIN_USES_TIME), - /* supports */ static_cast(NATIVE_PLUGIN_SUPPORTS_EVERYTHING), - /* audioIns */ 16, - /* audioOuts */ 16, - /* midiIns */ 1, - /* midiOuts */ 1, - /* paramIns */ 0, - /* paramOuts */ 0, - /* name */ "Carla-Patchbay (16chan)", - /* label */ "carlapatchbay16", - /* maker */ "falkTX", - /* copyright */ "GNU GPL v2+", - DESCFUNCS -}, -{ - /* category */ NATIVE_PLUGIN_CATEGORY_OTHER, - /* hints */ static_cast(NATIVE_PLUGIN_IS_SYNTH - |NATIVE_PLUGIN_HAS_UI - //|NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS - |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD - |NATIVE_PLUGIN_USES_STATE - |NATIVE_PLUGIN_USES_TIME), - /* supports */ static_cast(NATIVE_PLUGIN_SUPPORTS_EVERYTHING), - /* audioIns */ 32, - /* audioOuts */ 32, - /* midiIns */ 1, - /* midiOuts */ 1, - /* paramIns */ 0, - /* paramOuts */ 0, - /* name */ "Carla-Patchbay (32chan)", - /* label */ "carlapatchbay32", - /* maker */ "falkTX", - /* copyright */ "GNU GPL v2+", - DESCFUNCS -}, #endif // ----------------------------------------------------------------------- diff --git a/source/utils/CarlaDssiUtils.cpp b/source/utils/CarlaDssiUtils.cpp index 6f2670c13..b363e699f 100644 --- a/source/utils/CarlaDssiUtils.cpp +++ b/source/utils/CarlaDssiUtils.cpp @@ -1,6 +1,6 @@ /* * Carla DSSI utils - * Copyright (C) 2013-2016 Filipe Coelho + * Copyright (C) 2013-2017 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -17,6 +17,7 @@ #include "CarlaDssiUtils.hpp" +#include "AppConfig.h" #include "juce_core/juce_core.h" // -------------------------------------------------------------------------------------------------------------------- diff --git a/source/utils/CarlaMathUtils.hpp b/source/utils/CarlaMathUtils.hpp index 14bf37b64..36264fc98 100644 --- a/source/utils/CarlaMathUtils.hpp +++ b/source/utils/CarlaMathUtils.hpp @@ -200,6 +200,36 @@ void carla_zeroFloats(float floats[], const std::size_t count) noexcept std::memset(floats, 0, count*sizeof(float)); } +/* + * Find the highest absolute and normalized value within a float array. + */ +static inline +float carla_findMaxNormalizedFloat(float floats[], const std::size_t count) +{ + CARLA_SAFE_ASSERT_RETURN(floats != nullptr, 0.0f); + CARLA_SAFE_ASSERT_RETURN(count > 0, 0.0f); + + static const float kEmptyFloats[8192] = { 0.0f }; + + if (count <= 8192 && std::memcmp(floats, kEmptyFloats, count) == 0) + return 0.0f; + + float tmp, maxf2 = std::abs(floats[0]); + + for (std::size_t i=1; i tmp) + maxf2 = tmp; + } + + if (maxf2 > 1.0f) + maxf2 = 1.0f; + + return maxf2; +} + // -------------------------------------------------------------------------------------------------------------------- // Missing functions in old OSX versions.