3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
* Copyright (C) 2005 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
26 |
|
|
27 |
#include <math.h> |
#include <math.h> |
28 |
|
|
29 |
|
#include "../../common/global.h" |
30 |
|
|
31 |
/// ln(2) / 2 |
/// ln(2) / 2 |
32 |
#define LN_2_2 0.34657359f |
#define LN_2_2 0.34657359f |
33 |
|
|
72 |
bq_t y1; |
bq_t y1; |
73 |
bq_t y2; |
bq_t y2; |
74 |
|
|
75 |
|
#if __GNUC__ >= 4 |
76 |
|
float fbc; |
77 |
|
#else |
78 |
const static float fbc = 0.98; |
const static float fbc = 0.98; |
79 |
|
#endif |
80 |
|
|
81 |
/** |
/** |
82 |
* Prevent \a f from going into denormal mode which would slow down |
* Prevent \a f from going into denormal mode which would slow down |
91 |
public: |
public: |
92 |
BiquadFilter() { |
BiquadFilter() { |
93 |
Reset(); |
Reset(); |
94 |
|
#if __GNUC__ >= 4 |
95 |
|
fbc = 0.98f; |
96 |
|
#endif |
97 |
} |
} |
98 |
|
|
99 |
void Reset() { |
void Reset() { |
131 |
return y; |
return y; |
132 |
} |
} |
133 |
|
|
134 |
|
#if CONFIG_ASM && ARCH_X86 |
135 |
// expects to find input in xmm0 (xmm0 stays unmodified) and finally leaves output in xmm6 |
// expects to find input in xmm0 (xmm0 stays unmodified) and finally leaves output in xmm6 |
136 |
inline void Apply4StepsSSE(biquad_param_t* param) { |
inline void Apply4StepsSSE(biquad_param_t* param) { |
137 |
__asm__ __volatile__ ( |
__asm__ __volatile__ ( |
218 |
"r" (¶m->b0) /* %2 */ |
"r" (¶m->b0) /* %2 */ |
219 |
); |
); |
220 |
} |
} |
221 |
|
#endif // CONFIG_ASM && ARCH_X86 |
222 |
|
|
223 |
inline bq_t ApplyFB(bq_t x, const bq_t fb) { |
inline bq_t ApplyFB(bq_t x, const bq_t fb) { |
224 |
bq_t y; |
bq_t y; |
250 |
return y; |
return y; |
251 |
} |
} |
252 |
|
|
253 |
|
#if CONFIG_ASM && ARCH_X86 |
254 |
// expects to find input in xmm0 (xmm0 stays unmodified) and finally leaves output in xmm7 |
// expects to find input in xmm0 (xmm0 stays unmodified) and finally leaves output in xmm7 |
255 |
inline void ApplyFB4StepsSSE(biquad_param_t* param, const bq_t &fb) { |
inline void ApplyFB4StepsSSE(biquad_param_t* param, const bq_t &fb) { |
256 |
float xs, ys; |
float xs, ys; |
446 |
:: |
:: |
447 |
); |
); |
448 |
} |
} |
449 |
|
#endif // CONFIG_ASM && ARCH_X86 |
450 |
}; |
}; |
451 |
|
|
452 |
|
/** @brief Lowpass Filter |
453 |
|
* |
454 |
|
* Lowpass filter based on biquad filter implementation. |
455 |
|
*/ |
456 |
class LowpassFilter : public BiquadFilter { |
class LowpassFilter : public BiquadFilter { |
457 |
public: |
public: |
458 |
inline LowpassFilter() : BiquadFilter() {} |
inline LowpassFilter() : BiquadFilter() {} |
486 |
} |
} |
487 |
}; |
}; |
488 |
|
|
489 |
|
/** @brief Bandpass Filter |
490 |
|
* |
491 |
|
* Bandpass filter based on biquad filter implementation. |
492 |
|
*/ |
493 |
class BandpassFilter : public BiquadFilter { |
class BandpassFilter : public BiquadFilter { |
494 |
public: |
public: |
495 |
inline BandpassFilter() : BiquadFilter() {} |
inline BandpassFilter() : BiquadFilter() {} |
523 |
} |
} |
524 |
}; |
}; |
525 |
|
|
526 |
|
/** @brief Highpass Filter |
527 |
|
* |
528 |
|
* Highpass filter based on biquad filter implementation. |
529 |
|
*/ |
530 |
class HighpassFilter : public BiquadFilter { |
class HighpassFilter : public BiquadFilter { |
531 |
public: |
public: |
532 |
inline HighpassFilter() : BiquadFilter() {} |
inline HighpassFilter() : BiquadFilter() {} |