hsc3-0.20: Haskell SuperCollider
Safe HaskellSafe-Inferred
LanguageHaskell2010

Sound.Sc3.Ugen.Ugen

Description

Unit generator (Ugen) type and instances.

Synopsis

Basic types

type Sample = Double Source #

Sc3 samples are 32-bit Float. hsc3 uses 64-bit Double. If Ugen values are used more generally (ie. see hsc3-forth) Float may be too imprecise, i.e. for representing time stamps.

data Ugen Source #

Union type of Unit Generator forms.

Instances

Instances details
Bits Ugen Source #

Ugens are bit patterns.

Instance details

Defined in Sound.Sc3.Ugen.Ugen

Enum Ugen Source #

Unit generators are enumerable.

Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

succ :: Ugen -> Ugen #

pred :: Ugen -> Ugen #

toEnum :: Int -> Ugen #

fromEnum :: Ugen -> Int #

enumFrom :: Ugen -> [Ugen] #

enumFromThen :: Ugen -> Ugen -> [Ugen] #

enumFromTo :: Ugen -> Ugen -> [Ugen] #

enumFromThenTo :: Ugen -> Ugen -> Ugen -> [Ugen] #

Floating Ugen Source #

Unit generators are floating point.

Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

pi :: Ugen #

exp :: Ugen -> Ugen #

log :: Ugen -> Ugen #

sqrt :: Ugen -> Ugen #

(**) :: Ugen -> Ugen -> Ugen #

logBase :: Ugen -> Ugen -> Ugen #

sin :: Ugen -> Ugen #

cos :: Ugen -> Ugen #

tan :: Ugen -> Ugen #

asin :: Ugen -> Ugen #

acos :: Ugen -> Ugen #

atan :: Ugen -> Ugen #

sinh :: Ugen -> Ugen #

cosh :: Ugen -> Ugen #

tanh :: Ugen -> Ugen #

asinh :: Ugen -> Ugen #

acosh :: Ugen -> Ugen #

atanh :: Ugen -> Ugen #

log1p :: Ugen -> Ugen #

expm1 :: Ugen -> Ugen #

log1pexp :: Ugen -> Ugen #

log1mexp :: Ugen -> Ugen #

Num Ugen Source #

Unit generators are numbers.

Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

(+) :: Ugen -> Ugen -> Ugen #

(-) :: Ugen -> Ugen -> Ugen #

(*) :: Ugen -> Ugen -> Ugen #

negate :: Ugen -> Ugen #

abs :: Ugen -> Ugen #

signum :: Ugen -> Ugen #

fromInteger :: Integer -> Ugen #

Read Ugen Source # 
Instance details

Defined in Sound.Sc3.Ugen.Ugen

Fractional Ugen Source #

Unit generators are fractional.

Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

(/) :: Ugen -> Ugen -> Ugen #

recip :: Ugen -> Ugen #

fromRational :: Rational -> Ugen #

Integral Ugen Source #

Unit generators are integral.

Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

quot :: Ugen -> Ugen -> Ugen #

rem :: Ugen -> Ugen -> Ugen #

div :: Ugen -> Ugen -> Ugen #

mod :: Ugen -> Ugen -> Ugen #

quotRem :: Ugen -> Ugen -> (Ugen, Ugen) #

divMod :: Ugen -> Ugen -> (Ugen, Ugen) #

toInteger :: Ugen -> Integer #

Real Ugen Source #

Unit generators are real.

Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

toRational :: Ugen -> Rational #

RealFrac Ugen Source # 
Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

properFraction :: Integral b => Ugen -> (b, Ugen) #

truncate :: Integral b => Ugen -> b #

round :: Integral b => Ugen -> b #

ceiling :: Integral b => Ugen -> b #

floor :: Integral b => Ugen -> b #

Show Ugen Source # 
Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

showsPrec :: Int -> Ugen -> ShowS #

show :: Ugen -> String #

showList :: [Ugen] -> ShowS #

Eq Ugen Source # 
Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

(==) :: Ugen -> Ugen -> Bool #

(/=) :: Ugen -> Ugen -> Bool #

Ord Ugen Source #

Unit generators are orderable (when Constants).

(constant 2 > constant 1) == True
Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

compare :: Ugen -> Ugen -> Ordering #

(<) :: Ugen -> Ugen -> Bool #

(<=) :: Ugen -> Ugen -> Bool #

(>) :: Ugen -> Ugen -> Bool #

(>=) :: Ugen -> Ugen -> Bool #

