Skip to content

Commit

Permalink
LADSPA - Fix various floating point errors (#3927)
Browse files Browse the repository at this point in the history
* swh - Dyson Compressor, fix NaN

* swh - shaper_1187, division with 0

* Division with 0 in calf limiter
  • Loading branch information
zonkmachine authored Oct 31, 2017
1 parent 7e107f5 commit 88b940f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions plugins/LadspaEffect/calf/src/audio_fx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ void lookahead_limiter::process(float &left, float &right, float * multi_buffer)
_peak = fabs(buffer[nextpos[j]]) > fabs(buffer[nextpos[j] + 1]) ? fabs(buffer[nextpos[j]]) : fabs(buffer[nextpos[j] + 1]);
// calc a delta to use to reach our incoming peak from the
// stored position
_peak = std::max( _peak, 0.000001f );
_delta = (_limit / peak - (limit * _multi_coeff * weight) / _peak) / (((buffer_size - nextpos[j] + pos) % buffer_size) / channels);
if(_delta < nextdelta[j]) {
// if the buffered delta is more important than the delta
Expand Down
2 changes: 1 addition & 1 deletion plugins/LadspaEffect/swh/dyson_compress_1403.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ static void __attribute__((constructor)) swh_init() {
D_("Release time (s)");
port_range_hints[DYSONCOMPRESS_RELEASE_TIME].HintDescriptor =
LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_LOW;
port_range_hints[DYSONCOMPRESS_RELEASE_TIME].LowerBound = 0;
port_range_hints[DYSONCOMPRESS_RELEASE_TIME].LowerBound = 0.0000001;
port_range_hints[DYSONCOMPRESS_RELEASE_TIME].UpperBound = 1;

/* Parameters for Fast compression ratio */
Expand Down
8 changes: 4 additions & 4 deletions plugins/LadspaEffect/swh/shaper_1187.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ static void runShaper(LADSPA_Handle instance, unsigned long sample_count) {

if (shapep < 1.0f && shapep > -1.0f) {
shape = 1.0f;
} else if (shape < 0) {
shape = -1.0f / shape;
} else if (shapep < 0) {
shape = -1.0f / shapep;
} else {
shape = shapep;
}
Expand Down Expand Up @@ -160,8 +160,8 @@ static void runAddingShaper(LADSPA_Handle instance, unsigned long sample_count)

if (shapep < 1.0f && shapep > -1.0f) {
shape = 1.0f;
} else if (shape < 0) {
shape = -1.0f / shape;
} else if (shapep < 0) {
shape = -1.0f / shapep;
} else {
shape = shapep;
}
Expand Down

0 comments on commit 88b940f

Please sign in to comment.