You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
6.4KB

  1. #pragma once
  2. #include "rack.hpp"
  3. #include "componentlibrary.hpp"
  4. namespace rack {
  5. ////////////////////
  6. // common
  7. ////////////////////
  8. /** Deprecated lowercase macro */
  9. #define defer(...) DEFER(__VA_ARGS__)
  10. ////////////////////
  11. // math
  12. ////////////////////
  13. using namespace math;
  14. DEPRECATED inline int min(int a, int b) {return std::min(a, b);}
  15. DEPRECATED inline int max(int a, int b) {return std::max(a, b);}
  16. DEPRECATED inline int eucmod(int a, int base) {return eucMod(a, base);}
  17. DEPRECATED inline bool ispow2(int n) {return isPow2(n);}
  18. DEPRECATED inline int clamp2(int x, int a, int b) {return clampSafe(x, a, b);}
  19. DEPRECATED inline float min(float a, float b) {return std::min(a, b);}
  20. DEPRECATED inline float max(float a, float b) {return std::max(a, b);}
  21. DEPRECATED inline float eucmod(float a, float base) {return eucMod(a, base);}
  22. DEPRECATED inline float clamp2(float x, float a, float b) {return clampSafe(x, a, b);}
  23. DEPRECATED inline int mini(int a, int b) {return std::min(a, b);}
  24. DEPRECATED inline int maxi(int a, int b) {return std::max(a, b);}
  25. DEPRECATED inline int clampi(int x, int min, int max) {return math::clamp(x, min, max);}
  26. DEPRECATED inline int absi(int a) {return std::abs(a);}
  27. DEPRECATED inline int eucmodi(int a, int base) {return eucMod(a, base);}
  28. DEPRECATED inline int log2i(int n) {return log2(n);}
  29. DEPRECATED inline bool ispow2i(int n) {return isPow2(n);}
  30. DEPRECATED inline float absf(float x) {return std::abs(x);}
  31. DEPRECATED inline float sgnf(float x) {return sgn(x);}
  32. DEPRECATED inline float eucmodf(float a, float base) {return eucMod(a, base);}
  33. DEPRECATED inline bool nearf(float a, float b, float epsilon = 1.0e-6f) {return math::isNear(a, b, epsilon);}
  34. DEPRECATED inline float clampf(float x, float min, float max) {return math::clamp(x, min, max);}
  35. DEPRECATED inline float clamp2f(float x, float min, float max) {return clampSafe(x, min, max);}
  36. DEPRECATED inline float chopf(float x, float eps) {return chop(x, eps);}
  37. DEPRECATED inline float rescalef(float x, float a, float b, float yMin, float yMax) {return math::rescale(x, a, b, yMin, yMax);}
  38. DEPRECATED inline float crossf(float a, float b, float frac) {return crossfade(a, b, frac);}
  39. DEPRECATED inline float interpf(const float *p, float x) {return interpolateLinear(p, x);}
  40. DEPRECATED inline void cmultf(float *cr, float *ci, float ar, float ai, float br, float bi) {return complexMult(cr, ci, ar, ai, br, bi);}
  41. ////////////////////
  42. // random
  43. ////////////////////
  44. DEPRECATED inline float randomu32() {return random::u32();}
  45. DEPRECATED inline float randomu64() {return random::u64();}
  46. DEPRECATED inline float randomUniform() {return random::uniform();}
  47. DEPRECATED inline float randomNormal() {return random::normal();}
  48. DEPRECATED inline float randomf() {return random::uniform();}
  49. ////////////////////
  50. // logger
  51. ////////////////////
  52. /** Deprecated lowercase log functions */
  53. #define debug(...) DEBUG(__VA_ARGS__)
  54. #define info(...) INFO(__VA_ARGS__)
  55. #define warn(...) WARN(__VA_ARGS__)
  56. #define fatal(...) FATAL(__VA_ARGS__)
  57. ////////////////////
  58. // asset
  59. ////////////////////
  60. DEPRECATED inline std::string assetGlobal(std::string filename) {return asset::system(filename);}
  61. DEPRECATED inline std::string assetLocal(std::string filename) {return asset::user(filename);}
  62. DEPRECATED inline std::string assetPlugin(Plugin *plugin, std::string filename) {return asset::plugin(plugin, filename);}
  63. ////////////////////
  64. // color
  65. ////////////////////
  66. DEPRECATED inline NVGcolor colorClip(NVGcolor a) {return color::clip(a);}
  67. DEPRECATED inline NVGcolor colorMinus(NVGcolor a, NVGcolor b) {return color::minus(a, b);}
  68. DEPRECATED inline NVGcolor colorPlus(NVGcolor a, NVGcolor b) {return color::plus(a, b);}
  69. DEPRECATED inline NVGcolor colorMult(NVGcolor a, NVGcolor b) {return color::mult(a, b);}
  70. DEPRECATED inline NVGcolor colorMult(NVGcolor a, float x) {return color::mult(a, x);}
  71. DEPRECATED inline NVGcolor colorScreen(NVGcolor a, NVGcolor b) {return color::screen(a, b);}
  72. DEPRECATED inline NVGcolor colorAlpha(NVGcolor a, float alpha) {return color::alpha(a, alpha);}
  73. DEPRECATED inline NVGcolor colorFromHexString(std::string s) {return color::fromHexString(s);}
  74. DEPRECATED inline std::string colorToHexString(NVGcolor c) {return color::toHexString(c);}
  75. ////////////////////
  76. // componentlibrary
  77. ////////////////////
  78. DEPRECATED static const NVGcolor COLOR_BLACK_TRANSPARENT = SCHEME_BLACK_TRANSPARENT;
  79. DEPRECATED static const NVGcolor COLOR_BLACK = SCHEME_BLACK;
  80. DEPRECATED static const NVGcolor COLOR_WHITE = SCHEME_WHITE;
  81. DEPRECATED static const NVGcolor COLOR_RED = SCHEME_RED;
  82. DEPRECATED static const NVGcolor COLOR_ORANGE = SCHEME_ORANGE;
  83. DEPRECATED static const NVGcolor COLOR_YELLOW = SCHEME_YELLOW;
  84. DEPRECATED static const NVGcolor COLOR_GREEN = SCHEME_GREEN;
  85. DEPRECATED static const NVGcolor COLOR_CYAN = SCHEME_CYAN;
  86. DEPRECATED static const NVGcolor COLOR_BLUE = SCHEME_BLUE;
  87. DEPRECATED static const NVGcolor COLOR_PURPLE = SCHEME_PURPLE;
  88. DEPRECATED static const NVGcolor COLOR_LIGHT_PANEL = SCHEME_LIGHT_PANEL;
  89. DEPRECATED static const NVGcolor COLOR_DARK_PANEL = SCHEME_DARK_PANEL;
  90. ////////////////////
  91. // helpers
  92. ////////////////////
  93. /** Use createWidget() instead */
  94. template <class TScrew>
  95. DEPRECATED TScrew *createScrew(math::Vec pos) {
  96. return createWidget<TScrew>(pos);
  97. }
  98. /** Use createParam(pos, module, paramId) and set the Param properties in your Module constructor */
  99. template <class TParamWidget>
  100. DEPRECATED TParamWidget *createParam(math::Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) {
  101. TParamWidget *o = createParam<TParamWidget>(pos, module, paramId);
  102. if (module) {
  103. module->params[paramId].config(minValue, maxValue, defaultValue);
  104. }
  105. return o;
  106. }
  107. /** Use createInput() and createOutput() without the `type` variable */
  108. template <class TPortWidget>
  109. DEPRECATED TPortWidget *createPort(math::Vec pos, PortWidget::Type type, Module *module, int inputId) {
  110. TPortWidget *o = new TPortWidget;
  111. o->box.pos = pos;
  112. o->type = type;
  113. o->module = module;
  114. o->portId = inputId;
  115. return o;
  116. }
  117. ////////////////////
  118. // engine
  119. ////////////////////
  120. DEPRECATED inline float engineGetSampleRate() {
  121. return app()->engine->getSampleRate();
  122. }
  123. DEPRECATED inline float engineGetSampleTime() {
  124. return app()->engine->getSampleTime();
  125. }
  126. ////////////////////
  127. // dsp
  128. ////////////////////
  129. using namespace dsp;
  130. DEPRECATED inline float gainToDb(float gain) {
  131. return dsp::amplitudeToDb(gain);
  132. }
  133. DEPRECATED inline float dbToGain(float db) {
  134. return dsp::dbToAmplitude(db);
  135. }
  136. } // namespace rack