max :: Ugen -> Ugen -> Ugen #

min :: Ugen -> Ugen -> Ugen #

BinaryOp Ugen Source # 
Instance details

Defined in Sound.Sc3.Ugen.Ugen

EqE Ugen Source # 
Instance details

Defined in Sound.Sc3.Ugen.Ugen

OrdE Ugen Source # 
Instance details

Defined in Sound.Sc3.Ugen.Ugen

RealFracE Ugen Source # 
Instance details

Defined in Sound.Sc3.Ugen.Ugen

UnaryOp Ugen Source # 
Instance details

Defined in Sound.Sc3.Ugen.Ugen

Audible Ugen Source # 
Instance details

Defined in Sound.Sc3.Server.Transport.Fd

Methods

play_id :: Transport t => Int -> t -> Ugen -> IO () Source #

play :: Transport t => t -> Ugen -> IO () Source #

Audible Ugen Source # 
Instance details

Defined in Sound.Sc3.Server.Transport.Monad

Methods

playAt :: Transport m => Play_Opt -> Ugen -> m () Source #

play :: Transport m => Ugen -> m () Source #

Random Ugen Source #

Unit generators are stochastic. Only un-bracketed constant values are considered.

Instance details

Defined in Sound.Sc3.Ugen.Ugen

Methods

randomR :: RandomGen g => (Ugen, Ugen) -> g -> (Ugen, g) #

random :: RandomGen g => g -> (Ugen, g) #

randomRs :: RandomGen g => (Ugen, Ugen) -> g -> [Ugen] #

randoms :: RandomGen g => g -> [Ugen] #

Name

ugen_user_name :: String -> Special -> String Source #

Lookup operator name for operator Ugens, else Ugen name.

Instances

Parser

Accessors

u_constant_err :: Ugen -> Sample Source #

Erroring variant.

Mrg

mrg :: [Ugen] -> Ugen Source #

Multiple root graph constructor.

mrg_leftmost :: Ugen -> Ugen Source #

See into Mrg_U, follows leftmost rule until arriving at non-Mrg node.

Predicates

isConstant :: Ugen -> Bool Source #

Constant node predicate.

isSink :: Ugen -> Bool Source #

True if input is a sink Ugen, ie. has no outputs. Sees into Mrg.

ugenPrimitive :: Ugen -> Maybe (Primitive Ugen) Source #

Get Primitive from Ugen if Ugen is a Primitive.

Mce

mce :: [Ugen] -> Ugen Source #

Multiple channel expansion node constructor.

mceProxies :: Mce Ugen -> [Ugen] Source #

Type specified mce_to_list.

isMce :: Ugen -> Bool Source #

Multiple channel expansion node (Mce_U) predicate. Sees into Mrg.

mceChannels :: Ugen -> [Ugen] Source #

Output channels of Ugen as a list. If required, preserves the RHS of and Mrg node in channel 0.

mceDegree :: Ugen -> Maybe Int Source #

Number of channels to expand to. This function sees into Mrg, and is defined only for Mce nodes.

mceDegree_err :: Ugen -> Int Source #

Erroring variant.

mceExtend :: Int -> Ugen -> [Ugen] Source #

Extend Ugen to specified degree. Follows "leftmost" rule for Mrg nodes.

mceRequired :: [Ugen] -> Bool Source #

Is Mce required, ie. are any input values Mce?

mceInputTransform :: [Ugen] -> Maybe [[Ugen]] Source #

Apply Mce transform to a list of inputs. The transform extends each input so all are of equal length, and then transposes the matrix.

mceInputTransform [mce2 1 2,mce2 3 4] == Just [[1,3],[2,4]]
mceInputTransform [mce2 1 2,mce2 3 4,mce3 5 6 7] == Just [[1,3,5],[2,4,6],[1,3,7]]
mceInputTransform [mce2 (mce2 1 2) (mce2 3 4),mce2 5 6] == Just [[mce2 1 2,5],[mce2 3 4,6]]

mceBuild :: ([Ugen] -> Ugen) -> [Ugen] -> Ugen Source #

Build a Ugen after Mce transformation of inputs.

mce_is_direct_proxy :: Mce Ugen -> Bool Source #

True if Mce is an immediate proxy for a multiple-out Primitive. This is useful when disassembling graphs, ie. ugen_graph_forth_pp at hsc3-db. It's also useful when editing a Primitive after it is constructed, as in bracketUgen.

Bracketed

