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