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 * |
* Copyright (C) 2005 - 2007 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 * |
21 |
* MA 02111-1307 USA * |
* MA 02111-1307 USA * |
22 |
***************************************************************************/ |
***************************************************************************/ |
23 |
|
|
24 |
|
// Note: the assembly code is currently disabled, as it doesn't fit into |
25 |
|
// the new synthesis core introduced by LS 0.4.0 |
26 |
|
|
27 |
#ifndef __LS_BIQUADFILTER_H__ |
#ifndef __LS_BIQUADFILTER_H__ |
28 |
#define __LS_BIQUADFILTER_H__ |
#define __LS_BIQUADFILTER_H__ |
29 |
|
|
75 |
bq_t y1; |
bq_t y1; |
76 |
bq_t y2; |
bq_t y2; |
77 |
|
|
78 |
|
#if __GNUC__ >= 4 |
79 |
|
float fbc; |
80 |
|
#else |
81 |
const static float fbc = 0.98; |
const static float fbc = 0.98; |
82 |
|
#endif |
83 |
|
|
84 |
/** |
/** |
85 |
* Prevent \a f from going into denormal mode which would slow down |
* Prevent \a f from going into denormal mode which would slow down |
94 |
public: |
public: |
95 |
BiquadFilter() { |
BiquadFilter() { |
96 |
Reset(); |
Reset(); |
97 |
|
#if __GNUC__ >= 4 |
98 |
|
fbc = 0.98f; |
99 |
|
#endif |
100 |
} |
} |
101 |
|
|
102 |
void Reset() { |
void Reset() { |
134 |
return y; |
return y; |
135 |
} |
} |
136 |
|
|
137 |
#if CONFIG_ASM && ARCH_X86 |
#if 0 // CONFIG_ASM && ARCH_X86 |
138 |
// 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 |
139 |
inline void Apply4StepsSSE(biquad_param_t* param) { |
inline void Apply4StepsSSE(biquad_param_t* param) { |
140 |
__asm__ __volatile__ ( |
__asm__ __volatile__ ( |
253 |
return y; |
return y; |
254 |
} |
} |
255 |
|
|
256 |
#if CONFIG_ASM && ARCH_X86 |
#if 0 // CONFIG_ASM && ARCH_X86 |
257 |
// 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 |
258 |
inline void ApplyFB4StepsSSE(biquad_param_t* param, const bq_t &fb) { |
inline void ApplyFB4StepsSSE(biquad_param_t* param, const bq_t &fb) { |
259 |
float xs, ys; |
float xs, ys; |
504 |
bq_t alpha = sn * sinh(M_LN2 / 2.0 * bw * omega / sn); |
bq_t alpha = sn * sinh(M_LN2 / 2.0 * bw * omega / sn); |
505 |
|
|
506 |
const float a0r = 1.0 / (1.0 + alpha); |
const float a0r = 1.0 / (1.0 + alpha); |
507 |
this->b0 = a0r * alpha; |
this->b0 = a0r * sn * 0.71; |
508 |
this->b1 = 0.0; |
this->b1 = 0.0; |
509 |
this->b2 = a0r * -alpha; |
this->b2 = a0r * -sn * 0.71; |
510 |
this->a1 = a0r * (2.0 * cs); |
this->a1 = a0r * (2.0 * cs); |
511 |
this->a2 = a0r * (alpha - 1.0); |
this->a2 = a0r * (alpha - 1.0); |
512 |
} |
} |
518 |
bq_t alpha = sn * sinh(M_LN2 / 2.0 * bw * omega / sn); |
bq_t alpha = sn * sinh(M_LN2 / 2.0 * bw * omega / sn); |
519 |
|
|
520 |
const float a0r = 1.0 / (1.0 + alpha); |
const float a0r = 1.0 / (1.0 + alpha); |
521 |
param->b0 = a0r * alpha; |
param->b0 = a0r * sn * 0.71; |
522 |
param->b1 = 0.0; |
param->b1 = 0.0; |
523 |
param->b2 = a0r * -alpha; |
param->b2 = a0r * -sn * 0.71; |
524 |
param->a1 = a0r * (2.0 * cs); |
param->a1 = a0r * (2.0 * cs); |
525 |
param->a2 = a0r * (alpha - 1.0); |
param->a2 = a0r * (alpha - 1.0); |
526 |
} |
} |