STARTMACRO/xpipe/setup/dec=8 N:nsamples 
!
! macro for emulating SD350 spectrum analyzer
!
local SFREQ,CFREQ,FWIDTH,FS

if /C gt 0
  WAVEFORM/tl=1k/ctag=3:SFREQ _wave CF nsamples SIN
else
  WAVEFORM/tl=1k/ctag=3:SFREQ/s=h _wave SF nsamples SIN
endif
RQFSHIFT/rs/fft=1k/ctag=(2:CFREQ,3:FWIDTH)/nowarn/wb=3 _wave _waves 0e-3 ,,
MFFT/rs/fftp=3 _waves _wavep 1k hann 0.0
STATUS/quiet _wavep ,,,,, FS
XRTPLOT/xs=3/mtag=X:SFREQ/xcnt=2/mark=3 _wavep(cl=/DEC*FS) 1e-10 .5 lo ,, 70
XRTRASTER/xs=2/mtag=X:CFREQ/lpb=2/stretch _wavep 0    0.25 lo ,, 20
XRTDISPLAY/xs=4 SFREQ/"Sine Frequency" FWIDTH/"Filter Width"
!
ENDMACRO
