hsc3-lang-0.14: Haskell SuperCollider Language

Safe HaskellSafe-Inferred

Sound.SC3.Lang.Math

Contents

Description

sclang math functions.

Synopsis

SimpleNumber

ampdb :: Floating a => a -> aSource

SimpleNumber.ampdb converts linear amplitude to decibels.

 > [1,0.5,0.25,0.13,6e-2].collect({|i| i.ampdb.round}) == [0,-6,-12,-18,-24]
 map (round . ampdb) [1,0.5,0.25,0.13,6e-2] == [0,-6,-12,-18,-24]
 > [1,0.7,0.5,0.35,0.25].collect({|i| i.ampdb.round}) == [0,-3,-6,-9,-12]
 map (round . ampdb) [1,0.7,0.5,0.35,0.25] == [0,-3,-6,-9,-12]

dbamp :: Floating a => a -> aSource

SimpleNumber.dbamp converts decibels to a linear amplitude.

 > [0,-3,-6,-9,-12].collect({|i| (i.dbamp * 100).floor}) == [100,70,50,35,25]
 map (floor . (* 100) . dbamp) [0,-3,-6,-9,-12] == [100,70,50,35,25]

degreeToKey :: RealFrac a => [a] -> a -> a -> aSource

SimpleNumber.degreeToKey translates degree, scale and steps per octave to key.

 > (0..5).collect({|i| i.degreeToKey([0,1,5,9,11],12)}) == [0,1,5,9,11,12]
 map (degreeToKey [0,1,5,9,11] 12) [0..5] == [0,1,5,9,11,12]
 degreeToKey [0,2,4,5,7,9,11] 12 5 == 9

inf :: Bounded a => aSource

Psuedo-inifite bounded value.

 inf == maxBound

isInf :: (Eq a, Bounded a) => a -> BoolSource

Predicate for inf.

 isInf inf == True

linexp :: (Ord a, Floating a) => a -> a -> a -> a -> a -> aSource

SimpleNumber.linexp shifts from linear to exponential ranges.

 > [1,1.5,2].collect({|i| i.linexp(1,2,10,100).floor}) == [10,31,100]
 map (floor . linexp 1 2 10 100) [1,1.5,2] == [10,31,100]

log10 :: Floating a => a -> aSource

SimpleNumber.log10 is the base 10 logarithm.

midicps :: Floating a => a -> aSource

SimpleNumber.midicps translates from midi note number to cycles per second.

 > [57,69].collect({|i| i.midicps}) == [220,440]
 map midicps [57,69] == [220,440]

UGen

exprange :: Floating b => b -> b -> b -> bSource

UGen.exprand shifts a linear (0,1) value to an exponential range.

 map (floor . exprange 10 100) [0,0.5,1] == [10,31,100]

Binary

bitChar :: Char -> BoolSource

0 is false, 1 is True, else error.

 map bitChar "01" == [False,True]

parseBits :: (Num a, Bits a) => String -> aSource

Parse a sequence of 0 and 1 characters as a BE bit sequence

 parseBits "101" == 5
 parseBits "00001111" == 15