Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Visualizer

View Visualizer.hs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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.