Skip to content
Snippets Groups Projects
Commit 9df12e2f authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2
Browse files

tone: M_PI is not standard

Fix usage of M_PI constant: it's not C++, even C, standard constant.
Replaced by a direct value in the code.
This also can fix C++14 compatibility on some platforms.

Change-Id: I1b37c5cd4aabc9af2adccf208cc8a793de54a79c
parent e375f828
Branches
Tags
No related merge requests found
...@@ -118,9 +118,10 @@ Tone::genBuffer(const std::string& definition) ...@@ -118,9 +118,10 @@ Tone::genBuffer(const std::string& definition)
void void
Tone::genSin(AudioSample* buffer, int lowFrequency, int highFrequency, size_t nb) Tone::genSin(AudioSample* buffer, int lowFrequency, int highFrequency, size_t nb)
{ {
static constexpr auto PI = 3.141592653589793238462643383279502884L;
const double sr = (double)buffer_->getSampleRate(); const double sr = (double)buffer_->getSampleRate();
const double dx_h = sr ? 2.0 * M_PI * lowFrequency / sr : 0.0; const double dx_h = sr ? 2.0 * PI * lowFrequency / sr : 0.0;
const double dx_l = sr ? 2.0 * M_PI * highFrequency / sr : 0.0; const double dx_l = sr ? 2.0 * PI * highFrequency / sr : 0.0;
static constexpr double DATA_AMPLITUDE = 2048; static constexpr double DATA_AMPLITUDE = 2048;
for (size_t t = 0; t < nb; t ++) { for (size_t t = 0; t < nb; t ++) {
buffer[t] = DATA_AMPLITUDE * (sin(t*dx_h) + sin(t*dx_l)); buffer[t] = DATA_AMPLITUDE * (sin(t*dx_h) + sin(t*dx_l));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment