case FILTER_MODEL_A500:
fs->rc1 = a500e_filter1_a0 * input + (1 - a500e_filter1_a0) * fs->rc1 + DENORMAL_OFFSET;
- fs->rc2 = a500e_filter2_a0 * fs->rc1 + (1-a500e_filter2_a0) * fs->rc2;
+ fs->rc2 = a500e_filter2_a0 * fs->rc1 + (1 - a500e_filter2_a0) * fs->rc2;
normal_output = fs->rc2;
fs->rc3 = filter_a0 * normal_output + (1 - filter_a0) * fs->rc3;
return 0;
}
+double softfloat_tan(double v);
+
/* This computes the 1st order low-pass filter term b0.
* The a1 term is 1.0 - b0. The center frequency marks the -3 dB point. */
#ifndef M_PI
/* Compensate for the bilinear transformation. This allows us to specify the
* stop frequency more exactly, but the filter becomes less steep further
* from stopband. */
- omega = tan (omega / 2) * 2;
- return 1 / (1 + 1 / omega);
+ omega = softfloat_tan (omega / 2.0) * 2.0;
+ float out = 1.0 / (1.0 + 1.0 / omega);
+ return out;
}
void check_prefs_changed_audio (void)
a500e_filter1_a0 = rc_calculate_a0 (currprefs.sound_freq, 6200);
a500e_filter2_a0 = rc_calculate_a0 (currprefs.sound_freq, 20000);
filter_a0 = rc_calculate_a0 (currprefs.sound_freq, 7000);
+ memset (sound_filter_state, 0, sizeof sound_filter_state);
led_filter_audio ();
/* Select the right interpolation method. */
fpp_tst = fp_tst;
fpp_move = fp_move;
}
+
+double softfloat_tan(double v)
+{
+ struct float_status f = { 0 };
+ uae_u32 w1, w2;
+ fpdata fpd = { 0 };
+
+ fpd.fp = v;
+ set_floatx80_rounding_precision(80, &f);
+ set_float_rounding_mode(float_round_to_zero, &f);
+ fp_from_double(&fpd, &w1, &w2);
+ floatx80 fv = float64_to_floatx80(((uae_u64)w1 << 32) | w2, &fs);
+ fv = floatx80_tan(fv, &fs);
+ float64 f64 = floatx80_to_float64(fv, &fs);
+ fp_to_double(&fpd, f64 >> 32, (uae_u32)f64);
+ return fpd.fp;
+}