Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial code for loading wave file and printing first 1000 samples

  • Loading branch information...
commit ea4ebb8a4fd3278d322551a63ee72aa4d7065682 0 parents
= authored
Showing with 23 additions and 0 deletions.
  1. +22 −0 FreqAnalysis.hs
  2. +1 −0  README
  3. BIN  amen.wav
22 FreqAnalysis.hs
@@ -0,0 +1,22 @@
+
+import Numeric.FFT
+import Data.WAVE
+import System.Environment (getArgs)
+
+-- Gets a list of samples for the specified channel from the wave file
+getChannel :: Int -> WAVE -> [Double]
+getChannel channel wave = map (\x -> sampleToDouble $ x !! channel) $ waveSamples wave
+
+-- Plays a specified sound file
+playSound :: String -> IO()
+playSound file = do
+ putStrLn $ "playing sound " ++ file
+ wave <- getWAVEFile file
+ print $ take 256 $ getChannel 1 wave
+
+-- Entry point for the application
+main = do
+ args <- getArgs
+ case args of
+ [input] -> playSound input
+ _ -> putStrLn "One argument required (wav file name)"
1  README
@@ -0,0 +1 @@
+This is a simple project which reads in a wave file and plays it whilst visualizing the frequency content with openGL. It is written in response to a Hoodlums meetup in London on May 12th 2011.
BIN  amen.wav
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.