<?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 Hello,   in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/ippsResamplePolyphase-sample-usage-quesiton/m-p/1041386#M23820</link>
    <description>&lt;P&gt;Hello, &amp;nbsp;&lt;/P&gt;

&lt;P&gt;The sample code take the raw PCM files. &amp;nbsp; For a wave file, it also include wave header. &amp;nbsp; When you save to &amp;nbsp;a wave file, you also need to handle the wave headers.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
	Chao&lt;/P&gt;</description>
    <pubDate>Mon, 16 Mar 2015 05:36:53 GMT</pubDate>
    <dc:creator>Chao_Y_Intel</dc:creator>
    <dc:date>2015-03-16T05:36:53Z</dc:date>
    <item>
      <title>ippsResamplePolyphase sample usage quesiton</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/ippsResamplePolyphase-sample-usage-quesiton/m-p/1041385#M23819</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I need to resample my signal from 44100 hZ to 8000 hZ with similar method that Matlab does. As Matlab's help description says that resample method uses polyphase implementation:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;resample&amp;nbsp; Change the sampling rate of a signal.&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; Y = resample(X,P,Q) resamples the sequence in vector X at P/Q times&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; the original sample rate using a polyphase implementation.&amp;nbsp; Y is P/Q&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; times the length of X (or the ceiling of this if P/Q is not an integer). &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; P and Q must be positive integers.&lt;/P&gt;

&lt;P&gt;I wanted to try IPP's resampling. But I don't quite get it. I found in documentation such example of usage:&lt;/P&gt;

&lt;P&gt;void resampleIPP(&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; int&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inRate,&amp;nbsp;&amp;nbsp;&amp;nbsp; // input frequency&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; int&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRate,&amp;nbsp;&amp;nbsp; // output frequency&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE&amp;nbsp;&amp;nbsp;&amp;nbsp; *infd,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // input pcm file&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE&amp;nbsp;&amp;nbsp;&amp;nbsp; *outfd)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // output pcm file&lt;BR /&gt;
	&amp;nbsp;{&amp;nbsp; short *inBuf,*outBuf;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; int bufsize=4096;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; int history=128;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; double time=history;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; int lastread=history;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; int inCount=0,outCount=0,inLen,outLen;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; int size,len,height;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; IppsResamplingPolyphaseFixed_16s *state;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsResamplePolyphaseFixedGetSize_16s(inRate,outRate,2*(history-1),&amp;amp;size,&amp;amp;len,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;height,ippAlgHintAccurate);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; state=(IppsResamlingPolyphaseFixed_16s*)ippsMalloc_8u(size);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsResamplePolyphaseFixedInit_16s(inRate,outRate,2*(history-1),0.95f,9.0f,state,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ippAlgHintAccurate);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; inBuf=ippsMalloc_16s(bufsize+history+2);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; outBuf=ippsMalloc_16s((int)((bufsize-history)*outRate/(float)inRate+2));&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsZero_16s(inBuf,history);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; while ((inLen=fread(inBuf+lastread,sizeof(short),bufsize-lastread,infd))&amp;gt;0) {&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inCount+=inLen;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lastread+=inLen;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsResamplePolyphaseFixed_16s(inBuf,lastread-history-(int)time,&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outBuf,0.98f,&amp;amp;time,&amp;amp;outLen,state);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fwrite(outBuf,outLen,sizeof(short),outfd);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outCount+=outLen;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsMove_16s(inBuf+(int)time-history,inBuf,lastread+history-(int)time);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lastread-=(int)time-history;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; time-=(int)time-history;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsZero_16s(inBuf+lastread,history);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsResamplePolyphaseFixed_16s(inBuf,lastread-(int)time,&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outBuf,0.98f,&amp;amp;time,&amp;amp;outLen,state);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; fwrite(outBuf,outLen,sizeof(short),outfd);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; outCount+=outLen;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("%d inputs resampled to %d outputs\n",inCount,outCount);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsFree(outBuf);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsFree(inBuf);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsFree (state);&lt;BR /&gt;
	&amp;nbsp;}&lt;/P&gt;

&lt;P&gt;So I have my *.wav file which data of header looks like this:&lt;/P&gt;

&lt;P&gt;Chunk name: RIFF&lt;/P&gt;

&lt;P&gt;File size: 31636640&lt;/P&gt;

&lt;P&gt;File format: WAVE&lt;/P&gt;

&lt;P&gt;Sub chunk id: fmt&lt;/P&gt;

&lt;P&gt;Sub chunk size: 16&lt;/P&gt;

&lt;P&gt;Compression format: 1&lt;/P&gt;

&lt;P&gt;Channels: 1&lt;/P&gt;

&lt;P&gt;Sample rate: 44100&lt;/P&gt;

&lt;P&gt;Byte rate: 88200&lt;/P&gt;

&lt;P&gt;Block align: 2&lt;/P&gt;

&lt;P&gt;Bits per sample: 16&lt;/P&gt;

&lt;P&gt;Sub chunk id: data&lt;/P&gt;

&lt;P&gt;Sub chunk size: 31636604&lt;/P&gt;

&lt;P&gt;And I insert it to this examplary function as FILE should be inserted to input from what I understand. I get something on output but I can't play it. I do it like that:&lt;/P&gt;

&lt;P&gt;FILE *fInput =fopen(wavFile0.filePath,"rb");&lt;BR /&gt;
	FILE *fOutput&amp;nbsp; =&amp;nbsp; fopen ("myTestFile.wav", "wb");&lt;/P&gt;

&lt;P&gt;&amp;nbsp;resampleIPP(44100, 8000, fInput, fOutput);&lt;/P&gt;

&lt;P&gt;fclose(fInput);&lt;BR /&gt;
	fclose((fOutput);&lt;/P&gt;

&lt;P&gt;By investigating file structure I can say for sure that something has happened with header of the file. Would that mean that I have to insert only vector of data located under sub chunk with id "data" and then after resampleIPP function resamples my data then append it to new header?&lt;/P&gt;

&lt;P&gt;I am using IPP 7.1&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2015 01:51:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/ippsResamplePolyphase-sample-usage-quesiton/m-p/1041385#M23819</guid>
      <dc:creator>Kamil_K_</dc:creator>
      <dc:date>2015-03-09T01:51:26Z</dc:date>
    </item>
    <item>
      <title>Hello,  </title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/ippsResamplePolyphase-sample-usage-quesiton/m-p/1041386#M23820</link>
      <description>&lt;P&gt;Hello, &amp;nbsp;&lt;/P&gt;

&lt;P&gt;The sample code take the raw PCM files. &amp;nbsp; For a wave file, it also include wave header. &amp;nbsp; When you save to &amp;nbsp;a wave file, you also need to handle the wave headers.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
	Chao&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2015 05:36:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/ippsResamplePolyphase-sample-usage-quesiton/m-p/1041386#M23820</guid>
      <dc:creator>Chao_Y_Intel</dc:creator>
      <dc:date>2015-03-16T05:36:53Z</dc:date>
    </item>
  </channel>
</rss>

