!
! @author  Jason Broussard
! @version $Id: test_fdfilter.mm,v 1.2 2010/01/28 13:09:46 jgs Exp $
! @since   
!
startmacro

  !Basic test
  WAVEFORM,in1,SF,128k,SIN,1,.01,0,0,1
  WAVEFORM,f1,SF,1,constant,128,.01,0,0,1
  convolve in1 f1 n1
  fdfilter in1 f1 n2
  fcalc diff n1 n2 -
  maxmin/quiet diff max1 min1
  calc max1 max1 abs min1 abs max !calculate max abs of min and max

  assert/text="Basic comparison of fdfilter to convolve" max1 le 1e-4

  !Test with weird sizes
  WAVEFORM,in1,SF,111,SIN,1,.01,0,0,1
  WAVEFORM,f1,SF,1,ramp,111,.01,0,0,1
  convolve in1 f1 n1
  fdfilter in1 f1 n2
  fcalc diff n1 n2 -
  maxmin/quiet diff max1 min1
  calc max1 max1 abs min1 abs max !calculate max abs of min and max

  assert/text="Compare fdfilter to convolve using irregular sizes" max1 le 1e-4

  !Test with firwin, /pad, and negative xstarts
  WAVEFORM,in1,SF,100k,ramp,1,.01,0,0,1
  firwin f1 BANDPASS ,NONE, 513 2.55e6,3.55e6,5e6  
  convolve in1 f1 n1
  fdfilter/pad in1 f1 n2
  thin n1 n1 file(f1).size/2	!remove beginning transients
  headermod n1 xs=0	!align
  fcalc diff n1 n2 -
  maxmin/quiet diff max1 min1
  calc max1 max1 abs min1 abs max !calculate max abs of min and max

  assert/text="Compare fdfilter to convolve and verify /pad" max1 le 1e-6

  erase in1 f1 n1 n2 diff
  remove max1 min1
  
endmacro
