Audio plugin host https://kx.studio/carla
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.

juce_Windowing.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. namespace dsp
  21. {
  22. /**
  23. A class which provides multiple windowing functions useful for filter design
  24. and spectrum analyzers.
  25. The different functions provided here can be used by creating either a
  26. WindowingFunction object, or a static function to fill an array with the
  27. windowing method samples.
  28. @tags{DSP}
  29. */
  30. template <typename FloatType>
  31. class JUCE_API WindowingFunction
  32. {
  33. public:
  34. //==============================================================================
  35. /** The windowing methods available. */
  36. enum WindowingMethod
  37. {
  38. rectangular = 0,
  39. triangular,
  40. hann,
  41. hamming,
  42. blackman,
  43. blackmanHarris,
  44. flatTop,
  45. kaiser,
  46. numWindowingMethods
  47. };
  48. //==============================================================================
  49. /** This constructor automatically fills a buffer of the specified size using
  50. the fillWindowingTables function and the specified arguments.
  51. @see fillWindowingTables
  52. */
  53. WindowingFunction (size_t size, WindowingMethod,
  54. bool normalise = true, FloatType beta = 0);
  55. //==============================================================================
  56. /** Fills the content of the object array with a given windowing method table.
  57. @param size the size of the destination buffer allocated in the object
  58. @param type the type of windowing method being used
  59. @param normalise if the result must be normalised, creating a DC amplitude
  60. response of one
  61. @param beta an optional argument useful only for Kaiser's method
  62. which must be positive and sets the properties of the
  63. method (bandwidth and attenuation increases with beta)
  64. */
  65. void fillWindowingTables (size_t size, WindowingMethod type,
  66. bool normalise = true, FloatType beta = 0) noexcept;
  67. /** Fills the content of an array with a given windowing method table.
  68. @param samples the destination buffer pointer
  69. @param size the size of the destination buffer allocated in the object
  70. @param normalise if the result must be normalised, creating a DC amplitude
  71. response of one
  72. @param beta an optional argument useful only for Kaiser's method,
  73. which must be positive and sets the properties of the
  74. method (bandwidth and attenuation increases with beta)
  75. */
  76. static void fillWindowingTables (FloatType* samples, size_t size, WindowingMethod,
  77. bool normalise = true, FloatType beta = 0) noexcept;
  78. /** Multiplies the content of a buffer with the given window. */
  79. void multiplyWithWindowingTable (FloatType* samples, size_t size) noexcept;
  80. /** Returns the name of a given windowing method. */
  81. static const char* getWindowingMethodName (WindowingMethod) noexcept;
  82. private:
  83. //==============================================================================
  84. Array<FloatType> windowTable;
  85. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowingFunction)
  86. };
  87. } // namespace dsp
  88. } // namespace juce