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.

84 lines
2.5KB

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