Diff of /comp/comp_warpedfreqresponse.m [287832] .. [055026]  Maximize  Restore

Switch to side-by-side view

--- a/comp/comp_warpedfreqresponse.m
+++ b/comp/comp_warpedfreqresponse.m
@@ -1,4 +1,4 @@
-function H=comp_warpedfreqresponse(wintype,fc,bw,fs,L,freqtoscale,varargin)
+function H=comp_warpedfreqresponse(wintype,fc,bw,fs,L,freqtoscale,scaletofreq,varargin)
 %COMP_WARPEDFREQRESPONSE  Transfer function of warped filter
 %   Usage: H=comp_warpedfreqresponse(wintype,fc,bw,fs,L,freqtoscale);
 %          H=comp_warpedfreqresponse(wintype,fc,bw,fs,L,freqtoscale,normtype);
@@ -10,6 +10,7 @@
 %      fs          : Sampling frequency in Hz.
 %      L           : Transform length (in samples).
 %      freqtoscale : Function to convert Hz into scale units.
+%      scaletofreq : Function to convert scale units into Hz.
 %      normtype    : Normalization flag to pass to |normalize|.
 
 definput.import={'normalize'};
@@ -21,12 +22,22 @@
 
 % This one is necessary to represent the highest frequency filters, which
 % overlap into the negative frequencies.
-bins_hi   = 2*freqtoscale(fs/2)+bins_lo;
+nyquest2  = 2*freqtoscale(fs/2);
+bins_hi   = nyquest2+bins_lo;
 
 % firwin makes a window of width 1 centered around 0 on the scale, so we rescale the
 % bins in order to pass the correct width to firwin and subtract fc
 bins_lo=(bins_lo-fc)/bw;
 bins_hi=(bins_hi-fc)/bw;
+
+% pos_lo is the same as foff
+pos_lo=floor(scaletofreq(fc-.5*bw)/fs*L);
+pos_hi=ceil(scaletofreq(fc+.5*bw)/fs*L);
+
+if pos_hi>L/2
+    % Filter is high pass and spilling into the negative frequencies
+    pos_hi=ceil(scaletofreq(fc+.5*bw-nyquest2)/fs*L);    
+end;
 
 win_lo=firwin(wintype,bins_lo);
 win_hi=firwin(wintype,bins_hi);
@@ -34,3 +45,7 @@
 H=win_lo+win_hi;
    
 H=normalize(H,flags.norm);
+
+% Testing
+H=circshift(H,-pos_lo);
+H=H(1:modcent(pos_hi-pos_lo,L));

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks