Floating is a Haskell type class for floating-point values such as Float and Double, supplying trigonometric, logarithmic, and related mathematical operations. section 10.1.1
Applying a trigonometric operation
Use sin with an explicitly typed Double when generating or processing a signal: sin (fromIntegral (1 :: Int)) :: Double produces 0.8414709848078965. section 10.1.1
Signal-processing code commonly represents samples, frequencies, and durations as Double. Floating-point calculations can then be converted to integral sample counts with round when a whole number is required. section 10.1.1
Listing 10.1 Types and helper functions for dealing with signals
type Sample = Double #1 type Signal = [Sample] #1 type Hz = Double #1 type Seconds = Double #1 sampleRate :: Double #2 sampleRate = 44100 samplesPerPeriod :: Hz -> Int samplesPerPeriod hz = round $ sampleRate / hz #3 samplesPerSecond :: Seconds -> Int samplesPerSecond duration = round $ duration * sampleRate #4
Inspect the signal types and helper functions that use Double arithmetic before converting calculated sample counts to Int. section 10.1.1
