Index: webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc |
diff --git a/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc b/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc |
index 597820b15df2dc861a4bd37ecbece96b396f2899..07b8339277663e8ac48ca5470fdd4fae99b0fc77 100644 |
--- a/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc |
+++ b/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc |
@@ -18,7 +18,9 @@ |
namespace webrtc { |
SinusoidalLinearChirpSource::SinusoidalLinearChirpSource(int sample_rate, |
- int samples, double max_frequency, double delay_samples) |
+ size_t samples, |
+ double max_frequency, |
+ size_t delay_samples) |
: sample_rate_(sample_rate), |
total_samples_(samples), |
max_frequency_(max_frequency), |
@@ -29,8 +31,8 @@ SinusoidalLinearChirpSource::SinusoidalLinearChirpSource(int sample_rate, |
k_ = (max_frequency_ - kMinFrequency) / duration; |
} |
-void SinusoidalLinearChirpSource::Run(int frames, float* destination) { |
- for (int i = 0; i < frames; ++i, ++current_index_) { |
+void SinusoidalLinearChirpSource::Run(size_t frames, float* destination) { |
+ for (size_t i = 0; i < frames; ++i, ++current_index_) { |
// Filter out frequencies higher than Nyquist. |
if (Frequency(current_index_) > 0.5 * sample_rate_) { |
destination[i] = 0; |
@@ -40,7 +42,8 @@ void SinusoidalLinearChirpSource::Run(int frames, float* destination) { |
destination[i] = 0; |
} else { |
// Sinusoidal linear chirp. |
- double t = (current_index_ - delay_samples_) / sample_rate_; |
+ double t = |
+ static_cast<double>(current_index_ - delay_samples_) / sample_rate_; |
destination[i] = |
sin(2 * M_PI * (kMinFrequency * t + (k_ / 2) * t * t)); |
} |
@@ -48,8 +51,8 @@ void SinusoidalLinearChirpSource::Run(int frames, float* destination) { |
} |
} |
-double SinusoidalLinearChirpSource::Frequency(int position) { |
- return kMinFrequency + (position - delay_samples_) * |
+double SinusoidalLinearChirpSource::Frequency(size_t position) { |
+ return kMinFrequency + (static_cast<double>(position) - delay_samples_) * |
(max_frequency_ - kMinFrequency) / total_samples_; |
} |