module Sound.Sc3.Ugen.Bindings.Hw where
import Sound.Sc3.Common.Rate
import Sound.Sc3.Common.Uid
import Sound.Sc3.Common.Unsafe
import qualified Sound.Sc3.Ugen.Bindings.Hw.Construct as C
import Sound.Sc3.Ugen.Types
import qualified Sound.Sc3.Ugen.Util as Util
clearBuf :: Ugen -> Ugen
clearBuf :: Ugen -> Ugen
clearBuf Ugen
b = Ugen -> Ugen -> Ugen
Util.mrg2 Ugen
b (Rate -> String -> [Ugen] -> Int -> Ugen
C.mkOsc Rate
ir String
"ClearBuf" [Ugen
b] Int
1)
dwrandId :: ID i => i -> Ugen -> Ugen -> Ugen -> Ugen
dwrandId :: forall i. ID i => i -> Ugen -> Ugen -> Ugen -> Ugen
dwrandId i
z Ugen
repeats Ugen
weights Ugen
list_ =
let n :: Int
n = Ugen -> Int
mceDegree_err Ugen
list_
weights' :: [Ugen]
weights' = Int -> Ugen -> [Ugen]
mceExtend Int
n Ugen
weights
inp :: [Ugen]
inp = Ugen
repeats Ugen -> [Ugen] -> [Ugen]
forall a. a -> [a] -> [a]
: Int -> Ugen
forall n. Real n => n -> Ugen
constant Int
n Ugen -> [Ugen] -> [Ugen]
forall a. a -> [a] -> [a]
: [Ugen]
weights'
in Maybe ([Sample] -> Sample)
-> [Rate]
-> Either Rate [Int]
-> String
-> [Ugen]
-> Maybe [Ugen]
-> Int
-> Special
-> UgenId
-> Ugen
mkUgen Maybe ([Sample] -> Sample)
forall a. Maybe a
Nothing [Rate
dr] (Rate -> Either Rate [Int]
forall a b. a -> Either a b
Left Rate
dr) String
"Dwrand" [Ugen]
inp ([Ugen] -> Maybe [Ugen]
forall a. a -> Maybe a
Just [Ugen
list_]) Int
1 (Int -> Special
Special Int
0) (i -> UgenId
forall a. ID a => a -> UgenId
Util.toUid i
z)
dwrandM :: Uid m => Ugen -> Ugen -> Ugen -> m Ugen
dwrandM :: forall (m :: * -> *). Uid m => Ugen -> Ugen -> Ugen -> m Ugen
dwrandM = (Int -> Ugen -> Ugen -> Ugen -> Ugen)
-> Fn3 Ugen Ugen Ugen (m Ugen)
forall (m :: * -> *) a b c d.
Uid m =>
(Int -> Fn3 a b c d) -> Fn3 a b c (m d)
liftUid3 Int -> Ugen -> Ugen -> Ugen -> Ugen
forall i. ID i => i -> Ugen -> Ugen -> Ugen -> Ugen
dwrandId
dwrand :: Ugen -> Ugen -> Ugen -> Ugen
dwrand :: Ugen -> Ugen -> Ugen -> Ugen
dwrand = (Ugen -> Ugen -> Ugen -> IO Ugen) -> Ugen -> Ugen -> Ugen -> Ugen
forall a b c r. (a -> b -> c -> IO r) -> a -> b -> c -> r
liftUnsafe3 Ugen -> Ugen -> Ugen -> IO Ugen
forall (m :: * -> *). Uid m => Ugen -> Ugen -> Ugen -> m Ugen
dwrandM
envGen_ll :: Rate -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen
envGen_ll :: Rate -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen
envGen_ll Rate
rate Ugen
gate_ Ugen
levelScale Ugen
levelBias Ugen
timeScale Ugen
doneAction Ugen
envelope_ = Maybe ([Sample] -> Sample)
-> [Rate]
-> Either Rate [Int]
-> String
-> [Ugen]
-> Maybe [Ugen]
-> Int
-> Special
-> UgenId
-> Ugen
mkUgen Maybe ([Sample] -> Sample)
forall a. Maybe a
Nothing [Rate
kr, Rate
ar] (Rate -> Either Rate [Int]
forall a b. a -> Either a b
Left Rate
rate) String
"EnvGen" [Ugen
gate_, Ugen
levelScale, Ugen
levelBias, Ugen
timeScale, Ugen
doneAction] ([Ugen] -> Maybe [Ugen]
forall a. a -> Maybe a
Just [Ugen
envelope_]) Int
1 (Int -> Special
Special Int
0) UgenId
NoId
fftTrigger :: Ugen -> Ugen -> Ugen -> Ugen
fftTrigger :: Ugen -> Ugen -> Ugen -> Ugen
fftTrigger Ugen
b Ugen
h Ugen
p = Rate -> String -> [Ugen] -> Int -> Ugen
C.mkOsc Rate
kr String
"FFTTrigger" [Ugen
b, Ugen
h, Ugen
p] Int
1
packFFT :: Ugen -> Int -> Int -> Int -> Ugen -> Ugen -> Ugen
packFFT :: Ugen -> Int -> Int -> Int -> Ugen -> Ugen -> Ugen
packFFT Ugen
b Int
sz Int
from Int
to Ugen
z Ugen
mp =
let n :: Ugen
n = Int -> Ugen
forall n. Real n => n -> Ugen
constant (Ugen -> Int
mceDegree_err Ugen
mp)
in Rate -> String -> [Ugen] -> Ugen -> Int -> Ugen
C.mkOscMCE Rate
kr String
"PackFFT" [Ugen
b, Int -> Ugen
forall n. Real n => n -> Ugen
constant Int
sz, Int -> Ugen
forall n. Real n => n -> Ugen
constant Int
from, Int -> Ugen
forall n. Real n => n -> Ugen
constant Int
to, Ugen
z, Ugen
n] Ugen
mp Int
1
poll :: Ugen -> Ugen -> Ugen -> Ugen -> Ugen
poll :: Ugen -> Ugen -> Ugen -> Ugen -> Ugen
poll Ugen
trig_ Ugen
in_ Ugen
trigid Ugen
label_ =
let q :: [Ugen]
q = Bool -> Ugen -> [Ugen]
Util.unpackLabel Bool
True Ugen
label_
in String -> [Ugen] -> Int -> Ugen
C.mkFilter String
"Poll" ([Ugen
trig_, Ugen
in_, Ugen
trigid] [Ugen] -> [Ugen] -> [Ugen]
forall a. [a] -> [a] -> [a]
++ [Ugen]
q) Int
0
pv_HainsworthFoote :: Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen
Ugen
buf Ugen
h Ugen
f Ugen
thr Ugen
wt = Rate -> String -> [Ugen] -> Int -> Ugen
C.mkOsc Rate
ar String
"PV_HainsworthFoote" [Ugen
buf, Ugen
h, Ugen
f, Ugen
thr, Ugen
wt] Int
1
pv_JensenAndersen :: Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen
pv_JensenAndersen :: Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen -> Ugen
pv_JensenAndersen Ugen
buffer Ugen
propsc Ugen
prophfe Ugen
prophfc Ugen
propsf Ugen
threshold Ugen
waittime = Rate -> String -> [Ugen] -> Int -> Ugen
C.mkOsc Rate
ar String
"PV_JensenAndersen" [Ugen
buffer, Ugen
propsc, Ugen
prophfe, Ugen
prophfc, Ugen
propsf, Ugen
threshold, Ugen
waittime] Int
1
string_to_ugens :: String -> [Ugen]
string_to_ugens :: String -> [Ugen]
string_to_ugens String
nm = Int -> Ugen
forall a b. (Integral a, Num b) => a -> b
fromIntegral (String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
nm) Ugen -> [Ugen] -> [Ugen]
forall a. a -> [a] -> [a]
: (Char -> Ugen) -> String -> [Ugen]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> Ugen
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Ugen) -> (Char -> Int) -> Char -> Ugen
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
forall a. Enum a => a -> Int
fromEnum) String
nm
sendReply :: Ugen -> Ugen -> String -> [Ugen] -> Ugen
sendReply :: Ugen -> Ugen -> String -> [Ugen] -> Ugen
sendReply Ugen
i Ugen
k String
n [Ugen]
v = String -> [Ugen] -> Int -> Ugen
C.mkFilter String
"SendReply" ([Ugen
i, Ugen
k] [Ugen] -> [Ugen] -> [Ugen]
forall a. [a] -> [a] -> [a]
++ String -> [Ugen]
string_to_ugens String
n [Ugen] -> [Ugen] -> [Ugen]
forall a. [a] -> [a] -> [a]
++ [Ugen]
v) Int
0
unpack1FFT :: Ugen -> Ugen -> Ugen -> Ugen -> Ugen
unpack1FFT :: Ugen -> Ugen -> Ugen -> Ugen -> Ugen
unpack1FFT Ugen
buf Ugen
size Ugen
index_ Ugen
which = Rate -> String -> [Ugen] -> Int -> Ugen
C.mkOsc Rate
dr String
"Unpack1FFT" [Ugen
buf, Ugen
size, Ugen
index_, Ugen
which] Int
1