| y=saListen(hnd, fc, bw, time, range, demod, play, verbose, fptr, param1)
|
function y=saListen(hnd, fc, bw, time, range, demod, play, verbose, fptr, param1)
% Y=SALISTEN(HND, FC, BW, TIME, RANGE, DEMOD, PLAY, VERBOSE)
% HND is a handle to a psa or mxa
% FC is the center frequency (Hz) you want to listen
% BW is the bandwidth (Hz)
% TIME is the amount of time (seconds) data you want
% RANGE is power range (dBm) of the analyzer use <=-100 to autorange
% DEMOD must be set to either 'am' or 'fm'
% (optional) PLAY if set to non-zero value will play the audio out the PC
% speaker. Default value is to play out the speaker.
% (optional) VERBOSE if set to non-zero value will be verbose about the
% acqistion. Default value it no verbosity.
% Y is the demod waveform
%% Check the variables for good results
if nargin == 6,
play=1;
verbose = 0;
fptr = @(dummy, str) disp(str);
param1 = 1;
elseif nargin == 7,
verbose = 0;
fptr = @(dummy, str) disp(str);
param1 = 1;
elseif nargin == 8,
fptr = @(dummy, str) disp(str);
param1 = 1;
elseif nargin ==9,
error('You need at least one parameter to your print function.');
elseif nargin < 6,
error('too few inputs. YOu need at least 6.');
elseif nargin > 10,
error('too many inputs. You only need 8 inputs.');
end
if ~strcmp(demod,'am') && ~strcmp(demod,'fm')
error('demod must be either ''am'' or ''fm''.');
end
%% Acquire the data
[x,T] = saAcquisition(hnd, fc, bw, time, range, verbose, fptr, param1);
%% Detect the data
if verbose,
fptr(param1,'Detecting data');
end
if strcmp(demod,'am'),
y=myamdemod(x,T);
else
y=myfmdemod(x);
end
%% Resample down to 44100 Hz
if verbose,
fptr(param1,'Resampling data.');
end
step=1/(T*44100); % calculate new step Size
N=floor(numel(y)/step-5); % calculate new number of points given that
% the resampler is 5 tap filter
y=kernelResample2(N,y,0,step);
%% rudimentary ranging
k=1/max(abs(y));
y=k*y;
%% play out the sound
if play,
wavplay(y,44100,'async');
end
|
|