;;; -*- logo -*-
;; This is offered as part of the sound API.
;;
;; copyright University of Victoria, 2005


to upsample :iarray :inc
  local [ oarray i rise next factor df ]

  if less? inc 2 [ output iarray ]
  make "df round inc
  make "df 1/df
  make "factor df

  make "oarray (array (count iarray)*inc0)

  make "i 0
  make "j 0
  repeat count iarray [

    setitem j oarray item i iarray
    make "j j+1
    if less? i iarray-1 [
      make "rise (item i-1 iarray) - (item i iarray)

      setitem j 
      repeat inc [
        make "next (item i iarray) + rise * factor
        make "factor factor + df 
        setitem j oarray next
        make "j j+1
      ]
    ] 
    make "i i+1
  ]  

  output oarray
end

bury [ upsample ]

