Skip to content

Commit 2274b5c

Browse files
committed
FFTWindows replace array with Vector
1 parent 4d7ccc8 commit 2274b5c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/AudioLibs/FFT/FFTWindows.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,25 @@ class BufferedWindow : public WindowFunction {
5757
BufferedWindow(BufferedWindow const&) = delete;
5858
BufferedWindow& operator=(BufferedWindow const&) = delete;
5959

60-
6160
virtual void begin(int samples) {
6261
// process only if there is a change
6362
if (p_wf->samples() != samples) {
6463
p_wf->begin(samples);
6564
len = samples / 2;
66-
if (p_buffer != nullptr) delete[] p_buffer;
67-
p_buffer = new float[len];
65+
buffer.resize(len);
6866
for (int j = 0; j < len; j++) {
69-
p_buffer[j] = p_wf->factor(j);
67+
buffer[j] = p_wf->factor(j);
7068
}
7169
}
7270
}
7371

74-
~BufferedWindow() {
75-
if (p_buffer != nullptr) delete[] p_buffer;
76-
}
77-
7872
inline float factor(int idx) {
79-
return idx < len ? p_buffer[idx] : p_buffer[i_samples - idx];
73+
return idx < len ? buffer[idx] : buffer[i_samples - idx];
8074
}
8175

8276
protected:
8377
WindowFunction* p_wf = nullptr;
84-
float* p_buffer = nullptr;
78+
Vector<float> buffer{0};
8579
int len;
8680
};
8781

0 commit comments

Comments
 (0)