bracketUgen :: Ugen -> Brackets -> Ugen Source #

Attach Brackets (initialisation and cleanup message sequences) to Ugen. For simplicity and clarity, brackets can only be attached to Primitive, Constant and Control nodes. This will look into the direct (immediate) proxies of a Primitive.

ugenBrackets :: Ugen -> Brackets Source #

Retrieve Brackets from Ugen.

Validators

checkInput :: Ugen -> Ugen Source #

Ensure input Ugen is valid, ie. not a sink.

Constructors

constant :: Real n => n -> Ugen Source #

Constant value node constructor.

int_to_ugen :: Int -> Ugen Source #

Type specialised constant.

float_to_ugen :: Float -> Ugen Source #

Type specialised constant.

double_to_ugen :: Double -> Ugen Source #

Type specialised constant.

proxy :: Ugen -> Int -> Ugen Source #

Unit generator proxy node constructor.

rateOf :: Ugen -> Rate Source #

Determine the rate of a Ugen.

proxify :: Ugen -> Ugen Source #

Apply proxy transformation if required.

mk_ugen_select_rate :: String -> [Ugen] -> [Rate] -> Either Rate [Int] -> Rate Source #

Filters with DemandRate inputs run at ControlRate. This is a little unfortunate, it'd be nicer if the rate in this circumstance could be given.

mkUgen :: Maybe ([Sample] -> Sample) -> [Rate] -> Either Rate [Int] -> String -> [Ugen] -> Maybe [Ugen] -> Int -> Special -> UgenId -> Ugen Source #

Construct proxied and multiple channel expanded Ugen.

cf = constant function, rs = rate set, r = rate, nm = name, i = inputs, i_mce = list of Mce inputs, o = outputs.

Operators

mkOperator :: ([Sample] -> Sample) -> String -> [Ugen] -> Int -> Ugen Source #

Operator Ugen constructor.

mkUnaryOperator :: Sc3_Unary_Op -> (Sample -> Sample) -> Ugen -> Ugen Source #

Unary math constructor.

mkBinaryOperator_optimise_constants :: Sc3_Binary_Op -> (Sample -> Sample -> Sample) -> (Either Sample Sample -> Bool) -> Ugen -> Ugen -> Ugen Source #

Binary math constructor with constant optimisation.

constant 2 * constant 3 == constant 6
let o = sinOsc ar 440 0
o * 1 == o && 1 * o == o && o * 2 /= o
o + 0 == o && 0 + o == o && o + 1 /= o
o - 0 == o && 0 - o /= o
o / 1 == o && 1 / o /= o
o ** 1 == o && o ** 2 /= o

mkBinaryOperator :: Sc3_Binary_Op -> (Sample -> Sample -> Sample) -> Ugen -> Ugen -> Ugen Source #

Plain (non-optimised) binary math constructor.

Numeric instances

is_primitive_for :: String -> Ugen -> Bool Source #

Is u the primitive for the named Ugen.

is_constant_of :: Sample -> Ugen -> Bool Source #

Is u the primitive for the named Ugen.

is_math_binop :: Int -> Ugen -> Bool Source #

Is u a binary math operator with SPECIAL of k.

is_add_operator :: Ugen -> Bool Source #

Is u an ADD operator?

is_mul_operator :: Ugen -> Bool Source #

Is u an MUL operator?

mul_add_optimise_direct :: Ugen -> Ugen Source #

MulAdd re-writer, applicable only directly at add operator Ugen. The MulAdd Ugen is very sensitive to input rates. Add=AudioRate with In|Mul=InitialisationRate|Const will crash scsynth. This only considers primitives that do not have bracketing messages.

mul_add_optimise :: Ugen -> Ugen Source #

MulAdd optimiser, applicable at any Ugen (ie. checks u is an ADD ugen)

import Sound.Sc3
g1 = sinOsc ar 440 0 * 0.1 + control ir "x" 0.05
g2 = sinOsc ar 440 0 * control ir "x" 0.1 + 0.05
g3 = control ir "x" 0.1 * sinOsc ar 440 0 + 0.05
g4 = 0.05 + sinOsc ar 440 0 * 0.1

sum3_optimise_direct :: Ugen -> Ugen Source #

Sum3 re-writer, applicable only directly at add operator Ugen. This only considers nodes that have no bracketing messages.

sum3_optimise :: Ugen -> Ugen Source #

Sum3 optimiser, applicable at any u (ie. checks if u is an ADD operator).