Sign in

username:

password:



Not a member?

Search audiodsp



Search tips

Subscribe to audiodsp



audiodsp by Keywords

AAC | ADPCM | Convolution | DAFx | FFT | IIR | Mixer | MP3 | MPEG | MPEG-4

Ads

Discussion Groups

Technical discussions related to Audio Signal Processing (digital effects, acoustics, noise reduction, musical signal processing, etc).

  

Post a new Thread

Testing FIR filter - smartie_625 - Dec 11 6:24:13 2007



Hi,

I am doing a low-pass and high-pass 7-tap moving average filter filter
on Xilinx Virtex II Pro FPGA.

I am recording a sound, storing it in DDR RAM and filtering it and
playing it back. But, the output sounds like noise for both low-pass
and high-pass filters. Could someone please let me know what I could
be doing wrong?

Also, how can I calculate the cut-off frequencies for a seven-tap
moving average filter?

I have pasted my code below. I hope it is understandable. Xuint32 is
just a data type pre-defined in Xilinx libraries.

/*************************************************************
Function: low_pass_filter does the low pass 7-point moving average filter
@Param *aBuf: This is the array of 32-bit values stored in DDR RAM
*********************************************************************/
Xuint32* low_pass_filter(Xuint32 *aBuf)
{
	//Lowpass:
	const int mSamples = SAMPLES;
	
	Xuint32 *mOut; //output buffer
		
	int i;
	
	xil_printf("\r\nBegin loop");
	
	for(i = 6; i<mSamples-6;i++)
	{
		mOut[i] = aBuf[i+6] + aBuf[i+5] + aBuf[i+4] + aBuf[i+3] + aBuf[i+2]
+ aBuf[i+1] + aBuf[i];
		mOut[i] /= 7.0;
	}
	
	xil_printf("\r\nEnd loop");
	
	return mOut;
}

/************************************************************
Function: high_pass_filter does the high pass 7-point moving average
filter
@Param *aBuf: This is the array of 32-bit values stored in DDR RAM
*****************************************************************/

Xuint32* high_pass_filter(Xuint32 *aBuf)
{
	int mSamples = SAMPLES;
	
	Xuint32 *mOut;//output buffer
	
	int i;

	xil_printf("\r\nBegin loop");
	
	for(i = 0; i<mSamples-6;i++)
	{
		mOut[i] = aBuf[i+6] - aBuf[i+5] + aBuf[i+4] - aBuf[i+3] + aBuf[i+2]
- aBuf[i+1] + aBuf[i];
		mOut[i] /= 7.0;
	}
	
	xil_printf("\r\nEnd loop");
	
	return mOut;

}

/*****************************************************************
End of code
*****************************************************************/

Thanks,
Abhishek



(You need to be a member of audiodsp -- send a blank email to audiodsp-subscribe@yahoogroups.com )

Re: Testing FIR filter - Amit - Dec 11 7:11:12 2007

Hi,
There are 2 issues with this filter

1. If you are sampling sound then you would have both positive and negative samples. So an
unsigned int32 datatype is not suitable for storing data. 
2. The values will overflow if you do not give enough guard bits. So you might consider
dividing by 7.0 before addition. You might as well make it 8 tap filter and shift right the
input by 3.

Regards,
Amit
----- Original Message ----
From: smartie_625 <s...@gmail.com>
To: a...@yahoogroups.com
Sent: Saturday, 8 December, 2007 4:37:18 AM
Subject: [audiodsp] Testing FIR filter

Hi,

I am doing a low-pass and high-pass 7-tap moving average filter filter
on Xilinx Virtex II Pro FPGA.

I am recording a sound, storing it in DDR RAM and filtering it and
playing it back. But, the output sounds like noise for both low-pass
and high-pass filters. Could someone please let me know what I could
be doing wrong?

Also, how can I calculate the cut-off frequencies for a seven-tap
moving average filter?

I have pasted my code below. I hope it is understandable. Xuint32 is
just a data type pre-defined in Xilinx libraries.

/*********** ********* ********* ********* ********* ********* *****
Function: low_pass_filter does the low pass 7-point moving average filter
@Param *aBuf: This is the array of 32-bit values stored in DDR RAM
************ ********* ********* ********* ********* ********* ********* ***/
Xuint32* low_pass_filter( Xuint32 *aBuf)
{
//Lowpass:
const int mSamples = SAMPLES;

Xuint32 *mOut; //output buffer

int i;

xil_printf(" \r\nBegin loop");

for(i = 6; i<mSamples-6; i++)
{
mOut[i] = aBuf[i+6] + aBuf[i+5] + aBuf[i+4] + aBuf[i+3] + aBuf[i+2]
+ aBuf[i+1] + aBuf[i];
mOut[i] /= 7.0;
}

xil_printf(" \r\nEnd loop");

return mOut;
}

/*********** ********* ********* ********* ********* ********* ****
Function: high_pass_filter does the high pass 7-point moving average
filter
@Param *aBuf: This is the array of 32-bit values stored in DDR RAM
************ ********* ********* ********* ********* ********* ********/

Xuint32* high_pass_filter( Xuint32 *aBuf)
{
int mSamples = SAMPLES;

Xuint32 *mOut;//output buffer

int i;

xil_printf(" \r\nBegin loop");

for(i = 0; i<mSamples-6; i++)
{
mOut[i] = aBuf[i+6] - aBuf[i+5] + aBuf[i+4] - aBuf[i+3] + aBuf[i+2]
- aBuf[i+1] + aBuf[i];
mOut[i] /= 7.0;
}

xil_printf(" \r\nEnd loop");

return mOut;

}

/*********** ********* ********* ********* ********* ********* *********
End of code
************ ********* ********* ********* ********* ********* ********/

Thanks,
Abhishek



(You need to be a member of audiodsp -- send a blank email to audiodsp-subscribe@yahoogroups.com )