Skip to content

Commit

Permalink
suppress warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
takenori-y committed Mar 12, 2024
1 parent 2707ebe commit 90a8c11
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif()

set(CMAKE_CXX_STANDARD 11)
if (MSVC)
set(CMAKE_CXX_FLAGS "/O2 /W4 /wd4244 /wd4305 /wd4996 /EHsc")
set(CMAKE_CXX_FLAGS "/O2 /W4 /wd4100 /EHsc")
else()
set(CMAKE_CXX_FLAGS "-O2 -Wall -Wno-deprecated-register")
endif()
Expand Down
5 changes: 3 additions & 2 deletions include/SPTK/utils/int24_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ class int24_t {
int24_t() {
}

explicit int24_t(int initial_value) {
*this = initial_value;
template <typename T>
explicit int24_t(T initial_value) {
*this = static_cast<int>(initial_value);
}

~int24_t() {
Expand Down
5 changes: 3 additions & 2 deletions include/SPTK/utils/uint24_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class uint24_t {
uint24_t() {
}

explicit uint24_t(int initial_value) {
*this = initial_value;
template <typename T>
explicit uint24_t(T initial_value) {
*this = static_cast<int>(initial_value);
}

~uint24_t() {
Expand Down
6 changes: 4 additions & 2 deletions src/analysis/pitch_extraction_by_reaper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "SPTK/analysis/pitch_extraction_by_reaper.h"

#include <algorithm> // std::copy, std::fill
#include <algorithm> // std::copy, std::fill, std::transform
#include <cmath> // std::ceil
#include <cstdint> // int16_t

Expand Down Expand Up @@ -54,7 +54,9 @@ bool PitchExtractionByReaper::Get(

reaper::EpochTracker epoch_tracker;
epoch_tracker.set_unvoiced_cost(static_cast<float>(voicing_threshold_));
std::vector<int16_t> integer_waveform(waveform.begin(), waveform.end());
std::vector<int16_t> integer_waveform(waveform.size());
std::transform(waveform.begin(), waveform.end(), integer_waveform.begin(),
[](double x) { return static_cast<int16_t>(x); });
if (!epoch_tracker.Init(integer_waveform.data(),
static_cast<int32_t>(integer_waveform.size()),
static_cast<float>(sampling_rate_),
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/spectrum_extraction_by_world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool SpectrumExtractionByWorld::Run(
f0_floor = f0[i];
}
}
if (f0_floor < world::GetF0FloorForCheapTrick(sampling_rate_, fft_length_)) {
if (f0_floor < world::GetF0FloorForCheapTrick(static_cast<int>(sampling_rate_), fft_length_)) {
return false;
}

Expand All @@ -73,7 +73,7 @@ bool SpectrumExtractionByWorld::Run(
}

world::CheapTrickOption option;
world::InitializeCheapTrickOption(sampling_rate_, &option);
world::InitializeCheapTrickOption(static_cast<int>(sampling_rate_), &option);
option.fft_size = fft_length_;
option.f0_floor = f0_floor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool AutocorrelationToCompositeSinusoidalModeling::Run(
const int index((l < 2 * k) ? (2 * k - l) : (l - 2 * k));
sum += (binomial_coefficient)*input[index];
}
u[l] = sum / std::pow(2.0, l);
u[l] = static_cast<double>(sum / std::pow(2.0, l));
}

for (int i(0); i < num_sine_wave_; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/acr2csm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int main(int argc, char* argv[]) {
double convergence_threshold(kDefaultConvergenceThreshold);

for (;;) {
const char option_char(getopt_long(argc, argv, "m:i:d:h", NULL, NULL));
const int option_char(getopt_long(argc, argv, "m:i:d:h", NULL, NULL));
if (-1 == option_char) break;

switch (option_char) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/bcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ class BlockCopy : public BlockCopyInterface {
public:
BlockCopy(int input_start_number, int input_end_number,
int input_block_length, int output_start_number,
int output_block_length, T pad_value, bool is_ascii = false)
int output_block_length, double pad_value, bool is_ascii = false)
: input_start_number_(input_start_number),
input_end_number_(input_end_number),
input_block_length_(input_block_length),
output_start_number_(output_start_number),
output_block_length_(output_block_length),
pad_value_(pad_value),
pad_value_(static_cast<T>(pad_value)),
is_ascii_(is_ascii) {
}

Expand Down Expand Up @@ -125,7 +125,7 @@ class BlockCopy : public BlockCopyInterface {
}
if (input_start_number_ <= i && i <= input_end_number_) {
try {
inputs[i] = std::stold(word);
inputs[i] = static_cast<T>(std::stold(word));
} catch (std::invalid_argument&) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/c2acr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int main(int argc, char* argv[]) {
int fft_length(kDefaultFftLength);

for (;;) {
const char option_char(getopt_long(argc, argv, "m:M:l:h", NULL, NULL));
const int option_char(getopt_long(argc, argv, "m:M:l:h", NULL, NULL));
if (-1 == option_char) break;

switch (option_char) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/csm2acr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) {
int num_order(kDefaultNumOrder);

for (;;) {
const char option_char(getopt_long(argc, argv, "m:h", NULL, NULL));
const int option_char(getopt_long(argc, argv, "m:h", NULL, NULL));
if (-1 == option_char) break;

switch (option_char) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/pitch_mark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ int main(int argc, char* argv[]) {

switch (output_format) {
case kBinarySequence: {
int next_pitch_mark(pitch_mark.empty() ? -1 : std::round(pitch_mark[0]));
int next_pitch_mark(pitch_mark.empty() ? -1 : static_cast<int>(std::round(pitch_mark[0])));
for (int i(0), j(1); i < waveform_length; ++i) {
if (i == next_pitch_mark) {
if (!sptk::WriteStream(binary_polarity, &std::cout)) {
Expand All @@ -304,7 +304,7 @@ int main(int argc, char* argv[]) {
return 1;
}
if (j < num_pitch_marks) {
next_pitch_mark = std::round(pitch_mark[j++]);
next_pitch_mark = static_cast<int>(std::round(pitch_mark[j++]));
}
} else {
if (!sptk::WriteStream(0.0, &std::cout)) {
Expand Down Expand Up @@ -334,7 +334,7 @@ int main(int argc, char* argv[]) {
const double bias(kSine == output_format ? 0.0 : 0.5 * sptk::kPi);
for (int n(0), i(0); n <= num_pitch_marks; ++n) {
const int next_pitch_mark(
n < num_pitch_marks ? std::round(pitch_mark[n]) : waveform_length);
n < num_pitch_marks ? static_cast<int>(std::round(pitch_mark[n])) : waveform_length);
// Find the point across voiced region to unvoiced one.
int j(i);
for (; j < next_pitch_mark; ++j) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/x2x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class DataTransform : public DataTransformInterface {
*input_stream >> word;
if (word.empty()) break;
try {
input_data = std::stold(word);
input_data = static_cast<T1>(std::stold(word));
} catch (std::invalid_argument&) {
return false;
}
Expand All @@ -133,7 +133,7 @@ class DataTransform : public DataTransformInterface {
}

// Convert.
T2 output_data(input_data);
T2 output_data(static_cast<T2>(input_data));

bool is_clipped(false);
{
Expand Down
6 changes: 4 additions & 2 deletions src/utils/sptk_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bool ReadStream(bool zero_padding, int stream_skip, int read_point,
return false; // Something wrong!
}

std::fill_n(sequence_to_read->begin() + end - num_zeros, num_zeros, 0.0);
std::fill_n(sequence_to_read->begin() + end - num_zeros, num_zeros, static_cast<T>(0));

return !input_stream->bad();
}
Expand Down Expand Up @@ -336,7 +336,9 @@ bool ConvertSpecialStringToDouble(const std::string& input, double* output) {

std::string lowercase_input(input);
std::transform(input.begin(), input.end(), lowercase_input.begin(),
[](unsigned char c) { return std::tolower(c); });
[](unsigned char c) {
return static_cast<unsigned char>(std::tolower(c));
});
if ("pi" == lowercase_input) {
*output = sptk::kPi;
return true;
Expand Down

0 comments on commit 90a8c11

Please sign in to comment.