Skip to content

Commit

Permalink
Fix "possible loss of data" warnings with MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Dec 7, 2023
1 parent 42893f2 commit fea0b75
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
10 changes: 5 additions & 5 deletions lib/reverb/Reverb.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Lattice
: public DSP::Delay
{
public:
sample_t process (sample_t x, double d)
sample_t process (sample_t x, sample_t d)
{
sample_t y = get();
x -= d*y;
Expand Down Expand Up @@ -126,8 +126,8 @@ class ModLattice

void init (int n, int w)
{
n0 = n;
width = w;
n0 = static_cast<float>(n);
width = static_cast<float>(w);
delay.init (n + w);
}

Expand All @@ -137,9 +137,9 @@ class ModLattice
}

inline sample_t
process (sample_t x, double d)
process (sample_t x, sample_t d)
{
sample_t y = delay.get_linear (n0 + width * lfo.get());
sample_t y = delay.get_linear (n0 + width * static_cast<float>(lfo.get()));
x += d * y;
delay.put (x);
return y - d * x; /* note sign */
Expand Down
11 changes: 4 additions & 7 deletions lib/reverb/dsp/Delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,9 @@ class Delay
sample_t x2 = (*this) [n + 2];

/* sample_t (32bit) quicker than double here */
sample_t a =
(3 * (x0 - x1) - x_1 + x2) * .5;
sample_t b =
2 * x1 + x_1 - (5 * x0 + x2) * .5;
sample_t c =
(x1 - x_1) * .5;
sample_t a = (3 * (x0 - x1) - x_1 + x2) * .5f;
sample_t b = 2 * x1 + x_1 - (5 * x0 + x2) * .5f;
sample_t c = (x1 - x_1) * .5f;

return x0 + (((a * f) + b) * f + c) * f;
}
Expand All @@ -124,7 +121,7 @@ class MovingAverage
void init (uint n)
{
this->Delay::init (n);
over_n = 1. / n;
over_n = 1.f / n;
/* adjust write pointer so we have a full history of zeros */
write = (write + size + 1) & size;
state = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/reverb/dsp/IIR1.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LP1
public:
T a0, b1, y1;

LP1 (double d = 1.)
LP1 (T d = 1.)
{
set (d);
y1 = 0.;
Expand Down

0 comments on commit fea0b75

Please sign in to comment.