hsc3-0.15.1: Haskell SuperCollider

Safe Haskell Safe-Inferred Haskell98

Sound.SC3.UGen.Math

Description

Non-standard mathematical classes and class instances.

Synopsis

Documentation

Pseudo-infinite constant UGen.

sc3_true :: Num n => n Source

True is conventionally 1. The test to determine true is `> 0`.

sc3_false :: Num n => n Source

False is conventionally 0.

sc3_not :: (Ord n, Num n) => n -> n Source

Lifted `not`.

```sc3_not sc3_true == sc3_false
sc3_not sc3_false == sc3_true```

sc3_bool :: Num n => Bool -> n Source

Translate `Bool` to `sc3_true` and `sc3_false`.

sc3_comparison :: Num n => (n -> n -> Bool) -> n -> n -> n Source

Lift comparison function.

sc3_eq :: (Num n, Eq n) => n -> n -> n Source

Lifted `==`.

sc3_neq :: (Num n, Eq n) => n -> n -> n Source

Lifted `/=`.

sc3_lt :: (Num n, Ord n) => n -> n -> n Source

Lifted `<`.

sc3_lte :: (Num n, Ord n) => n -> n -> n Source

Lifted `<=`.

sc3_gt :: (Num n, Ord n) => n -> n -> n Source

Lifted `>`.

sc3_gte :: (Num n, Ord n) => n -> n -> n Source

Lifted `>=`.

roundTo_ :: (RealFrac n, Ord n) => n -> n -> n Source

Variant of `SC3` `roundTo` function.

```let r = [0,0,0.25,0.25,0.5,0.5,0.5,0.75,0.75,1,1]
in map (`roundTo_` 0.25) [0,0.1 .. 1] == r```

sc3_round_to :: (RealFrac n, Ord n) => n -> n -> n Source

sc3_idiv :: RealFrac n => n -> n -> n Source

binop_hs_tbl :: (Real n, Floating n, RealFrac n, Ord n) => [(Binary, n -> n -> n)] Source

Association table for `Binary` to haskell function implementing operator.

binop_special_hs :: (Real n, RealFrac n, Floating n, Ord n) => Int -> Maybe (n -> n -> n) Source

`lookup` `binop_hs_tbl` via `toEnum`.

uop_hs_tbl :: (RealFrac n, Floating n, Ord n) => [(Unary, n -> n)] Source

Association table for `Unary` to haskell function implementing operator.

uop_special_hs :: (RealFrac n, Floating n, Ord n) => Int -> Maybe (n -> n) Source

`lookup` `uop_hs_tbl` via `toEnum`.

class (Eq a, Num a) => EqE a where Source

Variant on Eq class, result is of the same type as the values compared.

Minimal complete definition

Nothing

Methods

(==*) :: a -> a -> a Source

(/=*) :: a -> a -> a Source

Instances

 EqE Double EqE Float EqE Int EqE Int32 EqE Int64 EqE Integer EqE UGen

class (Ord a, Num a) => OrdE a where Source

Variant on Ord class, result is of the same type as the values compared.

Minimal complete definition

Nothing

Methods

(<*) :: a -> a -> a Source

(<=*) :: a -> a -> a Source

(>*) :: a -> a -> a Source

(>=*) :: a -> a -> a Source

Instances

 OrdE Double OrdE Float OrdE Int OrdE Int32 OrdE Int64 OrdE Integer OrdE UGen

sc3_properFraction :: (RealFrac t, Num t) => t -> (t, t) Source

sc3_truncate :: (RealFrac a, Num a) => a -> a Source

sc3_round :: (RealFrac a, Num a) => a -> a Source

sc3_ceiling :: (RealFrac a, Num a) => a -> a Source

sc3_floor :: (RealFrac a, Num a) => a -> a Source

class RealFrac a => RealFracE a where Source

Variant of `RealFrac` with non `Integral` results.

Minimal complete definition

Nothing

Methods

properFractionE :: a -> (a, a) Source

truncateE :: a -> a Source

roundE :: a -> a Source

ceilingE :: a -> a Source

