File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
src/AudioTools/AudioLibs/FFT Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ class WindowFunction {
28
28
virtual void begin (int samples) {
29
29
this ->samples_minus_1 = -1 .0f + samples;
30
30
this ->i_samples = samples;
31
- this ->i_half_samples = samples / 2 - 1 ;
31
+ this ->i_half_samples = samples / 2 ;
32
32
}
33
33
34
34
// / Provides the multipication factor at the indicated position. The result is symetrically mirrored around the center
35
35
inline float factor (int idx) {
36
- float result = idx < i_half_samples ? factor_internal (idx) : factor_internal (i_samples-idx-1 );
36
+ float result = idx <= i_half_samples ? factor_internal (idx) : factor_internal (i_samples-idx-1 );
37
37
return result>1 .0f ? 1 .0f : result;
38
38
}
39
39
@@ -75,9 +75,8 @@ class BufferedWindow : public WindowFunction {
75
75
WindowFunction::begin (samples);
76
76
if (p_wf->samples () != samples) {
77
77
p_wf->begin (samples);
78
- len = samples;
79
- buffer.resize (len);
80
- for (int j = 0 ; j < len; j++) {
78
+ buffer.resize (i_half_samples + 1 );
79
+ for (int j = 0 ; j <= i_half_samples; j++) {
81
80
buffer[j] = p_wf->factor (j);
82
81
}
83
82
}
@@ -89,7 +88,7 @@ class BufferedWindow : public WindowFunction {
89
88
int len;
90
89
91
90
float factor_internal (int idx) override {
92
- if (idx < 0 || idx > len ) return 0.0 ;
91
+ if (idx < 0 || idx > i_half_samples ) return 0.0 ;
93
92
return buffer[idx];
94
93
}
95
94
};
You can’t perform that action at this time.
0 commit comments