module Vivid.ByteBeat (
(&&&)
, (|||)
, (>>>)
, (<<<)
, xor
, byteBeatFromHelpFile
, baseThing
) where
import Vivid.SynthDef
import Vivid.UGens.Algebraic
import Vivid.UGens.Args
import Vivid.UGens.Generators.Deterministic (impulse)
import Vivid.UGens.Triggers (pulseCount)
(&&&), (|||), (>>>), (<<<)
:: (ToSig s0 a, ToSig s1 a) => s0 -> s1 -> SDBody' a Signal
(&&&) = biOp BitAnd
(|||) = biOp BitOr
(>>>) = biOp ShiftRight
(<<<) = biOp ShiftLeft
byteBeatFromHelpFile :: SDBody' a Signal
byteBeatFromHelpFile = baseThing $ \t ->
(((t ~* 15) &&& (t >>> 5)) |||
((t ~* 5) &&& (t >>> 3)) |||
((t ~* 2) &&& (t >>> 9)) |||
((t ~* 8) &&& (t >>> 11)))
~- 3
baseThing :: (Signal -> SDBody' a Signal) -> SDBody' a Signal
baseThing f = do
t <- pulseCount (trig_ $ impulse (freq_ 8e3))
sig0 <- f t
sig1 <- biOp Mod sig0 256
((sig1 ~/ 127) ~- 1) ~* 0.1