startmacro/ps=2m u:device[pic1iil] d:freq[1e6]

res irate 27e6
res rrate 25e6
res ratio rrate/irate
res dec  16
res nfft 2k
res psz  32k
res crate rrate/dec/2
res orate rrate/dec
res flgw "MUXCLK=N|PM1=NONE|AOVSR|RESAMP"
res flgn "MUXCLK=N|PM1=DTDMX|PRESAMP"
res skp 50

pic/round=psz create wafile si rrate rrate
pic/round=psz create wbfile si rrate rrate
pic/round=psz create nafile ci crate crate
pic/round=psz create nbfile ci crate crate

picd/flags=^flgn/verbose=0 reset ^device

xpipe/setup/nw=256 on

! wideband resampled PIC5 data source
sourcepic/wb=1/port=tuner1/ratio=ratio/skip=64/flags=^flgw/replay=0/master=2002 wafile(fs=nfft) _wa ^device 1 irate/4 
sourcepic/wb=2/port=tuner2/ratio=ratio/skip=64/flags=^flgw/replay=0/slave       wbfile(fs=nfft) _wb ^device 1 irate/4 
! if in seperate macro, lose the /master=3002, and kick 1001 last

! wideband resampled DTDM data source
sourcepic/wb=3/port=tuner1/ratio=ratio/skip=4/flags=^flgn|RGO/replay=0 nafile(fs=nfft) _na ^device dec freq 
sourcepic/wb=4/port=tuner2/ratio=ratio/skip=4/flags=^flgn|RGO/replay=0 nbfile(fs=nfft) _nb ^device dec freq 

! displays
mfft _wa _waf nfft 
xrtplot/xs=2/dbrange=140/xn=WA _waf ,,, l2

mfft _wb _wbf nfft 
xrtplot/xs=3/dbrange=140/xn=WB _wbf ,,, l2

mfft _na _naf nfft
xrtplot/xs=4/dbrange=140/xn=NA _naf ,,, l2

mfft _nb _nbf nfft
xrtplot/xs=5/dbrange=140/xn=NB _nbf ,,, l2

if /dump gt 0 then
  noop _ca testca
  noop _cb testcb
endif

xpipe off

endmacro

startcontrols

label initialentry
xcontrol prompt "MODE" "Mode" mode
xcontrol/lab=xxx menu item 0 "Do;Run,Stop,Exit" 
return

label xxx
if item eq 1 then
  res w_3001 2
  res w_4001 2
  ! wait for the sourcepics in the NB macro to startup and wait (thanks to RGO) 
  pause .5  
  ! now start the WB macro sourcepics
  res w_1001 2
elseif item eq 2 then
  res w_3001 4
  res w_4001 4
  res w_1001 4
elseif item eq 3 then
  stop
endif
return

endcontrols
