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.

183 lines
7.1KB

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