Popularity
6.9
Growing
Activity
0.0
Stable
13
5
7
Monthly Downloads: 36
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags:
Codec
HCodecs alternatives and similar packages
Based on the "Codec" category.
Alternatively, view HCodecs alternatives based on common mentions on social networks and blogs.
-
threefish
Haskell implementation of the Threefish block cipher and the Skein hash function built on it.
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
Promo
www.saashub.com
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of HCodecs or a related project?
README
HCodecs - A library to read, write and manipulate MIDI, WAVE, and SoundFont2 files.
Code example
This programs generates a short WAV file "sample.wav", then reads it and prints each sample.
import Codec.Wav ( exportFile, importFile )
import Data.Audio ( Audio(Audio) )
import Data.Array.Unboxed ( listArray, elems )
import Data.Int ( Int32 )
import Data.Maybe ( fromMaybe )
import System.IO (FilePath)
filename = "sample.wav"
sinewave :: [Float]
sinewave = map (\x -> sin ((fromInteger x) / 10.0)) [1..10000]
outMain :: FilePath -> IO ()
outMain path = do
let fs :: [Float]
fs = sinewave
l = 1000
rate = 44100
-- Float is 32bit, so i use Int32 for each sample in the output.
let maxInt32 :: Float
maxInt32 = fromIntegral (maxBound::Int32)
-- actual transformation function
rounder :: Float -> Int32
rounder = round . (*maxInt32)
exportFile path ( Audio rate 1 -- 1 channel
$ listArray (0,l)
$ map rounder
$ fs)
inMain :: FilePath -> IO ()
inMain path = do
maybeAudio <- importFile path
case maybeAudio :: Either String (Audio Int32) of
Left s -> putStrLn $ "wav decoding error: " ++ s
Right (Audio rate channels samples) -> do
putStrLn $ "rate = " ++ show rate
putStrLn $ "channels: " ++ show channels
print $ elems samples
main = do
putStrLn $ "* Outputting the sound to "++filename
outMain filename
putStrLn $ "* Printing the content of "++filename
inMain filename
-- Original by hexagoxel @ freenode/#haskell
-- Modified by Vitaly "_Vi" Shukela