Skip to content

Commit

Permalink
Silence various type conversion warnings in dsp libs
Browse files Browse the repository at this point in the history
  • Loading branch information
sagamusix committed Sep 12, 2024
1 parent a2ff1df commit cf9c9d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions dsp/fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ namespace signalsmith { namespace fft {

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

Expand Down Expand Up @@ -429,13 +429,13 @@ namespace signalsmith { namespace fft {
size_t hhSize = size/4 + 1;
twiddlesMinusI.resize(hhSize);
for (size_t i = 0; i < hhSize; ++i) {
V rotPhase = -2*M_PI*(modified ? i + 0.5 : i)/size;
V rotPhase = static_cast<V>(-2*M_PI*(modified ? i + 0.5 : i)/size);
twiddlesMinusI[i] = {std::sin(rotPhase), -std::cos(rotPhase)};
}
if (modified) {
modifiedRotations.resize(size/2);
for (size_t i = 0; i < size/2; ++i) {
V rotPhase = -2*M_PI*i/size;
V rotPhase = static_cast<V>(-2*M_PI*i/size);
modifiedRotations[i] = {std::cos(rotPhase), std::sin(rotPhase)};
}
}
Expand Down
12 changes: 6 additions & 6 deletions dsp/spectral.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ namespace spectral {
public:
/// Returns a fast FFT size <= `size`
static int fastSizeAbove(int size, int divisor=1) {
return MRFFT::fastSizeAbove(size/divisor)*divisor;
return static_cast<int>(MRFFT::fastSizeAbove(size/divisor)*divisor);
}
/// Returns a fast FFT size >= `size`
static int fastSizeBelow(int size, int divisor=1) {
return MRFFT::fastSizeBelow(1 + (size - 1)/divisor)*divisor;
return static_cast<int>(MRFFT::fastSizeBelow(1 + (size - 1)/divisor)*divisor);
}

WindowedFFT() {}
Expand Down Expand Up @@ -86,7 +86,7 @@ namespace spectral {
return this->fftWindow;
}
int size() const {
return mrfft.size();
return static_cast<int>(mrfft.size());
}

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

for (int i = 0; i < offsetSamples; ++i) {
Expand Down Expand Up @@ -247,8 +247,8 @@ namespace spectral {
if (windowShape == Window::kaiser) {
using Kaiser = ::signalsmith::windows::Kaiser;
/// Roughly optimal Kaiser for STFT analysis (forced to perfect reconstruction)
auto kaiser = Kaiser::withBandwidth(_windowSize/double(_interval), true);
kaiser.fill(window, _windowSize);
auto kaiserWindow = Kaiser::withBandwidth(_windowSize/double(_interval), true);
kaiserWindow.fill(window, _windowSize);
} else {
using Confined = ::signalsmith::windows::ApproximateConfinedGaussian;
auto confined = Confined::withBandwidth(_windowSize/double(_interval));
Expand Down
6 changes: 3 additions & 3 deletions dsp/windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace windows {
for (int i = 0; i < size; ++i) {
double r = (2*i + 1)*invSize - 1;
double arg = std::sqrt(1 - r*r);
data[i] = bessel0(beta*arg)*invB0;
data[i] = static_cast<std::remove_reference_t<decltype(data[i])>>(bessel0(beta*arg)*invB0);
}
}
};
Expand Down Expand Up @@ -191,7 +191,7 @@ namespace windows {
double norm = 1/(gaussian(0) - 2*offsetScale*(gaussian(2)));
for (int i = 0; i < size; ++i) {
double r = (2*i + 1)*invSize - 1;
data[i] = norm*(gaussian(r) - offsetScale*(gaussian(r - 2) + gaussian(r + 2)));
data[i] = static_cast<std::remove_reference_t<decltype(data[i])>>(norm*(gaussian(r) - offsetScale*(gaussian(r - 2) + gaussian(r + 2))));
}
}
};
Expand All @@ -209,7 +209,7 @@ namespace windows {
}
double factor = 1/std::sqrt(sum2);
for (int index = i; index < windowLength; index += interval) {
data[index] *= factor;
data[index] = static_cast<std::remove_reference_t<decltype(data[index])>>(data[index] * factor);
}
}
}
Expand Down

0 comments on commit cf9c9d5

Please sign in to comment.