📄 aliasing.c
字号:
//Aliasing.c illustration of downsampling, aliasing, upsampling
#include "lp33.cof" //lowpass at 1.8 kHz
short flag = 0; //toggles for 2x down-sampling
float indly[N],outdly[N]; //antialias and reconst delay lines
short i; //index
float yn; //filter output
short antialiasing = 0; //init for no antialiasing filter
interrupt void c_int11() //ISR
{
indly[0]=(float)(input_sample()); //new sample to antialias filter
yn = 0.0; //initialize downsampled value
if (flag == 0) //discard input sample value
flag = 1; //don't discard at next sampling
else
{
if (antialiasing == 1) //if antialiasing filter desired
{ //compute downsampled value
for (i = 0 ; i < N ; i++) //using LP @ 1.8 kHz filter coeffs
yn += (h[i]*indly[i]); //filter is implemented using float
}
else //if filter is bypassed
yn = indly[0]; //downsampled value is input value
flag = 0; //next input value will be discarded
}
for (i = N-1; i > 0; i--)
indly[i] = indly[i-1]; //update input buffer
outdly[0] = (yn); //input to reconst filter
yn = 0.0; //4 kHz sample values and zeros
for (i = 0 ; i < N ; i++) //are filtered at 8 kHz rate
yn += (h[i]*outdly[i]); //by reconstruction lowpass filter
for (i = N-1; i > 0; i--)
outdly[i] = outdly[i-1]; //update delays
output_sample((short)(yn)); //8 kHz rate sample
return; //return from interrupt
}
void main()
{
comm_intr(); //init DSK, codec, McBSP
while(1); //infinite loop
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -