Safe Haskell | Safe-Inferred |
---|
sclang
math functions.
- ampdb :: Floating a => a -> a
- dbamp :: Floating a => a -> a
- degreeToKey :: RealFrac a => [a] -> a -> a -> a
- inf :: Bounded a => a
- isInf :: (Eq a, Bounded a) => a -> Bool
- linexp :: (Ord a, Floating a) => a -> a -> a -> a -> a -> a
- log10 :: Floating a => a -> a
- midicps :: Floating a => a -> a
- exprange :: Floating b => b -> b -> b -> b
- bitChar :: Char -> Bool
- parseBits :: (Num a, Bits a) => String -> a
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
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]
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]