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.

rack0.hpp 6.6KB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 cmultf(float *cr, float *ci, float ar, float ai, float br, float bi) {return complexMult(cr, ci, ar, ai, br, bi);}
  40. ////////////////////
  41. // random
  42. ////////////////////
  43. DEPRECATED inline float randomu32() {return random::u32();}
  44. DEPRECATED inline float randomu64() {return random::u64();}
  45. DEPRECATED inline float randomUniform() {return random::uniform();}
  46. DEPRECATED inline float randomNormal() {return random::normal();}
  47. DEPRECATED inline float randomf() {return random::uniform();}
  48. ////////////////////
  49. // logger
  50. ////////////////////
  51. /** Deprecated lowercase log functions */
  52. #define debug(...) DEBUG(__VA_ARGS__)
  53. #define info(...) INFO(__VA_ARGS__)
  54. #define warn(...) WARN(__VA_ARGS__)
  55. #define fatal(...) FATAL(__VA_ARGS__)
  56. ////////////////////
  57. // asset
  58. ////////////////////
  59. DEPRECATED inline std::string assetGlobal(std::string filename) {return asset::system(filename);}
  60. DEPRECATED inline std::string assetLocal(std::string filename) {return asset::user(filename);}
  61. DEPRECATED inline std::string assetPlugin(Plugin *plugin, std::string filename) {return asset::plugin(plugin, filename);}
  62. ////////////////////
  63. // color
  64. ////////////////////
  65. DEPRECATED inline NVGcolor colorClip(NVGcolor a) {return color::clamp(a);}
  66. DEPRECATED inline NVGcolor colorMinus(NVGcolor a, NVGcolor b) {return color::minus(a, b);}
  67. DEPRECATED inline NVGcolor colorPlus(NVGcolor a, NVGcolor b) {return color::plus(a, b);}
  68. DEPRECATED inline NVGcolor colorMult(NVGcolor a, NVGcolor b) {return color::mult(a, b);}
  69. DEPRECATED inline NVGcolor colorMult(NVGcolor a, float x) {return color::mult(a, x);}
  70. DEPRECATED inline NVGcolor colorScreen(NVGcolor a, NVGcolor b) {return color::screen(a, b);}
  71. DEPRECATED inline NVGcolor colorAlpha(NVGcolor a, float alpha) {return color::alpha(a, alpha);}
  72. DEPRECATED inline NVGcolor colorFromHexString(std::string s) {return color::fromHexString(s);}
  73. DEPRECATED inline std::string colorToHexString(NVGcolor c) {return color::toHexString(c);}
  74. ////////////////////
  75. // componentlibrary
  76. ////////////////////
  77. DEPRECATED static const NVGcolor COLOR_BLACK_TRANSPARENT = componentlibrary::SCHEME_BLACK_TRANSPARENT;
  78. DEPRECATED static const NVGcolor COLOR_BLACK = componentlibrary::SCHEME_BLACK;
  79. DEPRECATED static const NVGcolor COLOR_WHITE = componentlibrary::SCHEME_WHITE;
  80. DEPRECATED static const NVGcolor COLOR_RED = componentlibrary::SCHEME_RED;
  81. DEPRECATED static const NVGcolor COLOR_ORANGE = componentlibrary::SCHEME_ORANGE;
  82. DEPRECATED static const NVGcolor COLOR_YELLOW = componentlibrary::SCHEME_YELLOW;
  83. DEPRECATED static const NVGcolor COLOR_GREEN = componentlibrary::SCHEME_GREEN;
  84. DEPRECATED static const NVGcolor COLOR_CYAN = componentlibrary::SCHEME_CYAN;
  85. DEPRECATED static const NVGcolor COLOR_BLUE = componentlibrary::SCHEME_BLUE;
  86. DEPRECATED static const NVGcolor COLOR_PURPLE = componentlibrary::SCHEME_PURPLE;
  87. DEPRECATED static const NVGcolor COLOR_LIGHT_PANEL = componentlibrary::SCHEME_LIGHT_GRAY;
  88. DEPRECATED static const NVGcolor COLOR_DARK_PANEL = componentlibrary::SCHEME_DARK_GRAY;
  89. ////////////////////
  90. // helpers
  91. ////////////////////
  92. /** Use createWidget() instead */
  93. template <class TScrew>
  94. DEPRECATED TScrew *createScrew(math::Vec pos) {
  95. return createWidget<TScrew>(pos);
  96. }
  97. /** Use createParam(pos, module, paramId) and set the Param properties in your Module constructor */
  98. template <class TParamWidget>
  99. DEPRECATED TParamWidget *createParam(math::Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) {
  100. TParamWidget *o = createParam<TParamWidget>(pos, module, paramId);
  101. if (module) {
  102. module->configParam(paramId, minValue, maxValue, defaultValue);
  103. }
  104. return o;
  105. }
  106. /** Use createInput() and createOutput() without the `type` variable */
  107. template <class TPortWidget>
  108. DEPRECATED TPortWidget *createPort(math::Vec pos, PortWidget::Type type, Module *module, int inputId) {
  109. TPortWidget *o = new TPortWidget;
  110. o->box.pos = pos;
  111. o->type = type;
  112. o->module = module;
  113. o->portId = inputId;
  114. return o;
  115. }
  116. ////////////////////
  117. // engine
  118. ////////////////////
  119. DEPRECATED inline float engineGetSampleRate() {
  120. return APP->engine->getSampleRate();
  121. }
  122. DEPRECATED inline float engineGetSampleTime() {
  123. return APP->engine->getSampleTime();
  124. }
  125. ////////////////////
  126. // dsp
  127. ////////////////////
  128. using namespace dsp;
  129. DEPRECATED inline float gainToDb(float gain) {
  130. return dsp::amplitudeToDb(gain);
  131. }
  132. DEPRECATED inline float dbToGain(float db) {
  133. return dsp::dbToAmplitude(db);
  134. }
  135. } // namespace rack