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