Skip to content

Commit

Permalink
inline instead of static
Browse files Browse the repository at this point in the history
  • Loading branch information
zsliu98 committed Jun 23, 2023
1 parent 03884a1 commit c6c0d8f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 40 deletions.
20 changes: 8 additions & 12 deletions Source/DSP/dsp_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ namespace ZLDsp {
enum {
rms, lufs, rms_g, loudnessNUM
};

template<typename FloatType>
static std::vector<FloatType> getEmptyLoudness() {
return std::vector<FloatType>(loudnessNUM, -180);
Expand Down Expand Up @@ -137,8 +138,7 @@ namespace ZLDsp {
};
};

static juce::AudioProcessorValueTreeState::ParameterLayout
getParameterLayout() {
inline juce::AudioProcessorValueTreeState::ParameterLayout getParameterLayout() {
juce::AudioProcessorValueTreeState::ParameterLayout layout;
layout.add(strength::get(), gate::get(), target::get(), gain::get(),
bound::get(), ceil::get(), mode::get(), period::get(),
Expand All @@ -147,30 +147,26 @@ namespace ZLDsp {
}

template<typename T, size_t elementSize>
juce::String VectorToBase64String(const T &vec) {
inline juce::String VectorToBase64String(const T &vec) {
juce::MemoryBlock mb(vec.data(), vec.size() * elementSize);
return mb.toBase64Encoding();
}

template<typename T>
juce::String VectorToBase64String(const std::vector<T> &vec) {
inline juce::String VectorToBase64String(const std::vector<T> &vec) {
return VectorToBase64String<std::vector<T>, sizeof(T)>(vec);
}

template<typename T>
std::vector<T> Base64StringToVector(const juce::String &str) {
inline std::vector<T> Base64StringToVector(const juce::String &str) {
juce::MemoryBlock mb;
if (mb.fromBase64Encoding(str)) {
juce::Array <T> arr(static_cast<T *>(mb.getData()),
static_cast<int>(mb.getSize() / sizeof(T)));
juce::Array<T> arr(static_cast<T *>(mb.getData()),
static_cast<int>(mb.getSize() / sizeof(T)));
std::vector<T> vec;
// vec.resize(static_cast<size_t>(arr.size()));
for (auto& a: arr) {
for (auto &a: arr) {
vec.push_back(a);
}
// for (size_t i = 0; i < vec.size(); ++i) {
// vec[i] = arr[static_cast<int>(i)];
// }
return vec;
}

Expand Down
56 changes: 28 additions & 28 deletions Source/GUI/interface_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
#include "juce_gui_basics/juce_gui_basics.h"

namespace ZLInterface {
auto static const WindowHeight = 280;
auto static const WindowWidth = 385;
auto static const WindowFixedAspectRatio = 1.375;
auto static const WindowMinHeight = 200;
auto static const WindowMinWidth = 275;
auto static const WindowMaxHeight = WindowMinHeight * 10;
auto static const WindowMaxWidth = WindowMinWidth * 10;
auto inline const WindowHeight = 280;
auto inline const WindowWidth = 385;
auto inline const WindowFixedAspectRatio = 1.375;
auto inline const WindowMinHeight = 200;
auto inline const WindowMinWidth = 275;
auto inline const WindowMaxHeight = WindowMinHeight * 10;
auto inline const WindowMaxWidth = WindowMinWidth * 10;


auto static const TextColor = juce::Colour(87, 96, 110);
auto static const TextInactiveColor = TextColor.withAlpha(0.5f);
auto static const TextHideColor = TextColor.withAlpha(0.25f);
auto static const BackgroundColor = juce::Colour(214, 223, 236);
auto static const BackgroundInactiveColor = BackgroundColor.withAlpha(0.8f);
auto static const BackgroundHideColor = BackgroundColor.withAlpha(0.5f);
auto static const DarkShadowColor = juce::Colour(168, 172, 178);
auto static const BrightShadowColor = juce::Colour(237, 246, 255);
auto inline const TextColor = juce::Colour(87, 96, 110);
auto inline const TextInactiveColor = TextColor.withAlpha(0.5f);
auto inline const TextHideColor = TextColor.withAlpha(0.25f);
auto inline const BackgroundColor = juce::Colour(214, 223, 236);
auto inline const BackgroundInactiveColor = BackgroundColor.withAlpha(0.8f);
auto inline const BackgroundHideColor = BackgroundColor.withAlpha(0.5f);
auto inline const DarkShadowColor = juce::Colour(168, 172, 178);
auto inline const BrightShadowColor = juce::Colour(237, 246, 255);

auto static const FontTiny = 0.5f;
auto static const FontSmall = 0.75f;
auto static const FontNormal = 1.0f;
auto static const FontLarge = 1.25f;
auto static const FontHuge = 1.5f;
auto static const FontHuge2 = 3.0f;
auto static const FontHuge3 = 4.5f;
auto inline const FontTiny = 0.5f;
auto inline const FontSmall = 0.75f;
auto inline const FontNormal = 1.0f;
auto inline const FontLarge = 1.25f;
auto inline const FontHuge = 1.5f;
auto inline const FontHuge2 = 3.0f;
auto inline const FontHuge3 = 4.5f;

auto static const RefreshFreqHz = 120;
auto inline const RefreshFreqHz = 120;

static juce::Rectangle<float> fillRoundedShadowRectangle(juce::Graphics &g,
inline juce::Rectangle<float> fillRoundedShadowRectangle(juce::Graphics &g,
juce::Rectangle<float> boxBounds,
float cornerSize,
bool curveTopLeft = true,
Expand Down Expand Up @@ -69,7 +69,7 @@ namespace ZLInterface {
return boxBounds;
}

static juce::Rectangle<float> fillRoundedInnerShadowRectangle(juce::Graphics &g,
inline juce::Rectangle<float> fillRoundedInnerShadowRectangle(juce::Graphics &g,
juce::Rectangle<float> boxBounds,
float cornerSize,
float blurRadius,
Expand Down Expand Up @@ -121,7 +121,7 @@ namespace ZLInterface {
return boxBounds;
}

static juce::Rectangle<float> drawShadowEllipse(juce::Graphics &g,
inline juce::Rectangle<float> drawShadowEllipse(juce::Graphics &g,
juce::Rectangle<float> boxBounds,
float cornerSize,
juce::Colour mainColour = ZLInterface::BackgroundColor,
Expand Down Expand Up @@ -151,7 +151,7 @@ namespace ZLInterface {
return boxBounds;
}

static juce::Rectangle<float> drawInnerShadowEllipse(juce::Graphics &g,
inline juce::Rectangle<float> drawInnerShadowEllipse(juce::Graphics &g,
juce::Rectangle<float> boxBounds,
float cornerSize,
bool flip = false) {
Expand Down Expand Up @@ -190,7 +190,7 @@ namespace ZLInterface {
return boxBounds;
}

static std::string formatFloat(float x, int precision) {
inline std::string formatFloat(float x, int precision) {
std::stringstream stream;
stream << std::fixed << std::setprecision(precision) << x;
return stream.str();
Expand Down

0 comments on commit c6c0d8f

Please sign in to comment.