Hi Urban,

I always use the "pfo.m" script below ("plot faustout") - NOT pretty, 
but handy.

- Julius

% input parameters:
if !exist('fs')
   fs = 1;
   freqstr = 'Normalized Frequency (cycles/sample)';
else
   if fs<1000 % (Hack)
     freqstr = 'Frequency (kHz)';
   else
     freqstr = 'Frequency (Hz)';
   end
end

if !exist('lwidth')
   lwidth = 2; % linewidth for all plots
end
if !exist('kase') % cases to do
%  kase = [0 1 0 0]; % log freq
    kase = [1 0 0 0]; % linear freq
%  kase = [1 1 0 0]; % linear and log freq
%  kase = [1 0 1 0]; % linear freq and phase
elseif length(kase)<4
   kase = [kase(:)',zeros(1,4-length(kase))];
end

fo = faustout;
x = faustout;
[nx,nchans] = size(x);
N = 2^(nextpow2(nx)+4);
if !exist('Ns')
    Ns = N/2+1;
%   Ns = round(N*20000/fs); % only look at audio band
end

if !exist('printplots')
   printplots = 0;
end

% WINDOW DISABLED
% w = chebwin(nx,300);
% xw = x .* (w * ones(1,nchans));
xw = x;

X = fft(xw,N);
Xs = X(2:Ns,:); % omit dc term; may be multichannel
if !exist('mindb')
   mindb = -200;
end
Xsdb = db(Xs,mindb);
f = fs*[1:Ns-1]/N;

if kase(1) % dB magnitude vs. linear freq
   figure(2);
   plot(f,Xsdb,'linewidth',lwidth);
   ylabel('Magnitude (dB)');
   xlabel(freqstr);
   grid('on');
   if exist('pfx') && nchans>1, dolegend(pfx,nchans,1); end
   if printplots
     print -depsc -F:12 './pfo-magdb-c.eps';
     print -deps -F:12 -mono -solid './pfo-magdb.eps';
   end
end

if kase(2) % log-log
   figure(3);
   semilogx(f,Xsdb,'linewidth',lwidth);
   %axis([10 20000 ymin ymax])
   ylabel('Magnitude (dB)');
   xlabel(freqstr);
   grid('on');
   if exist('pfx') && nchans>1, dolegend(pfx,nchans,3); end
   if printplots
     print -depsc -F:12 './pfo-magdb-semilog-c.eps';
     print -deps -F:12 -mono -solid './pfo-magdb-semilog.eps';
   end
end

if kase(3) % phase delay
   aXs = unwrap(angle(Xs));
   Xspd = - aXs ./ ((2*pi*f'/fs)*ones(1,nchans));
   figure(4);
   plot(f,Xspd,'linewidth',lwidth);
   % semilogx(f,Xspd);
   ylabel('Phase Delay (samples)');
   xlabel(freqstr);
   grid('on');
   if exist('pfx') && nchans>1, dolegend(pfx,nchans,1); end
   if printplots
     print -depsc -F:12 './pfo-pd-c.eps';
     print -deps -F:12 -mono -solid './pfo-pd.eps';
   end
end

if kase(4) % group delay
   aXs = unwrap(angle(Xs));
   Xspd = -diff(aXs);
   Xspd = [0,Xspd(:)'];
   figure(4);
   plot(f,Xspd,'linewidth',lwidth);
   % semilogx(f,Xspd);
   ylabel('Group Delay (samples)');
   xlabel(freqstr);
   grid('on');
   if exist('pfx') && nchans>1, dolegend(pfx,nchans,1); end
   if printplots
     print -depsc -F:12 './pfo-gd-c.eps';
     print -deps -F:12 -mono -solid './pfo-gd.eps';
   end
end


At 08:59 AM 9/12/2013, urban wrote:
>Hi,
>
>I learned that I can view the frequency response of a filter like this:
>
>octave:1> plot(20*log10(abs(fft(faustout,1024))(1:512,:)));
>
>
>
>but how do I get the frequency axis to display Hz(log) ?
>
>Can someone provide me with a octave script?
>
>
>Thanks,
>Urban
>
>------------------------------------------------------------------------------
>How ServiceNow helps IT people transform IT departments:
>1. Consolidate legacy IT systems to a single system of record for IT
>2. Standardize and globalize service processes across IT
>3. Implement zero-touch automation to replace manual, redundant tasks
>http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
>_______________________________________________
>Faudiostream-devel mailing list
>Faudiostream-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/faudiostream-devel


Julius O. Smith III <j...@ccrma.stanford.edu>
Professor of Music and, by courtesy, Electrical Engineering
CCRMA, Stanford University
http://ccrma.stanford.edu/~jos/  


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
Faudiostream-devel mailing list
Faudiostream-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-devel

Reply via email to