{-# LINE 1 "./Sound/ProteaAudio.chs" #-}
{-#LANGUAGE ForeignFunctionInterface #-}
{-#LANGUAGE OverloadedStrings #-}
{-#LANGUAGE CPP #-}
module Sound.ProteaAudio (
Sample(),
Sound(),
initAudio,
finishAudio,
volume,
soundActiveAll,
soundStopAll,
loaderAvailable,
sampleFromMemoryPcm,
sampleFromMemoryWav,
sampleFromMemoryOgg,
sampleFromMemoryMp3,
sampleFromFile,
sampleDestroy,
soundLoop,
soundPlay,
soundLoopOn,
soundPlayOn,
soundUpdate,
soundStop,
soundActive
) where
import qualified Foreign.C.String as C2HSImp
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import Foreign
import Foreign.C
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
newtype Sample = Sample{ fromSample :: (C2HSImp.CULong) }
newtype Sound = Sound{ fromSound :: (C2HSImp.CULong) }
initAudio :: (Int)
-> (Int)
-> (Int)
-> IO ((Bool))
initAudio a1 a2 a3 =
let {a1' = fromIntegral a1} in
let {a2' = fromIntegral a2} in
let {a3' = fromIntegral a3} in
initAudio'_ a1' a2' a3' >>= \res ->
let {res' = C2HSImp.toBool res} in
return (res')
{-# LINE 75 "./Sound/ProteaAudio.chs" #-}
finishAudio :: IO ()
finishAudio =
finishAudio'_ >>
return ()
{-# LINE 80 "./Sound/ProteaAudio.chs" #-}
loaderAvailable :: (String)
-> IO ((Bool))
loaderAvailable a1 =
C2HSImp.withCString a1 $ \a1' ->
loaderAvailable'_ a1' >>= \res ->
let {res' = C2HSImp.toBool res} in
return (res')
{-# LINE 86 "./Sound/ProteaAudio.chs" #-}
_sampleFromMemoryPcm :: (Ptr CChar)
-> (Int)
-> (Int)
-> (Int)
-> (Int)
-> (Float)
-> IO ((Sample))
_sampleFromMemoryPcm a1 a2 a3 a4 a5 a6 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
let {a3' = fromIntegral a3} in
let {a4' = fromIntegral a4} in
let {a5' = fromIntegral a5} in
let {a6' = realToFrac a6} in
_sampleFromMemoryPcm'_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = Sample res} in
return (res')
{-# LINE 98 "./Sound/ProteaAudio.chs" #-}
_sampleFromMemoryWav :: (Ptr CChar)
-> (Int)
-> (Float)
-> IO ((Sample))
_sampleFromMemoryWav a1 a2 a3 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
let {a3' = realToFrac a3} in
_sampleFromMemoryWav'_ a1' a2' a3' >>= \res ->
let {res' = Sample res} in
return (res')
{-# LINE 106 "./Sound/ProteaAudio.chs" #-}
_sampleFromMemoryOgg :: (Ptr CChar)
-> (Int)
-> (Float)
-> IO ((Sample))
_sampleFromMemoryOgg a1 a2 a3 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
let {a3' = realToFrac a3} in
_sampleFromMemoryOgg'_ a1' a2' a3' >>= \res ->
let {res' = Sample res} in
return (res')
{-# LINE 114 "./Sound/ProteaAudio.chs" #-}
_sampleFromMemoryMp3 :: (Ptr CChar)
-> (Int)
-> (Float)
-> IO ((Sample))
_sampleFromMemoryMp3 a1 a2 a3 =
let {a1' = id a1} in
let {a2' = fromIntegral a2} in
let {a3' = realToFrac a3} in
_sampleFromMemoryMp3'_ a1' a2' a3' >>= \res ->
let {res' = Sample res} in
return (res')
{-# LINE 122 "./Sound/ProteaAudio.chs" #-}
sampleFromMemoryPcm :: ByteString
-> Int
-> Int
-> Int
-> Float
-> IO Sample
sampleFromMemoryPcm pcmData channels sampleRate bitsPerSample volume =
BS.useAsCStringLen pcmData $ \(ptr, size) -> _sampleFromMemoryPcm ptr size channels sampleRate bitsPerSample volume
sampleFromMemoryWav :: ByteString
-> Float
-> IO Sample
sampleFromMemoryWav wavData volume = BS.useAsCStringLen wavData $ \(ptr, size) -> _sampleFromMemoryWav ptr size volume
sampleFromMemoryOgg :: ByteString
-> Float
-> IO Sample
sampleFromMemoryOgg oggData volume = BS.useAsCStringLen oggData $ \(ptr, size) -> _sampleFromMemoryOgg ptr size volume
sampleFromMemoryMp3 :: ByteString
-> Float
-> IO Sample
sampleFromMemoryMp3 mp3Data volume = BS.useAsCStringLen mp3Data $ \(ptr, size) -> _sampleFromMemoryMp3 ptr size volume
sampleFromMemory :: ByteString -> Float -> IO Sample
sampleFromMemory bs volume
| BS.take 4 bs == "RIFF"
= sampleFromMemoryWav bs volume
| BS.take 4 bs == "OggS"
= sampleFromMemoryOgg bs volume
| BS.take 3 bs == "ID3" || BS.take 2 bs `elem` ["\xFF\xFB", "\xFF\xF3", "\xFF\xF2"]
= sampleFromMemoryMp3 bs volume
| otherwise
= error "Could not detect audio format"
sampleFromFile :: (String)
-> (Float)
-> IO ((Sample))
sampleFromFile a1 a2 =
C2HSImp.withCString a1 $ \a1' ->
let {a2' = realToFrac a2} in
sampleFromFile'_ a1' a2' >>= \res ->
let {res' = Sample res} in
return (res')
{-# LINE 169 "./Sound/ProteaAudio.chs" #-}
sampleDestroy :: (Sample) -> IO ((Bool))
sampleDestroy a1 =
let {a1' = fromSample a1} in
sampleDestroy'_ a1' >>= \res ->
let {res' = C2HSImp.toBool res} in
return (res')
{-# LINE 172 "./Sound/ProteaAudio.chs" #-}
volume :: (Float)
-> (Float)
-> IO ()
volume a1 a2 =
let {a1' = realToFrac a1} in
let {a2' = realToFrac a2} in
volume'_ a1' a2' >>
return ()
{-# LINE 179 "./Sound/ProteaAudio.chs" #-}
soundActiveAll :: IO ((Int))
soundActiveAll =
soundActiveAll'_ >>= \res ->
let {res' = fromIntegral res} in
return (res')
{-# LINE 182 "./Sound/ProteaAudio.chs" #-}
soundStopAll :: IO ()
soundStopAll =
soundStopAll'_ >>
return ()
{-# LINE 185 "./Sound/ProteaAudio.chs" #-}
soundLoop :: (Sample)
-> (Float)
-> (Float)
-> (Float)
-> (Float)
-> IO ((Sound))
soundLoop a1 a2 a3 a4 a5 =
let {a1' = fromSample a1} in
let {a2' = realToFrac a2} in
let {a3' = realToFrac a3} in
let {a4' = realToFrac a4} in
let {a5' = realToFrac a5} in
soundLoop'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = Sound res} in
return (res')
{-# LINE 195 "./Sound/ProteaAudio.chs" #-}
soundPlay :: (Sample)
-> (Float)
-> (Float)
-> (Float)
-> (Float)
-> IO ((Sound))
soundPlay a1 a2 a3 a4 a5 =
let {a1' = fromSample a1} in
let {a2' = realToFrac a2} in
let {a3' = realToFrac a3} in
let {a4' = realToFrac a4} in
let {a5' = realToFrac a5} in
soundPlay'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = Sound res} in
return (res')
{-# LINE 205 "./Sound/ProteaAudio.chs" #-}
soundPlayOn :: (Int)
-> (Sample)
-> (Float)
-> (Float)
-> (Float)
-> (Float)
-> IO ((Sound))
soundPlayOn a1 a2 a3 a4 a5 a6 =
let {a1' = fromIntegral a1} in
let {a2' = fromSample a2} in
let {a3' = realToFrac a3} in
let {a4' = realToFrac a4} in
let {a5' = realToFrac a5} in
let {a6' = realToFrac a6} in
soundPlayOn'_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = Sound res} in
return (res')
{-# LINE 216 "./Sound/ProteaAudio.chs" #-}
soundLoopOn :: (Int)
-> (Sample)
-> (Float)
-> (Float)
-> (Float)
-> (Float)
-> IO ((Sound))
soundLoopOn a1 a2 a3 a4 a5 a6 =
let {a1' = fromIntegral a1} in
let {a2' = fromSample a2} in
let {a3' = realToFrac a3} in
let {a4' = realToFrac a4} in
let {a5' = realToFrac a5} in
let {a6' = realToFrac a6} in
soundLoopOn'_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = Sound res} in
return (res')
{-# LINE 227 "./Sound/ProteaAudio.chs" #-}
soundUpdate :: (Sound)
-> (Bool)
-> (Float)
-> (Float)
-> (Float)
-> (Float)
-> IO ((Bool))
soundUpdate a1 a2 a3 a4 a5 a6 =
let {a1' = fromSound a1} in
let {a2' = C2HSImp.fromBool a2} in
let {a3' = realToFrac a3} in
let {a4' = realToFrac a4} in
let {a5' = realToFrac a5} in
let {a6' = realToFrac a6} in
soundUpdate'_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = C2HSImp.toBool res} in
return (res')
{-# LINE 238 "./Sound/ProteaAudio.chs" #-}
soundStop :: (Sound) -> IO ((Bool))
soundStop a1 =
let {a1' = fromSound a1} in
soundStop'_ a1' >>= \res ->
let {res' = C2HSImp.toBool res} in
return (res')
{-# LINE 241 "./Sound/ProteaAudio.chs" #-}
soundActive :: (Sound) -> IO ((Bool))
soundActive a1 =
let {a1' = fromSound a1} in
soundActive'_ a1' >>= \res ->
let {res' = C2HSImp.toBool res} in
return (res')
{-# LINE 244 "./Sound/ProteaAudio.chs" #-}
foreign import ccall safe "Sound/ProteaAudio.chs.h initAudio"
initAudio'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))
foreign import ccall safe "Sound/ProteaAudio.chs.h finishAudio"
finishAudio'_ :: (IO ())
foreign import ccall safe "Sound/ProteaAudio.chs.h loaderAvailable"
loaderAvailable'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (IO C2HSImp.CInt))
foreign import ccall safe "Sound/ProteaAudio.chs.h _sampleFromMemoryPcm"
_sampleFromMemoryPcm'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CFloat -> (IO C2HSImp.CULong)))))))
foreign import ccall safe "Sound/ProteaAudio.chs.h _sampleFromMemoryWav"
_sampleFromMemoryWav'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CFloat -> (IO C2HSImp.CULong))))
foreign import ccall safe "Sound/ProteaAudio.chs.h _sampleFromMemoryOgg"
_sampleFromMemoryOgg'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CFloat -> (IO C2HSImp.CULong))))
foreign import ccall safe "Sound/ProteaAudio.chs.h _sampleFromMemoryMp3"
_sampleFromMemoryMp3'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CFloat -> (IO C2HSImp.CULong))))
foreign import ccall safe "Sound/ProteaAudio.chs.h sampleFromFile"
sampleFromFile'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CFloat -> (IO C2HSImp.CULong)))
foreign import ccall safe "Sound/ProteaAudio.chs.h sampleDestroy"
sampleDestroy'_ :: (C2HSImp.CULong -> (IO C2HSImp.CInt))
foreign import ccall safe "Sound/ProteaAudio.chs.h volume"
volume'_ :: (C2HSImp.CFloat -> (C2HSImp.CFloat -> (IO ())))
foreign import ccall safe "Sound/ProteaAudio.chs.h soundActiveAll"
soundActiveAll'_ :: (IO C2HSImp.CInt)
foreign import ccall safe "Sound/ProteaAudio.chs.h soundStopAll"
soundStopAll'_ :: (IO ())
foreign import ccall safe "Sound/ProteaAudio.chs.h soundLoop"
soundLoop'_ :: (C2HSImp.CULong -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (IO C2HSImp.CULong))))))
foreign import ccall safe "Sound/ProteaAudio.chs.h soundPlay"
soundPlay'_ :: (C2HSImp.CULong -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (IO C2HSImp.CULong))))))
foreign import ccall safe "Sound/ProteaAudio.chs.h soundPlayOn"
soundPlayOn'_ :: (C2HSImp.CUInt -> (C2HSImp.CULong -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (IO C2HSImp.CULong)))))))
foreign import ccall safe "Sound/ProteaAudio.chs.h soundLoopOn"
soundLoopOn'_ :: (C2HSImp.CUInt -> (C2HSImp.CULong -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (IO C2HSImp.CULong)))))))
foreign import ccall safe "Sound/ProteaAudio.chs.h soundUpdate"
soundUpdate'_ :: (C2HSImp.CULong -> (C2HSImp.CInt -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (C2HSImp.CFloat -> (IO C2HSImp.CInt)))))))
foreign import ccall safe "Sound/ProteaAudio.chs.h soundStop"
soundStop'_ :: (C2HSImp.CULong -> (IO C2HSImp.CInt))
foreign import ccall safe "Sound/ProteaAudio.chs.h soundActive"
soundActive'_ :: (C2HSImp.CULong -> (IO C2HSImp.CInt))