Skip to content

Commit cf9c9d5

Browse files
committed
Silence various type conversion warnings in dsp libs
1 parent a2ff1df commit cf9c9d5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

dsp/fft.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ namespace signalsmith { namespace fft {
243243

244244
template<bool inverse, typename RandomAccessIterator>
245245
SIGNALSMITH_INLINE void fftStep3(RandomAccessIterator &&origData, const Step &step) {
246-
constexpr complex factor3 = {-0.5, inverse ? 0.8660254037844386 : -0.8660254037844386};
246+
constexpr complex factor3 = {V(-0.5), inverse ? V(0.8660254037844386) : V(-0.8660254037844386)};
247247
const size_t stride = step.innerRepeats;
248248
const complex *origTwiddles = twiddleVector.data() + step.twiddleIndex;
249249

@@ -429,13 +429,13 @@ namespace signalsmith { namespace fft {
429429
size_t hhSize = size/4 + 1;
430430
twiddlesMinusI.resize(hhSize);
431431
for (size_t i = 0; i < hhSize; ++i) {
432-
V rotPhase = -2*M_PI*(modified ? i + 0.5 : i)/size;
432+
V rotPhase = static_cast<V>(-2*M_PI*(modified ? i + 0.5 : i)/size);
433433
twiddlesMinusI[i] = {std::sin(rotPhase), -std::cos(rotPhase)};
434434
}
435435
if (modified) {
436436
modifiedRotations.resize(size/2);
437437
for (size_t i = 0; i < size/2; ++i) {
438-
V rotPhase = -2*M_PI*i/size;
438+
V rotPhase = static_cast<V>(-2*M_PI*i/size);
439439
modifiedRotations[i] = {std::cos(rotPhase), std::sin(rotPhase)};
440440
}
441441
}

dsp/spectral.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ namespace spectral {
3737
public:
3838
/// Returns a fast FFT size <= `size`
3939
static int fastSizeAbove(int size, int divisor=1) {
40-
return MRFFT::fastSizeAbove(size/divisor)*divisor;
40+
return static_cast<int>(MRFFT::fastSizeAbove(size/divisor)*divisor);
4141
}
4242
/// Returns a fast FFT size >= `size`
4343
static int fastSizeBelow(int size, int divisor=1) {
44-
return MRFFT::fastSizeBelow(1 + (size - 1)/divisor)*divisor;
44+
return static_cast<int>(MRFFT::fastSizeBelow(1 + (size - 1)/divisor)*divisor);
4545
}
4646

4747
WindowedFFT() {}
@@ -86,7 +86,7 @@ namespace spectral {
8686
return this->fftWindow;
8787
}
8888
int size() const {
89-
return mrfft.size();
89+
return static_cast<int>(mrfft.size());
9090
}
9191

9292
/// Performs an FFT (with windowing)
@@ -112,7 +112,7 @@ namespace spectral {
112112
template<class Input, class Output>
113113
void ifft(Input &&input, Output &&output) {
114114
mrfft.ifft(input, timeBuffer);
115-
int fftSize = mrfft.size();
115+
int fftSize = static_cast<int>(mrfft.size());
116116
Sample norm = 1/(Sample)fftSize;
117117

118118
for (int i = 0; i < offsetSamples; ++i) {
@@ -247,8 +247,8 @@ namespace spectral {
247247
if (windowShape == Window::kaiser) {
248248
using Kaiser = ::signalsmith::windows::Kaiser;
249249
/// Roughly optimal Kaiser for STFT analysis (forced to perfect reconstruction)
250-
auto kaiser = Kaiser::withBandwidth(_windowSize/double(_interval), true);
251-
kaiser.fill(window, _windowSize);
250+
auto kaiserWindow = Kaiser::withBandwidth(_windowSize/double(_interval), true);
251+
kaiserWindow.fill(window, _windowSize);
252252
} else {
253253
using Confined = ::signalsmith::windows::ApproximateConfinedGaussian;
254254
auto confined = Confined::withBandwidth(_windowSize/double(_interval));

dsp/windows.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ namespace windows {
158158
for (int i = 0; i < size; ++i) {
159159
double r = (2*i + 1)*invSize - 1;
160160
double arg = std::sqrt(1 - r*r);
161-
data[i] = bessel0(beta*arg)*invB0;
161+
data[i] = static_cast<std::remove_reference_t<decltype(data[i])>>(bessel0(beta*arg)*invB0);
162162
}
163163
}
164164
};
@@ -191,7 +191,7 @@ namespace windows {
191191
double norm = 1/(gaussian(0) - 2*offsetScale*(gaussian(2)));
192192
for (int i = 0; i < size; ++i) {
193193
double r = (2*i + 1)*invSize - 1;
194-
data[i] = norm*(gaussian(r) - offsetScale*(gaussian(r - 2) + gaussian(r + 2)));
194+
data[i] = static_cast<std::remove_reference_t<decltype(data[i])>>(norm*(gaussian(r) - offsetScale*(gaussian(r - 2) + gaussian(r + 2))));
195195
}
196196
}
197197
};
@@ -209,7 +209,7 @@ namespace windows {
209209
}
210210
double factor = 1/std::sqrt(sum2);
211211
for (int index = i; index < windowLength; index += interval) {
212-
data[index] *= factor;
212+
data[index] = static_cast<std::remove_reference_t<decltype(data[index])>>(data[index] * factor);
213213
}
214214
}
215215
}

0 commit comments

Comments
 (0)