<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Hi John, in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/Examples-of-IPP-Bi-Quad-Filter/m-p/1000977#M23095</link>
    <description>&lt;P&gt;Hi John,&lt;/P&gt;

&lt;P&gt;I don't see any problems in your code (for the 1st glance). IIR BQ always can be represented as AR filter, 1 BQ is an AR filter of the 2nd order. IPP IIR filters work in the same manner as Matlab filters - could you check your approach with Matlab (or any other reference code) and provide some more data: (1) taps in numerical form, (2) input data (also in numerical form) (3) desired output data&amp;nbsp;(in numerical form, from Matlab or some reference code) and (4) output data from IPP function (also in numerical form). If there is any difference between (3) and (4) - I'll help you with correct IPP invoking.&lt;/P&gt;

&lt;P&gt;regards, Igor&lt;/P&gt;</description>
    <pubDate>Thu, 14 May 2015 07:38:55 GMT</pubDate>
    <dc:creator>Igor_A_Intel</dc:creator>
    <dc:date>2015-05-14T07:38:55Z</dc:date>
    <item>
      <title>Examples of IPP Bi-Quad Filter?</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Examples-of-IPP-Bi-Quad-Filter/m-p/1000976#M23094</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I'm trying to use IPP to run a bandpass filter one some audio data (single channel).&lt;/P&gt;

&lt;P&gt;I've written the following class and helper function, but my results seem to be way off the mark. I hope this isn't too much code to dump&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;// BiQuad Coefs
// &lt;A href="http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt" target="_blank"&gt;http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt&lt;/A&gt;
struct BiQuad
{
float coefs[6];
};

// Return bandpass coefficients
BiQuad getBandPass( float f0, float Fs, float Q )
{
	float omega = IPP_2PI * f0 / Fs;
	float alpha = sinf( omega ) / ( 2.f*Q );

	float b0 = sinf( omega ) / 2.f;
	float b1 = 0.f;
	float b2 = -b0;
	float a0 = 1.f + alpha;
	float a1 = -2.f*cosf( omega );
	float a2 = 1.f - alpha;

	// Divide all by a0, set a0 to 1.f
	return{ {b0 / a0, b1 / a0, b2 / a0, 1.f, a1 / a0, a2 / a0} };
}

class IppBiquad
{
	int pBufSize{ 0 };
	int nBQ{ 0 };
	IppsIIRState_32f * m_State{ nullptr };
	Ipp8u * m_pBuf{ nullptr };
public:
	// Default constructor, takes # of cascaded filters
	IppBiquad( int N = 2 )
		: nBQ( N )
	{
		if ( nBQ &amp;gt; 0 )
		{
			ippsIIRGetStateSize_BiQuad_32f( 2, &amp;amp;pBufSize );
			m_pBuf = ippsMalloc_8u( pBufSize );
		}
	}
	// Set the filter components
	inline void setFilt( float f0, float Fs, float Q )
	{
		vector&amp;lt;BiQuad&amp;gt; taps( nBQ, getBandPass( f0, Fs, Q ) );
		ippsIIRInit_BiQuad_DF1_32f( &amp;amp;m_State, (Ipp32f *) taps.data( ), taps.size( ), 0, m_pBuf );
	}
	// Free work buf (Do I need to free the state?)
	~IppBiquad( )
	{
		if ( m_pBuf != nullptr )
			ippsFree( m_pBuf );
	}
	// Run the filter
	inline IppStatus operator()( float * input, float * output, int size )
	{
		if ( input &amp;amp;&amp;amp; output &amp;amp;&amp;amp; size &amp;gt; 0 &amp;amp;&amp;amp; m_State )
			return ippsIIR_32f( input, output, size, m_State );
		return IppStatus::ippStsNullPtrErr;
	}
};&lt;/PRE&gt;

&lt;P&gt;I use the BiQuad Struct to store my 6 float coefficients (taps, according to the docs), the getBandPass function to return the correct normalized taps for a Bandpass filter centered around f0 given the sample rate Fs and Q value, and I use the class in order to manage the work buffer without actually having to manage that.&lt;/P&gt;

&lt;P&gt;When I need to run the filter, I invoke the () (parentheses) operator, sort of making my class like a function. To test the class I made an audio sample with several 500Hz sine wave "chirps" to see if I could get isolate the chirps. However I see the chirps most at very low frequencies (f0=100Hz), and it seems like the amplitude of my output has been changed somehow.&lt;/P&gt;

&lt;P&gt;Am I interpreting the use of the BiQuad functions wrong? None of the examples in the docs actually use a BiQuad, they all use an arbitrary IIR filter (as far as I can tell).&lt;/P&gt;

&lt;P&gt;I apologize in advance if the example is too object oriented; I'm happy to provide some straight C code, I just thought this was a bit clearer. Sorry for the use of std::vector, if anyone is averse to that...&lt;/P&gt;

&lt;P&gt;Thanks for your help,&lt;/P&gt;

&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2015 20:23:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Examples-of-IPP-Bi-Quad-Filter/m-p/1000976#M23094</guid>
      <dc:creator>John_J_2</dc:creator>
      <dc:date>2015-05-13T20:23:14Z</dc:date>
    </item>
    <item>
      <title>Hi John,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Examples-of-IPP-Bi-Quad-Filter/m-p/1000977#M23095</link>
      <description>&lt;P&gt;Hi John,&lt;/P&gt;

&lt;P&gt;I don't see any problems in your code (for the 1st glance). IIR BQ always can be represented as AR filter, 1 BQ is an AR filter of the 2nd order. IPP IIR filters work in the same manner as Matlab filters - could you check your approach with Matlab (or any other reference code) and provide some more data: (1) taps in numerical form, (2) input data (also in numerical form) (3) desired output data&amp;nbsp;(in numerical form, from Matlab or some reference code) and (4) output data from IPP function (also in numerical form). If there is any difference between (3) and (4) - I'll help you with correct IPP invoking.&lt;/P&gt;

&lt;P&gt;regards, Igor&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2015 07:38:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Examples-of-IPP-Bi-Quad-Filter/m-p/1000977#M23095</guid>
      <dc:creator>Igor_A_Intel</dc:creator>
      <dc:date>2015-05-14T07:38:55Z</dc:date>
    </item>
    <item>
      <title>Hi Igor, thanks for the</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Examples-of-IPP-Bi-Quad-Filter/m-p/1000978#M23096</link>
      <description>&lt;P&gt;Hi Igor, thanks for the response.&lt;/P&gt;

&lt;P&gt;Actually I was mistaken, the filter seems correct, however I'm doing some heavy downsampling to the output and that seems to throw off the results. I suppose I should look into the polyphase resampling functions...&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Anyway, thanks for your help, and sorry to waste your time. I'm glad the class is OK.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2015 14:29:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Examples-of-IPP-Bi-Quad-Filter/m-p/1000978#M23096</guid>
      <dc:creator>John_J_2</dc:creator>
      <dc:date>2015-05-14T14:29:36Z</dc:date>
    </item>
  </channel>
</rss>

