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.

88 lines
2.6KB

  1. //
  2. // DSPUtilities.h
  3. //
  4. //
  5. //
  6. #ifndef DSPUtilities_h
  7. #define DSPUtilities_h
  8. namespace rack_plugin_Autodafe {
  9. //==============================================================================
  10. // Calculates the frequency of a given pitch (MIDI) value.
  11. double pitchToFreq(double pitch);
  12. //==============================================================================
  13. // Calculates the pitch (MIDI) of a given frequency value
  14. double freqToPitch(double freq);
  15. //==============================================================================
  16. /**
  17. Takes a value as input and clips it according to the min and max values.
  18. Returns the input if (minValue <= in <= maxValue).
  19. If (in < minValue), then return minValue.
  20. If (in > maxValue), then return maxValue.
  21. */
  22. double clipMinMax(double in, double minValue, double maxValue);
  23. //==============================================================================
  24. /**
  25. Takes a value as input and clips it according to the min value.
  26. Returns the input if (minValue <= in).
  27. If (in < minValue), then return minValue.
  28. */
  29. double clipMin(double in, double minValue);
  30. //==============================================================================
  31. /**
  32. Crossfades linearly between two values (in0, in1). The value returned is
  33. determined by the value of the xFadeCtrl argument.
  34. xFadeCtrl Range: 0->1
  35. - xFadeCtrl = 0 (only in0 comes through)
  36. - xFadeCtrl = 0.5 (equal mix of in0 and in1)
  37. - xfadeCtrl = 1 (only in1 comes through)
  38. */
  39. double xFadeLin(double xFadeCtrl, double in0, double in1);
  40. //==============================================================================
  41. /**
  42. Parabolic Controller Shaper:
  43. "Bends" the controller curve torwards the X or Y axis.
  44. input range: (-1..0..1) maps to output range: (-1..0..1).
  45. bend range: (-1..0..1)
  46. - bend = -1 (max bend towards X axis)
  47. - bend = 0 (don't bend)
  48. - bend = 1 (max bend towards Y axis)
  49. */
  50. double parCtrlShaper(double input, double bend);
  51. //==============================================================================
  52. /**
  53. Normalizes a range of values to the range 0->1.
  54. (start/end should probably be the range of a parameter)
  55. - input: the value to be normalized
  56. - start: the start of the input's range
  57. - end: the end of the input's range
  58. Note: (start < end) and (start > end) are both valid.
  59. */
  60. double normalizeRange(double input, double start, double end);
  61. double resonanceToQ(double resonance);
  62. //==============================================================================
  63. } // namespace rack_plugin_Autodafe
  64. using namespace rack_plugin_Autodafe;
  65. #endif /* DSPUtilities_h */