floorE :: a -> a Source

Instances

 RealFracE Double RealFracE Float RealFracE UGen

`UGen` form or `roundTo_`.

`UGen` form of `ceilingE`.

midiCPS' :: Floating a => a -> a Source

`Floating` form of `midiCPS`.

cpsMIDI' :: Floating a => a -> a Source

`Floating` form of `cpsMIDI`.

cpsOct' :: Floating a => a -> a Source

ampDb' :: Floating a => a -> a Source

dbAmp' :: Floating a => a -> a Source

cubed' :: Num a => a -> a Source

midiRatio' :: Floating a => a -> a Source

octCPS' :: Floating a => a -> a Source

ratioMIDI' :: Floating a => a -> a Source

squared' :: Num a => a -> a Source

class (Floating a, Ord a) => UnaryOp a where Source

Unary operator class.

`map (floor . (* 1e4) . dbAmp) [-90,-60,-30,0] == [0,10,316,10000]`

Minimal complete definition

Nothing

Methods

ampDb :: a -> a Source

asFloat :: a -> a Source

asInt :: a -> a Source

cpsMIDI :: a -> a Source

cpsOct :: a -> a Source

cubed :: a -> a Source

dbAmp :: a -> a Source

distort :: a -> a Source

frac :: a -> a Source

isNil :: a -> a Source

log10 :: a -> a Source

log2 :: a -> a Source

midiCPS :: a -> a Source

midiRatio :: a -> a Source

notE :: a -> a Source

notNil :: a -> a Source

octCPS :: a -> a Source

ramp_ :: a -> a Source

ratioMIDI :: a -> a Source

softClip :: a -> a Source

squared :: a -> a Source

Instances

 UnaryOp Double UnaryOp Float UnaryOp UGen

difSqr' :: Num a => a -> a -> a Source

hypotx' :: (Ord a, Floating a) => a -> a -> a Source

class (Floating a, RealFrac a, Ord a) => BinaryOp a where Source

Binary operator class.

Minimal complete definition

Nothing

Methods

absDif :: a -> a -> a Source

amClip :: a -> a -> a Source

atan2E :: a -> a -> a Source

clip2 :: a -> a -> a Source

difSqr :: a -> a -> a Source

excess :: a -> a -> a Source

exprandRange :: a -> a -> a Source

fill :: a -> a -> a Source

firstArg :: a -> a -> a Source

fold2 :: a -> a -> a Source

gcdE :: a -> a -> a Source

hypot :: a -> a -> a Source

hypotx :: a -> a -> a Source

iDiv :: a -> a -> a Source

lcmE :: a -> a -> a Source

modE :: a -> a -> a Source

randRange :: a -> a -> a Source

ring1 :: a -> a -> a Source

ring2 :: a -> a -> a Source

ring3 :: a -> a -> a Source

ring4 :: a -> a -> a Source

roundUp :: a -> a -> a Source

scaleNeg :: a -> a -> a Source

sqrDif :: a -> a -> a Source

sqrSum :: a -> a -> a Source

sumSqr :: a -> a -> a Source

thresh :: a -> a -> a Source

trunc :: a -> a -> a Source

wrap2 :: a -> a -> a Source

Instances

 BinaryOp Double BinaryOp Float BinaryOp UGen

The SC3 `%` operator is the `mod'` function.

```> 1.5 % 1.2 // ~= 0.3
> -1.5 % 1.2 // ~= 0.9
> 1.5 % -1.2 // ~= -0.9
> -1.5 % -1.2 // ~= -0.3```
```1.5 `fmod_f32` 1.2 -- ~= 0.3
(-1.5) `fmod_f32` 1.2 -- ~= 0.9
1.5 `fmod_f32` (-1.2) -- ~= -0.9
(-1.5) `fmod_f32` (-1.2) -- ~= -0.3```
```> 1.2 % 1.5 // ~= 1.2
> -1.2 % 1.5 // ~= 0.3
1.2 % -1.5 // ~= -0.3
-1.2 % -1.5 // ~= -1.2```
```1.2 `fmod_f32` 1.5 -- ~= 1.2
(-1.2) `fmod_f32` 1.5 -- ~= 0.3
1.2 `fmod_f32` (-1.5) -- ~= -0.3
(-1.2) `fmod_f32` (-1.5) -- ~= -1.2```

