Prev: "Repairing" an out-of- focus picture
Next: Our customer websites are modern, fresh and accessible.
From: Joe on 29 May 2010 12:28 I was asked to create a Decimator/Interpolator to go between Narrow Band (8 KHz Sampling) and Wide Band (16 KHz Sampling). I am not so familiar with english engineer lingo, so does the above mean that the samplerate of the input signal which is fed to the decimator/interpolator-algorithm will either be 8KHz or 16KHz ? The implementation will be done in ANSI C. It has to a be a fixed point implementation and it must be efficient in terms of cpu usage. The implementation must support multi-instance. I'm assuming that this means that it should be possible to create several instances of a decimator/interpolator "class" and that the implementation should be somewhat object-oriented? The Decimator must have a passband of 3700 Hz. Stop Band is 4000 Hz. Minimum stopband attenuation 40 dB. Passband ripple 1.5 dB. I understand that the decimator is a preprocessing low pass filter and that you send the input signal through this filter...and that you then take every Mth output sample from the filter to construct the downsampled signal. I also understand that the interpolator is a post-processing low-pass filter which you apply to a signal x[k] where x[k] is an 'expanded' version of some input signal y[k]....x[k] is created by inserting zeros between every sample in the original signal y[k]. I also understand that interpolation is done before decimation. I tried to do a simulation in matlab and it seems to work fine: ********* MATLAB CODE START ********** %% 22050Hz signal [y,fs]=wavread('audiosignal.wav'); %% Interpolator L = 2; % Interpolation factor Fp = 0.92*fs/2; % Passband-edge frequency Fst = fs/2; % Stopband-edge frequency Ap = 1.5; % Passband peak-to-peak ripple Ast = 40; % Minimum stopband attenuation Fs = fs; % Sampling frequency Hf = fdesign.interpolator(L,'lowpass',Fp,Fst,Ap,Ast,Fs); Hm = design(Hf,'equiripple'); % Create interpolated signal. New sample rate = 44100 Hz z_i=zeros(1,length(y)*L); z_i(1:L:end)=y; z_i=filter(Hm.Numerator,1,z_i); wavplay(z_i,fs*L); %% Decimator M = 6; % Decimation factor Fp = 3700; % Passband-edge frequency Fst = 4000; % Stopband-edge frequency Ap = 1.5; % Passband peak-to-peak ripple Ast = 40; % Minimum stopband attenuation Fs = fs*L; % Sampling frequency Hf = fdesign.decimator(M,'lowpass',Fp,Fst,Ap,Ast,Fs); Hm = design(Hf,'equiripple'); % Create decimated signal and play it. New sample rate = 7350Hz z=filter(Hm.Numerator,1,z_i); z=z(1:M:end); wavplay(z,fs*L/M); ********* MATLAB CODE END********** Since the filter coefficients depend on fs, I am wondering why the spec I was given doesn't say anything about the sample frequency of the input signal. Should I just assume that I also have to implement an algorithm which calculates the filter coefficients based on some fs specified by the user ? If it's a mistake and fs is known and fixed, I guess it should have been included in the spec? Or is the sample rate just either 8KHz or 16KHz (as mentioned in the beginning of this thread) ? In that case, the decimator filter coefficients still have to be calculated by some algorithm since they depend on the interpolator factor L, right?
From: Jerry Avins on 29 May 2010 12:50 On 5/29/2010 12:28 PM, Joe wrote: > I was asked to create a Decimator/Interpolator to go between > Narrow Band (8 KHz Sampling) and Wide Band (16 KHz Sampling). > > I am not so familiar with english engineer lingo, so does the above mean > that the samplerate of the input signal which is fed to the > decimator/interpolator-algorithm will either be 8KHz or 16KHz ? > > The implementation will be done in ANSI C. It has to a be a fixed point > implementation and it must be efficient in terms of cpu usage. > > The implementation must support multi-instance. I'm assuming that this > means > that it should be possible to create several instances of a > decimator/interpolator "class" and > that the implementation should be somewhat object-oriented? > > The Decimator must have a passband of 3700 Hz. Stop Band is 4000 Hz. > Minimum > stopband attenuation 40 dB. Passband ripple 1.5 dB. > > I understand that the decimator is a preprocessing low pass filter and > that you send the input signal > through this filter...and that you then take every Mth output sample > from the filter to > construct the downsampled signal. > > I also understand that the interpolator is a post-processing low-pass > filter which you apply to a signal x[k] > where x[k] is an 'expanded' version of some input signal y[k]....x[k] is > created by inserting zeros between > every sample in the original signal y[k]. > > I also understand that interpolation is done before decimation. > > I tried to do a simulation in matlab and it seems to work fine: > > ********* MATLAB CODE START ********** > %% 22050Hz signal > [y,fs]=wavread('audiosignal.wav'); > > %% Interpolator > L = 2; % Interpolation factor > Fp = 0.92*fs/2; % Passband-edge frequency > Fst = fs/2; % Stopband-edge frequency > Ap = 1.5; % Passband peak-to-peak ripple > Ast = 40; % Minimum stopband attenuation > Fs = fs; % Sampling frequency > Hf = fdesign.interpolator(L,'lowpass',Fp,Fst,Ap,Ast,Fs); > Hm = design(Hf,'equiripple'); > > % Create interpolated signal. New sample rate = 44100 Hz > z_i=zeros(1,length(y)*L); > z_i(1:L:end)=y; > z_i=filter(Hm.Numerator,1,z_i); > wavplay(z_i,fs*L); > > %% Decimator > M = 6; % Decimation factor > Fp = 3700; % Passband-edge frequency > Fst = 4000; % Stopband-edge frequency > Ap = 1.5; % Passband peak-to-peak ripple > Ast = 40; % Minimum stopband attenuation > Fs = fs*L; % Sampling frequency > Hf = fdesign.decimator(M,'lowpass',Fp,Fst,Ap,Ast,Fs); > Hm = design(Hf,'equiripple'); > > % Create decimated signal and play it. New sample rate = 7350Hz > z=filter(Hm.Numerator,1,z_i); > z=z(1:M:end); > wavplay(z,fs*L/M); > ********* MATLAB CODE END********** > > Since the filter coefficients depend on fs, I am wondering why the spec > I was given doesn't say anything > about the sample frequency of the input signal. Should I just assume > that I also have to implement an > algorithm which calculates the filter coefficients based on some fs > specified by the user ? If it's a mistake > and fs is known and fixed, I guess it should have been included in the > spec? Or is the sample rate just either > 8KHz or 16KHz (as mentioned in the beginning of this thread) ? In that > case, the decimator filter coefficients > still have to be calculated by some algorithm since they depend on the > interpolator factor L, right? Please be a little more explicit. When you write "go between Narrow Band (8 KHz Sampling) and Wide Band (16 KHz Sampling)", I take it that you mean that signals with a sample rate of 8KHz must be converted to 16 KHz, and signals with a sample rate of 16KHz must be converted to 8 KHz. If so, the sample rates are given. Likewise the interpolation and decimation factors; both 2. If your task is as I suppose, then the interpolating 8 Ks/sec to 16 is done by inserting a zero sample between each pair of original samples, then filtering the resulting 16Ks/sec stream to remove any frequencies not in the original, namely those above 4 KHz. This task requires a (something less than) 4 KHz low-pass filter running at 16 Hs/sec. Similarly decimating the 16 Ks/sec signal begins with the filter described above, since the signal may have frequencies present that can't be represented at the lower sample rate. Once that is done, delete alternate samples to halve the sample rate. Or did I not understand the requirements? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
From: Jerry Avins on 29 May 2010 12:54 On 5/29/2010 12:50 PM, Jerry Avins wrote: ... > (something less than) 4 KHz low-pass filter running at 16 Hs/sec. (something less than) 4 KHz low-pass filter running at 16 Ks/sec. �� ... Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
From: Fred Marshall on 29 May 2010 13:10 You might use exactly the same filter in each case (but with different sample rates). Note: the filter coefficients *don't* depend on the sample rate but the absolute frequency response does. If you normalize the frequency response to fs, then the frequency response remains the same with the same set of coefficients. You might use the same half-band filter in both situations. A half-band filter is a lowpass at fs/4 with some special features included. For interpolation: 1) Intersperse in time with zeros. This may be a "no-op" depending on your implementation. 2) Low pass filter (at the new fs) to fs/4 in order to get rid of the content around fs/2 (which is an image of the content around zero and fs). This is what a half-band filter does. One benefit of the half-band filter is that it has quite a few zero-valued coefficients. So, implementation in time can be efficiently done. For decimation: 1) Low pass filter at fs/4 in order to limit the bandwidth to below what will become the *new* fs/2. 2) Decimate by dropping every other sample. Again, almost a "no-op". Halfband design program at: ftp.mission-systems-inc.com login: ourguest password: hellothere.4 Directory: Halfband Fred
From: Jerry Avins on 29 May 2010 13:29 On 5/29/2010 1:10 PM, Fred Marshall wrote: > You might use exactly the same filter in each case (but with different > sample rates). > > Note: the filter coefficients *don't* depend on the sample rate but the > absolute frequency response does. If you normalize the frequency > response to fs, then the frequency response remains the same with the > same set of coefficients. > > You might use the same half-band filter in both situations. A half-band > filter is a lowpass at fs/4 with some special features included. > > For interpolation: > > 1) Intersperse in time with zeros. This may be a "no-op" depending on > your implementation. > > 2) Low pass filter (at the new fs) to fs/4 in order to get rid of the > content around fs/2 (which is an image of the content around zero and > fs). This is what a half-band filter does. > > One benefit of the half-band filter is that it has quite a few > zero-valued coefficients. So, implementation in time can be efficiently > done. > > For decimation: > > 1) Low pass filter at fs/4 in order to limit the bandwidth to below what > will become the *new* fs/2. > > 2) Decimate by dropping every other sample. Again, almost a "no-op". > > Halfband design program at: > ftp.mission-systems-inc.com > login: ourguest > password: hellothere.4 > Directory: Halfband Fred, I supposed that a half-band filter might fall short of the needed performance. Isn't the attenuation at fs/4 only 3 dB? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
|
Next
|
Last
Pages: 1 2 3 Prev: "Repairing" an out-of- focus picture Next: Our customer websites are modern, fresh and accessible. |