startmacro 

set samplerate 22000
set format "SI"
set length 5
set shape  "SIN"
set amp 2000
! JC4: Combined frequencies of 480Hz and 620Hz equals the dial tone
set freq1 480
set freq2 620

pipe/panel on

gc label  "MAIN" "Control"
gc button "MODE" "" "Setup,Exit,Acquire,Playback" /nc=2
gc choice "SRC"  "Source " "Mic,CD,Line,Wave" "Mic"
gc file   "FILE" "File   " "audio"

gc label  "CFG"  "Configuration"
gc lval   "SR"   "SampleRate" samplerate 8000 22000 1000
gc choice "FORM" "Format    " "SI,SB" format
gc dval   "LEN"  "Length    " length 1 100 1
gc lval   "AMP"  "Amplitude " amp 100 30000 100
gc dval   "FREQ" "Frequency1 " freq1 100 10000 100
gc dval   "FREQ" "Frequency2 " freq2 100 10000 100
gc choice "SHP"  "Shape     " "Sin,Square,Saw,White" shape

waveform _data1 format length*samplerate shape amp freq1 0 0 1/samplerate
waveform _data2 format length*samplerate shape amp freq2 0 0 1/samplerate
fcalc _data{FORM=^format} _data1 _data2 +
sinkaudio _data

fft/dbf _data _fft
plot/id=tdp _data 
plot/id=fdp _fft type=line scale=range range=50

pipe off

endmacro

procedure processMessage

if msg.name eqs "MODE"
  if msg.data eqs "SETUP"
  elseif msg.data eqs "ACQUIRE"
  elseif msg.data eqs "PLAYBACK"
  elseif msg.data eqs "EXIT"
    pipe stop
  endif

endif
return

