DSPRelated.com
Forums

designing a preemphasis filter

Started by Narax October 4, 2007
Hi!

I'm trying to design a digital preenphasis filter - so far without any
luck.
The other post about a preemphasis filter design I found couldn't help
me.

I'm working with LabView, where I read wav files (so my sampling frequency
is 44,1kHz) which I want to filter. What I tried so far is to calculate
coefficients for a FIR filter in MatLab using frequency sampling.

My MatLab code looks like this:

%------------------------------------------------
fs=44100; % sampling frequency
tau=50; % time constant in microsecondy (50us for Europe, 75us for
Amerika)
N=30; % filter order

%----- desired frequency response -----%
fa=0:1:(fs/2);
m=10*log10(1+((2*tau*fa/1000).^2)*10^(-5)); % corresponding magnitudes
[dB]

%----- design FIR filter (linear phase) -----%
%fir2 for frequency-sampling
b=fir2(N,(fa/(fs/2)),m);
%b=b/sum(b); % if not in comments, the beginning looks fine but the rest
doesn't

[H,f]=freqz(b,1,22051,fs); % compute transfer function

%----- plot everything -----%
figure(1)
plot(f,abs(H),f,m,'r')
grid on
axis([100 22050 0 35])
legend('designed', 'desired')
set(gca, 'XScale', 'log')

figure(2)
freqz(b,1)
%------------------------------------------------

Running this sequency you can see that the desired an designed plots don't
fit.

Could you point out my mistakes?

Thank you a lot!
Narax


Here is your pre-emphasis filter:

y[k]=x[k]-0.95x[k-1]



your filter order N is too low 


Thank you for your answer.

The filter you have designed does not fit at all when plotting in MatLab.

Increasing the order does in fact improve the fitting. But is an order 100
filter ok? Or can the high order cause any other problems?

Another question is: when looking at the plot with both filter everything
seems to be fine (N=100). But when looking at freqz() with the
coefficients I designed, the total magnitude rise is about 40dB, which is
more than double the rise I want to achive. Why is there a difference?
Narax wrote:
> Thank you for your answer. > > The filter you have designed does not fit at all when plotting in MatLab. > > Increasing the order does in fact improve the fitting. But is an order 100 > filter ok? Or can the high order cause any other problems? > > Another question is: when looking at the plot with both filter everything > seems to be fine (N=100). But when looking at freqz() with the > coefficients I designed, the total magnitude rise is about 40dB, which is > more than double the rise I want to achive. Why is there a difference?
Frequency warping steepens slopes as Fs/2 is approached. Jerry -- Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
> > The filter you have designed does not fit at all when plotting in MatLab.
I know. I just suggested a simple pre-emphasis filter
> Increasing the order does in fact improve the fitting. But is an order 100 > filter ok? Or can the high order cause any other problems?
Depends on the application. If delay is an issue, then that would be a problem.
Narax" wrote:
> Hi! > > I'm trying to design a digital preenphasis filter - so far without any > luck. > The other post about a preemphasis filter design I found couldn't help > me.
Are you sure you looked hard enough? Robert Orban (yes, that Orban) has posted quite a few examples of digital deemphasis filters on comp.dsp. Here is one of his posts: http://groups.google.ch/group/comp.dsp/msg/4914352a383a2923 Greg Berchin also posted an example in another thread using his excellent FDLS filter design method. Regards, Andor
>Are you sure you looked hard enough?
I was sure... not anymore, so shame on me!
>Robert Orban (yes, that Orban) >has posted quite a few examples of digital deemphasis filters on >comp.dsp. Here is one of his posts: > >http://groups.google.ch/group/comp.dsp/msg/4914352a383a2923
Thank you a lot for that link! I just took a look at it and it seems to be perfect! However, I have still some problems using MatLab so in one plot it is perfect and in the other plot it isn't, but I will ask my way through ;-)
>Are you sure you looked hard enough?
I was sure... not anymore, so shame on me!
>Robert Orban (yes, that Orban) >has posted quite a few examples of digital deemphasis filters on >comp.dsp. Here is one of his posts: > >http://groups.google.ch/group/comp.dsp/msg/4914352a383a2923
Thank you a lot for that link! I just took a look at it and it seems to be perfect! However, I have still some problems using MatLab so in one plot it is perfect and in the other plot it isn't, but I will ask my way through ;-)
>Are you sure you looked hard enough?
I was sure... not anymore, so shame on me!
>Robert Orban (yes, that Orban) >has posted quite a few examples of digital deemphasis filters on >comp.dsp. Here is one of his posts: > >http://groups.google.ch/group/comp.dsp/msg/4914352a383a2923
Thank you a lot for that link! I just took a look at it and it seems to be perfect! However, I have still some problems using MatLab so in one plot it is perfect and in the other plot it isn't, but I will ask my way through ;-)