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) = Array Int a -> (Int, Int)
forall i e. Array i e -> (i, i)
A.bounds Array Int a
c
f :: Int -> a
f = Array Int a -> Int -> a
forall i e. Ix i => Array i e -> i -> e
(A.!) Array Int a
c
in if Int
ix Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
l then Int -> a
f Int
l else if Int
ix Int -> Int -> Bool
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 = (Int -> Array Int a -> a) -> a -> Array Int a -> a
forall i n t.
(Integral i, RealFrac n) =>
(i -> t -> n) -> n -> t -> n
Common.Buffer.blendAtBy Int -> Array Int a -> a
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) = Array Int n -> (Int, Int)
forall i e. Array i e -> (i, i)
A.bounds Array Int n
c
gen :: Int -> n
gen = Int -> Int -> (Int -> Array Int n -> n) -> Array Int n -> Int -> n
forall i n t.
(Integral i, RealFrac n) =>
i -> i -> (i -> t -> n) -> t -> i -> n
Common.Buffer.resamp1_gen Int
n (Int
r Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Int -> Array Int n -> n
forall a. Int -> Array Int a -> a
clipAt Array Int n
c
rs :: [n]
rs = (Int -> n) -> [Int] -> [n]
forall a b. (a -> b) -> [a] -> [b]
map Int -> n
gen [Int
0 .. Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1]
in (Int, Int) -> [n] -> Array Int n
forall i e. Ix i => (i, i) -> [e] -> Array i e
A.listArray (Int
0, Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) [n]
rs