module Sound.SC3.Lang.Collection.Array where
import qualified Data.Array as A
import qualified Sound.SC3.Lang.Collection as C
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 = C.blendAtBy clipAt
resamp1 :: (Enum n,RealFrac n) => Int -> A.Array Int n -> A.Array Int n
resamp1 n c =
let (_,r) = A.bounds c
gen = C.resamp1_gen n (r + 1) clipAt c
rs = map gen [0 .. n 1]
in A.listArray (0,n 1) rs