Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Visualizer
module Visualiser where
import Numeric.FFT
import Data.Complex
test :: [Complex Double]
test = concat $ replicate 16 (replicate 8 1.0 ++ replicate 8 (-1.0))
freqs :: [Complex Double] -> [Double]
freqs samples = take (n `div` 2) . map (/ fromIntegral n) . map magnitude $ fft samples
where n = length samples
groupBins :: Int -> [Double] -> [Double]
groupBins i xs = map (/ fromIntegral binSize) . map sum $ chunksOf binSize xs
where binSize = length xs `div` i
chunksOf :: Int -> [a] -> [[a]]
chunksOf k = go
where
go t = case splitAt k t of
(a,b) | null a -> []
| otherwise -> a : go b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.