module SDL.Raw.Audio (
audioInit,
audioQuit,
buildAudioCVT,
clearQueuedAudio,
closeAudio,
closeAudioDevice,
convertAudio,
freeWAV,
getAudioDeviceName,
getAudioDeviceStatus,
getAudioDriver,
getAudioStatus,
getCurrentAudioDriver,
getNumAudioDevices,
getNumAudioDrivers,
getQueuedAudioSize,
loadWAV,
loadWAV_RW,
lockAudio,
lockAudioDevice,
mixAudio,
mixAudioFormat,
openAudio,
openAudioDevice,
pauseAudio,
pauseAudioDevice,
queueAudio,
unlockAudio,
unlockAudioDevice
) where
import Control.Monad.IO.Class
import Data.Word
import Foreign.C.String
import Foreign.C.Types
import Foreign.Ptr
import SDL.Raw.Enum
import SDL.Raw.Filesystem
import SDL.Raw.Types
foreign import ccall "SDL.h SDL_AudioInit" audioInitFFI :: CString -> IO CInt
foreign import ccall "SDL.h SDL_AudioQuit" audioQuitFFI :: IO ()
foreign import ccall "SDL.h SDL_BuildAudioCVT" buildAudioCVTFFI :: Ptr AudioCVT -> AudioFormat -> Word8 -> CInt -> AudioFormat -> Word8 -> CInt -> IO CInt
foreign import ccall "SDL.h SDL_ClearQueuedAudio" clearQueuedAudioFFI :: AudioDeviceID -> IO ()
foreign import ccall "SDL.h SDL_CloseAudio" closeAudioFFI :: IO ()
foreign import ccall "SDL.h SDL_CloseAudioDevice" closeAudioDeviceFFI :: AudioDeviceID -> IO ()
foreign import ccall "SDL.h SDL_ConvertAudio" convertAudioFFI :: Ptr AudioCVT -> IO CInt
foreign import ccall "SDL.h SDL_FreeWAV" freeWAVFFI :: Ptr Word8 -> IO ()
foreign import ccall "SDL.h SDL_GetAudioDeviceName" getAudioDeviceNameFFI :: CInt -> CInt -> IO CString
foreign import ccall "SDL.h SDL_GetAudioDeviceStatus" getAudioDeviceStatusFFI :: AudioDeviceID -> IO AudioStatus
foreign import ccall "SDL.h SDL_GetAudioDriver" getAudioDriverFFI :: CInt -> IO CString
foreign import ccall "SDL.h SDL_GetAudioStatus" getAudioStatusFFI :: IO AudioStatus
foreign import ccall "SDL.h SDL_GetCurrentAudioDriver" getCurrentAudioDriverFFI :: IO CString
foreign import ccall "SDL.h SDL_GetNumAudioDevices" getNumAudioDevicesFFI :: CInt -> IO CInt
foreign import ccall "SDL.h SDL_GetNumAudioDrivers" getNumAudioDriversFFI :: IO CInt
foreign import ccall "SDL.h SDL_GetQueuedAudioSize" getQueuedAudioSizeFFI :: AudioDeviceID -> IO Word32
foreign import ccall "SDL.h SDL_LoadWAV_RW" loadWAV_RWFFI :: Ptr RWops -> CInt -> Ptr AudioSpec -> Ptr (Ptr Word8) -> Ptr Word32 -> IO (Ptr AudioSpec)
foreign import ccall "SDL.h SDL_LockAudio" lockAudioFFI :: IO ()
foreign import ccall "SDL.h SDL_LockAudioDevice" lockAudioDeviceFFI :: AudioDeviceID -> IO ()
foreign import ccall "SDL.h SDL_MixAudio" mixAudioFFI :: Ptr Word8 -> Ptr Word8 -> Word32 -> CInt -> IO ()
foreign import ccall "SDL.h SDL_MixAudioFormat" mixAudioFormatFFI :: Ptr Word8 -> Ptr Word8 -> AudioFormat -> Word32 -> CInt -> IO ()
foreign import ccall "SDL.h SDL_OpenAudio" openAudioFFI :: Ptr AudioSpec -> Ptr AudioSpec -> IO CInt
foreign import ccall "SDL.h SDL_OpenAudioDevice" openAudioDeviceFFI :: CString -> CInt -> Ptr AudioSpec -> Ptr AudioSpec -> CInt -> IO AudioDeviceID
foreign import ccall "SDL.h SDL_PauseAudio" pauseAudioFFI :: CInt -> IO ()
foreign import ccall "SDL.h SDL_PauseAudioDevice" pauseAudioDeviceFFI :: AudioDeviceID -> CInt -> IO ()
foreign import ccall "SDL.h SDL_QueueAudio" queueAudioFFI :: AudioDeviceID -> Ptr () -> Word32 -> IO CInt
foreign import ccall "SDL.h SDL_UnlockAudio" unlockAudioFFI :: IO ()
foreign import ccall "SDL.h SDL_UnlockAudioDevice" unlockAudioDeviceFFI :: AudioDeviceID -> IO ()
audioInit :: MonadIO m => CString -> m CInt
audioInit :: forall (m :: Type -> Type). MonadIO m => CString -> m CInt
audioInit CString
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CString -> IO CInt
audioInitFFI CString
v1
{-# INLINE audioInit #-}
audioQuit :: MonadIO m => m ()
audioQuit :: forall (m :: Type -> Type). MonadIO m => m ()
audioQuit = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO ()
audioQuitFFI
{-# INLINE audioQuit #-}
buildAudioCVT :: MonadIO m => Ptr AudioCVT -> AudioFormat -> Word8 -> CInt -> AudioFormat -> Word8 -> CInt -> m CInt
buildAudioCVT :: forall (m :: Type -> Type).
MonadIO m =>
Ptr AudioCVT
-> AudioFormat
-> Word8
-> CInt
-> AudioFormat
-> Word8
-> CInt
-> m CInt
buildAudioCVT Ptr AudioCVT
v1 AudioFormat
v2 Word8
v3 CInt
v4 AudioFormat
v5 Word8
v6 CInt
v7 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr AudioCVT
-> AudioFormat
-> Word8
-> CInt
-> AudioFormat
-> Word8
-> CInt
-> IO CInt
buildAudioCVTFFI Ptr AudioCVT
v1 AudioFormat
v2 Word8
v3 CInt
v4 AudioFormat
v5 Word8
v6 CInt
v7
{-# INLINE buildAudioCVT #-}
clearQueuedAudio :: MonadIO m => AudioDeviceID -> m ()
clearQueuedAudio :: forall (m :: Type -> Type). MonadIO m => AudioDeviceID -> m ()
clearQueuedAudio AudioDeviceID
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ AudioDeviceID -> IO ()
clearQueuedAudioFFI AudioDeviceID
v1
{-# INLINE clearQueuedAudio #-}
closeAudio :: MonadIO m => m ()
closeAudio :: forall (m :: Type -> Type). MonadIO m => m ()
closeAudio = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO ()
closeAudioFFI
{-# INLINE closeAudio #-}
closeAudioDevice :: MonadIO m => AudioDeviceID -> m ()
closeAudioDevice :: forall (m :: Type -> Type). MonadIO m => AudioDeviceID -> m ()
closeAudioDevice AudioDeviceID
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ AudioDeviceID -> IO ()
closeAudioDeviceFFI AudioDeviceID
v1
{-# INLINE closeAudioDevice #-}
convertAudio :: MonadIO m => Ptr AudioCVT -> m CInt
convertAudio :: forall (m :: Type -> Type). MonadIO m => Ptr AudioCVT -> m CInt
convertAudio Ptr AudioCVT
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr AudioCVT -> IO CInt
convertAudioFFI Ptr AudioCVT
v1
{-# INLINE convertAudio #-}
freeWAV :: MonadIO m => Ptr Word8 -> m ()
freeWAV :: forall (m :: Type -> Type). MonadIO m => Ptr Word8 -> m ()
freeWAV Ptr Word8
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr Word8 -> IO ()
freeWAVFFI Ptr Word8
v1
{-# INLINE freeWAV #-}
getAudioDeviceName :: MonadIO m => CInt -> CInt -> m CString
getAudioDeviceName :: forall (m :: Type -> Type). MonadIO m => CInt -> CInt -> m CString
getAudioDeviceName CInt
v1 CInt
v2 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CInt -> CInt -> IO CString
getAudioDeviceNameFFI CInt
v1 CInt
v2
{-# INLINE getAudioDeviceName #-}
getAudioDeviceStatus :: MonadIO m => AudioDeviceID -> m AudioStatus
getAudioDeviceStatus :: forall (m :: Type -> Type).
MonadIO m =>
AudioDeviceID -> m AudioDeviceID
getAudioDeviceStatus AudioDeviceID
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ AudioDeviceID -> IO AudioDeviceID
getAudioDeviceStatusFFI AudioDeviceID
v1
{-# INLINE getAudioDeviceStatus #-}
getAudioDriver :: MonadIO m => CInt -> m CString
getAudioDriver :: forall (m :: Type -> Type). MonadIO m => CInt -> m CString
getAudioDriver CInt
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CInt -> IO CString
getAudioDriverFFI CInt
v1
{-# INLINE getAudioDriver #-}
getAudioStatus :: MonadIO m => m AudioStatus
getAudioStatus :: forall (m :: Type -> Type). MonadIO m => m AudioDeviceID
getAudioStatus = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO AudioDeviceID
getAudioStatusFFI
{-# INLINE getAudioStatus #-}
getCurrentAudioDriver :: MonadIO m => m CString
getCurrentAudioDriver :: forall (m :: Type -> Type). MonadIO m => m CString
getCurrentAudioDriver = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO CString
getCurrentAudioDriverFFI
{-# INLINE getCurrentAudioDriver #-}
getNumAudioDevices :: MonadIO m => CInt -> m CInt
getNumAudioDevices :: forall (m :: Type -> Type). MonadIO m => CInt -> m CInt
getNumAudioDevices CInt
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CInt -> IO CInt
getNumAudioDevicesFFI CInt
v1
{-# INLINE getNumAudioDevices #-}
getNumAudioDrivers :: MonadIO m => m CInt
getNumAudioDrivers :: forall (m :: Type -> Type). MonadIO m => m CInt
getNumAudioDrivers = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO CInt
getNumAudioDriversFFI
{-# INLINE getNumAudioDrivers #-}
getQueuedAudioSize :: MonadIO m => AudioDeviceID -> m Word32
getQueuedAudioSize :: forall (m :: Type -> Type).
MonadIO m =>
AudioDeviceID -> m AudioDeviceID
getQueuedAudioSize AudioDeviceID
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ AudioDeviceID -> IO AudioDeviceID
getQueuedAudioSizeFFI AudioDeviceID
v1
{-# INLINE getQueuedAudioSize #-}
loadWAV :: MonadIO m => CString -> Ptr AudioSpec -> Ptr (Ptr Word8) -> Ptr Word32 -> m (Ptr AudioSpec)
loadWAV :: forall (m :: Type -> Type).
MonadIO m =>
CString
-> Ptr AudioSpec
-> Ptr (Ptr Word8)
-> Ptr AudioDeviceID
-> m (Ptr AudioSpec)
loadWAV CString
file Ptr AudioSpec
spec Ptr (Ptr Word8)
audio_buf Ptr AudioDeviceID
audio_len = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
Ptr RWops
rw <- forall a. String -> (CString -> IO a) -> IO a
withCString String
"rb" forall a b. (a -> b) -> a -> b
$ forall (m :: Type -> Type).
MonadIO m =>
CString -> CString -> m (Ptr RWops)
rwFromFile CString
file
forall (m :: Type -> Type).
MonadIO m =>
Ptr RWops
-> CInt
-> Ptr AudioSpec
-> Ptr (Ptr Word8)
-> Ptr AudioDeviceID
-> m (Ptr AudioSpec)
loadWAV_RW Ptr RWops
rw CInt
1 Ptr AudioSpec
spec Ptr (Ptr Word8)
audio_buf Ptr AudioDeviceID
audio_len
{-# INLINE loadWAV #-}
loadWAV_RW :: MonadIO m => Ptr RWops -> CInt -> Ptr AudioSpec -> Ptr (Ptr Word8) -> Ptr Word32 -> m (Ptr AudioSpec)
loadWAV_RW :: forall (m :: Type -> Type).
MonadIO m =>
Ptr RWops
-> CInt
-> Ptr AudioSpec
-> Ptr (Ptr Word8)
-> Ptr AudioDeviceID
-> m (Ptr AudioSpec)
loadWAV_RW Ptr RWops
v1 CInt
v2 Ptr AudioSpec
v3 Ptr (Ptr Word8)
v4 Ptr AudioDeviceID
v5 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr RWops
-> CInt
-> Ptr AudioSpec
-> Ptr (Ptr Word8)
-> Ptr AudioDeviceID
-> IO (Ptr AudioSpec)
loadWAV_RWFFI Ptr RWops
v1 CInt
v2 Ptr AudioSpec
v3 Ptr (Ptr Word8)
v4 Ptr AudioDeviceID
v5
{-# INLINE loadWAV_RW #-}
lockAudio :: MonadIO m => m ()
lockAudio :: forall (m :: Type -> Type). MonadIO m => m ()
lockAudio = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO ()
lockAudioFFI
{-# INLINE lockAudio #-}
lockAudioDevice :: MonadIO m => AudioDeviceID -> m ()
lockAudioDevice :: forall (m :: Type -> Type). MonadIO m => AudioDeviceID -> m ()
lockAudioDevice AudioDeviceID
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ AudioDeviceID -> IO ()
lockAudioDeviceFFI AudioDeviceID
v1
{-# INLINE lockAudioDevice #-}
mixAudio :: MonadIO m => Ptr Word8 -> Ptr Word8 -> Word32 -> CInt -> m ()
mixAudio :: forall (m :: Type -> Type).
MonadIO m =>
Ptr Word8 -> Ptr Word8 -> AudioDeviceID -> CInt -> m ()
mixAudio Ptr Word8
v1 Ptr Word8
v2 AudioDeviceID
v3 CInt
v4 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr Word8 -> Ptr Word8 -> AudioDeviceID -> CInt -> IO ()
mixAudioFFI Ptr Word8
v1 Ptr Word8
v2 AudioDeviceID
v3 CInt
v4
{-# INLINE mixAudio #-}
mixAudioFormat :: MonadIO m => Ptr Word8 -> Ptr Word8 -> AudioFormat -> Word32 -> CInt -> m ()
mixAudioFormat :: forall (m :: Type -> Type).
MonadIO m =>
Ptr Word8
-> Ptr Word8 -> AudioFormat -> AudioDeviceID -> CInt -> m ()
mixAudioFormat Ptr Word8
v1 Ptr Word8
v2 AudioFormat
v3 AudioDeviceID
v4 CInt
v5 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr Word8
-> Ptr Word8 -> AudioFormat -> AudioDeviceID -> CInt -> IO ()
mixAudioFormatFFI Ptr Word8
v1 Ptr Word8
v2 AudioFormat
v3 AudioDeviceID
v4 CInt
v5
{-# INLINE mixAudioFormat #-}
openAudio :: MonadIO m => Ptr AudioSpec -> Ptr AudioSpec -> m CInt
openAudio :: forall (m :: Type -> Type).
MonadIO m =>
Ptr AudioSpec -> Ptr AudioSpec -> m CInt
openAudio Ptr AudioSpec
v1 Ptr AudioSpec
v2 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Ptr AudioSpec -> Ptr AudioSpec -> IO CInt
openAudioFFI Ptr AudioSpec
v1 Ptr AudioSpec
v2
{-# INLINE openAudio #-}
openAudioDevice :: MonadIO m => CString -> CInt -> Ptr AudioSpec -> Ptr AudioSpec -> CInt -> m AudioDeviceID
openAudioDevice :: forall (m :: Type -> Type).
MonadIO m =>
CString
-> CInt
-> Ptr AudioSpec
-> Ptr AudioSpec
-> CInt
-> m AudioDeviceID
openAudioDevice CString
v1 CInt
v2 Ptr AudioSpec
v3 Ptr AudioSpec
v4 CInt
v5 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CString
-> CInt
-> Ptr AudioSpec
-> Ptr AudioSpec
-> CInt
-> IO AudioDeviceID
openAudioDeviceFFI CString
v1 CInt
v2 Ptr AudioSpec
v3 Ptr AudioSpec
v4 CInt
v5
{-# INLINE openAudioDevice #-}
pauseAudio :: MonadIO m => CInt -> m ()
pauseAudio :: forall (m :: Type -> Type). MonadIO m => CInt -> m ()
pauseAudio CInt
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ CInt -> IO ()
pauseAudioFFI CInt
v1
{-# INLINE pauseAudio #-}
pauseAudioDevice :: MonadIO m => AudioDeviceID -> CInt -> m ()
pauseAudioDevice :: forall (m :: Type -> Type).
MonadIO m =>
AudioDeviceID -> CInt -> m ()
pauseAudioDevice AudioDeviceID
v1 CInt
v2 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ AudioDeviceID -> CInt -> IO ()
pauseAudioDeviceFFI AudioDeviceID
v1 CInt
v2
{-# INLINE pauseAudioDevice #-}
queueAudio :: MonadIO m => AudioDeviceID -> Ptr () -> Word32 -> m CInt
queueAudio :: forall (m :: Type -> Type).
MonadIO m =>
AudioDeviceID -> Ptr () -> AudioDeviceID -> m CInt
queueAudio AudioDeviceID
v1 Ptr ()
v2 AudioDeviceID
v3 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ AudioDeviceID -> Ptr () -> AudioDeviceID -> IO CInt
queueAudioFFI AudioDeviceID
v1 Ptr ()
v2 AudioDeviceID
v3
{-# INLINE queueAudio #-}
unlockAudio :: MonadIO m => m ()
unlockAudio :: forall (m :: Type -> Type). MonadIO m => m ()
unlockAudio = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO IO ()
unlockAudioFFI
{-# INLINE unlockAudio #-}
unlockAudioDevice :: MonadIO m => AudioDeviceID -> m ()
unlockAudioDevice :: forall (m :: Type -> Type). MonadIO m => AudioDeviceID -> m ()
unlockAudioDevice AudioDeviceID
v1 = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ AudioDeviceID -> IO ()
unlockAudioDeviceFFI AudioDeviceID
v1
{-# INLINE unlockAudioDevice #-}