36 #ifndef DSPFILTERS_STATE_H
37 #define DSPFILTERS_STATE_H
78 template <
typename Sample>
79 inline Sample process1 (
const Sample in,
83 double out = s.m_b0*in + s.m_b1*m_x1 + s.m_b2*m_x2
84 - s.m_a1*m_y1 - s.m_a2*m_y2
91 return static_cast<Sample
> (out);
126 template <
typename Sample>
127 Sample process1 (
const Sample in,
131 double w = in - s.m_a1*m_v1 - s.m_a2*m_v2 + vsa;
132 double out = s.m_b0*w + s.m_b1*m_v1 + s.m_b2*m_v2;
137 return static_cast<Sample
> (out);
178 template <
typename Sample>
179 inline Sample process1 (
const Sample in,
187 out = s.m_b0*m_v + m_s3_1;
188 m_s1 = m_s2_1 - s.m_a1*m_v;
190 m_s3 = s.m_b1*m_v + m_s4_1;
198 return static_cast<Sample
> (out);
231 template <
typename Sample>
232 inline Sample process1 (
const Sample in,
238 out = m_s1_1 + s.m_b0*in + vsa;
239 m_s1 = m_s2_1 + s.m_b1*in - s.m_a1*out;
240 m_s2 = s.m_b2*in - s.m_a2*out;
244 return static_cast<Sample
> (out);
257 template <
int Channels,
class StateType>
265 const int getNumChannels()
const
272 for (
int i = 0; i < Channels; ++i)
276 StateType& operator[] (
int index)
278 assert (index >= 0 && index < Channels);
279 return m_state[index];
282 template <
class Filter,
typename Sample>
283 void process (
int numSamples,
284 Sample*
const* arrayOfChannels,
287 for (
int i = 0; i < Channels; ++i)
288 filter.process (numSamples, arrayOfChannels[i], m_state[i]);
292 StateType m_state[Channels];
296 template <
class StateType>
300 const int getNumChannels()
const
307 throw std::logic_error (
"attempt to reset empty ChannelState");
310 template <
class FilterDesign,
typename Sample>
311 void process (
int numSamples,
312 Sample*
const* arrayOfChannels,
315 throw std::logic_error (
"attempt to process empty ChannelState");