class Num a => TernaryOp a where Source

Ternary operator class.

Minimal complete definition

Nothing

Methods

mul_add :: a -> a -> a -> a Source

Instances

 TernaryOp Double TernaryOp Float TernaryOp UGen

wrap' :: RealFracE n => n -> n -> n -> n Source

Wrap k to within range (i,j), ie. `AbstractFunction.wrap`.

```> [5,6].wrap(0,5) == [5,0]
map (wrap' 0 5) [5,6] == [5,0]```
```> [9,10,5,6,7,8,9,10,5,6].wrap(5,10) == [9,10,5,6,7,8,9,10,5,6]
map (wrap' 5 10) [3..12] == [9,10,5,6,7,8,9,10,5,6]```

genericWrap :: (Ord a, Num a) => a -> a -> a -> a Source

Generic variant of `wrap'`.

```> [5,6].wrap(0,5) == [5,0]
map (genericWrap 0 5) [5,6] == [5,0]```
```> [9,10,5,6,7,8,9,10,5,6].wrap(5,10) == [9,10,5,6,7,8,9,10,5,6]
map (genericWrap (5::Integer) 10) [3..12] == [9,10,5,6,7,8,9,10,5,6]```

wrap_ :: RealFracE n => n -> n -> n -> n Source

Variant of `wrap'` with `SC3` argument ordering.

`map (\n -> wrap_ n 5 10) [3..12] == map (wrap' 5 10) [3..12]`

foldToRange :: (Ord a, Num a) => a -> a -> a -> a Source

Fold k to within range (i,j), ie. `AbstractFunction.fold`

`map (foldToRange 5 10) [3..12] == [7,6,5,6,7,8,9,10,9,8]`

fold_ :: (Ord a, Num a) => a -> a -> a -> a Source

Variant of `foldToRange` with `SC3` argument ordering.

clip' :: Ord a => a -> a -> a -> a Source

Clip k to within range (i,j),

`map (clip' 5 10) [3..12] == [5,5,5,6,7,8,9,10,10,10]`

clip_ :: Ord a => a -> a -> a -> a Source

Variant of `clip'` with `SC3` argument ordering.

hypot_ :: Floating a => a -> a -> a Source

linLin_muladd :: Fractional t => t -> t -> t -> t -> (t, t) Source

Calculate multiplier and add values for `linLin` transform.

```range_muladd 3 4 == (0.5,3.5)
linLin_muladd (-1) 1 3 4 == (0.5,3.5)
linLin_muladd 0 1 3 4 == (1,3)
linLin_muladd (-1) 1 0 1 == (0.5,0.5)```

linlin :: (Fractional a, TernaryOp a) => a -> a -> a -> a -> a -> a Source

Map from one linear range to another linear range.

linlin' :: Fractional a => a -> a -> a -> a -> a -> a Source

Variant without `TernaryOp` constraint.

urange :: (Fractional a, TernaryOp a) => a -> a -> a -> a Source

Scale uni-polar (0,1) input to linear (l,r) range

`map (urange 3 4) [0,0.5,1] == [3,3.5,4]`

urange' :: Fractional a => a -> a -> a -> a Source

Variant without `TernaryOp` constraint.

range_muladd :: Fractional t => t -> t -> (t, t) Source

Calculate multiplier and add values for `range` transform.

`range_muladd 3 4 == (0.5,3.5)`

range :: (Fractional a, TernaryOp a) => a -> a -> a -> a Source

Scale bi-polar (-1,1) input to linear (l,r) range. Note that the argument order is not the same as `linLin`.

```map (range 3 4) [-1,0,1] == [3,3.5,4]
map (\x -> let (m,a) = linLin_muladd (-1) 1 3 4 in x * m + a) [-1,0,1]```

range' :: Fractional a => a -> a -> a -> a Source

Variant without `TernaryOp` constraint.