module Sound.SC3.Common.Buffer.Array where
import qualified Data.Array as A
import qualified Sound.SC3.Common.Buffer as SC3
clipAt :: Int -> A.Array Int a -> a
clipAt ix c =
let (l,r) = A.bounds c
f = (A.!) c
in if ix < l then f l else if ix > r then f r else f ix
blendAt :: RealFrac a => a -> A.Array Int a -> a
blendAt = SC3.blendAtBy clipAt
resamp1 :: RealFrac n => Int -> A.Array Int n -> A.Array Int n
resamp1 n c =
let (_,r) = A.bounds c
gen = SC3.resamp1_gen n (r + 1) clipAt c
rs = map gen [0 .. n 1]
in A.listArray (0,n 1) rs