sdl2-2.5.5.1: Both high- and low-level bindings to the SDL library (version 2.0.6+).

Safe Haskell | None
Language | Haskell2010

SDL.Audio

Contents

- Managing `AudioDevice`s
  - Opening and Closing `AudioDevice`s
  - Working with Opened Devices
    - Locking `AudioDevice`s
    - Switching Playback States
    - Querying an `AudioDevice`s Status.
  - `AudioFormat`
  - Enumerating `AudioDevice`s
- `AudioSpec`
- Audio Drivers
- Explicit Initialization

Description

SDL.Audio provides a high-level API to SDL's audio device capabilities.

Synopsis

- data AudioDevice
- openAudioDevice :: MonadIO m => OpenDeviceSpec -> m (AudioDevice, AudioSpec)
- closeAudioDevice :: MonadIO m => AudioDevice -> m ()
- data OpenDeviceSpec = OpenDeviceSpec {
  - openDeviceFreq :: !(Changeable CInt)
  - openDeviceFormat :: !(Changeable (AudioFormat sampleType))
  - openDeviceChannels :: !(Changeable Channels)
  - openDeviceSamples :: !Word16
  - openDeviceCallback :: forall actualSampleType. AudioFormat actualSampleType -> IOVector actualSampleType -> IO ()
  - openDeviceUsage :: !AudioDeviceUsage
  - openDeviceName :: !(Maybe Text)
  }
- data AudioDeviceUsage
  - = ForPlayback
  - | ForCapture
- data Channels
  - = Mono
  - | Stereo
  - | Quad
  - | FivePointOne
- data Changeable a
  - = Mandate !a
  - | Desire !a
- setAudioDeviceLocked :: MonadIO m => AudioDevice -> LockState -> m ()
- data LockState
  - = Locked
  - | Unlocked
- data PlaybackState
  - = Pause
  - | Play
- setAudioDevicePlaybackState :: MonadIO m => AudioDevice -> PlaybackState -> m ()
- data AudioDeviceStatus
  - = Playing
  - | Paused
  - | Stopped
- audioDeviceStatus :: MonadIO m => AudioDevice -> m AudioDeviceStatus
- data AudioFormat sampleType where
  - Signed8BitAudio :: AudioFormat Int8
  - Unsigned8BitAudio :: AudioFormat Word8
  - Signed16BitLEAudio :: AudioFormat Int16
  - Signed16BitBEAudio :: AudioFormat Int16
  - Signed16BitNativeAudio :: AudioFormat Int16
  - Unsigned16BitLEAudio :: AudioFormat Word16
  - Unsigned16BitBEAudio :: AudioFormat Word16
  - Unsigned16BitNativeAudio :: AudioFormat Word16
  - Signed32BitLEAudio :: AudioFormat Int32
  - Signed32BitBEAudio :: AudioFormat Int32
  - Signed32BitNativeAudio :: AudioFormat Int32
  - FloatingLEAudio :: AudioFormat Float
  - FloatingBEAudio :: AudioFormat Float
  - FloatingNativeAudio :: AudioFormat Float
- getAudioDeviceNames :: MonadIO m => AudioDeviceUsage -> m (Maybe (Vector Text))
- data AudioSpec = AudioSpec {
  - audioSpecFreq :: !CInt
  - audioSpecFormat :: !(AudioFormat sampleType)
  - audioSpecChannels :: !Channels
  - audioSpecSilence :: !Word8
  - audioSpecSamples :: !Word16
  - audioSpecSize :: !Word32
  - audioSpecCallback :: AudioFormat sampleType -> IOVector sampleType -> IO ()
  }
- getAudioDrivers :: MonadIO m => m (Vector AudioDriver)
- currentAudioDriver :: MonadIO m => m (Maybe Text)
- data AudioDriver
- audioDriverName :: AudioDriver -> Text
- audioInit :: MonadIO m => AudioDriver -> m ()

# Managing `AudioDevice`s

data AudioDevice Source #

An open audio device. These can be created via `openAudioDevice` and should be closed with `closeAudioDevice`

#### Instances

Instances details

Eq AudioDevice Source # |
Instance details Defined in SDL.Audio Methods (==) :: AudioDevice -> AudioDevice -> Bool Source # (/=) :: AudioDevice -> AudioDevice -> Bool Source #

## Opening and Closing `AudioDevice`s

openAudioDevice :: MonadIO m => OpenDeviceSpec -> m (AudioDevice, AudioSpec) Source #

Attempt to open the closest matching `AudioDevice`, as specified by the given `OpenDeviceSpec`.

See `SDL_OpenAudioDevice` for C documentation.

closeAudioDevice :: MonadIO m => AudioDevice -> m () Source #

See `SDL_CloseAudioDevice` for C documentation.

data OpenDeviceSpec Source #

A specification to `openAudioDevice`, indicating the desired output format. Note that many of these properties are `Changeable`, meaning that you can choose whether or not SDL should interpret your specification as an unbreakable request (`Mandate`), or as an approximation `Desire`.

Constructors

OpenDeviceSpec |

Fields

- openDeviceFreq :: !(Changeable CInt)

  The output audio frequency in herts.

- openDeviceFormat :: !(Changeable (AudioFormat sampleType))

  The format of audio that will be sampled from the output buffer.

- openDeviceChannels :: !(Changeable Channels)

  The amount of audio channels.

- openDeviceSamples :: !Word16

  Output audio buffer size in samples. This should be a power of 2.

- openDeviceCallback :: forall actualSampleType. AudioFormat actualSampleType -> IOVector actualSampleType -> IO ()

  A callback to invoke whenever new sample data is required. The callback will be passed a single `MVector` that must be filled with audio data.

- openDeviceUsage :: !AudioDeviceUsage

  How you intend to use the opened `AudioDevice` - either for outputting or capturing audio.

- openDeviceName :: !(Maybe Text)

  The name of the `AudioDevice` that should be opened. If `Nothing`, any suitable `AudioDevice` will be used.

data AudioDeviceUsage Source #

How you intend to use an `AudioDevice`

Constructors

ForPlayback | The device will be used for sample playback.
ForCapture | The device will be used for sample capture.

#### Instances

Instances details

Data AudioDeviceUsage Source # |

Instance details

Defined in SDL.Audio

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AudioDeviceUsage -> c AudioDeviceUsage Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AudioDeviceUsage Source #

toConstr :: AudioDeviceUsage -> Constr Source #

dataTypeOf :: AudioDeviceUsage -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AudioDeviceUsage) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AudioDeviceUsage) Source #

gmapT :: (forall b. Data b => b -> b) -> AudioDeviceUsage -> AudioDeviceUsage Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AudioDeviceUsage -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AudioDeviceUsage -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> AudioDeviceUsage -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AudioDeviceUsage -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AudioDeviceUsage -> m AudioDeviceUsage Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AudioDeviceUsage -> m AudioDeviceUsage Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AudioDeviceUsage -> m AudioDeviceUsage Source #

Bounded AudioDeviceUsage Source # |
Instance details Defined in SDL.Audio Methods minBound :: AudioDeviceUsage Source # maxBound :: AudioDeviceUsage Source #
Enum AudioDeviceUsage Source # |

Instance details

Defined in SDL.Audio

Methods

succ :: AudioDeviceUsage -> AudioDeviceUsage Source #

pred :: AudioDeviceUsage -> AudioDeviceUsage Source #

toEnum :: Int -> AudioDeviceUsage Source #

fromEnum :: AudioDeviceUsage -> Int Source #

enumFrom :: AudioDeviceUsage -> [AudioDeviceUsage] Source #

enumFromThen :: AudioDeviceUsage -> AudioDeviceUsage -> [AudioDeviceUsage] Source #

enumFromTo :: AudioDeviceUsage -> AudioDeviceUsage -> [AudioDeviceUsage] Source #

enumFromThenTo :: AudioDeviceUsage -> AudioDeviceUsage -> AudioDeviceUsage -> [AudioDeviceUsage] Source #

Generic AudioDeviceUsage Source # |

Instance details

Defined in SDL.Audio

Associated Types

type Rep AudioDeviceUsage |
Instance details Defined in SDL.Audio type Rep AudioDeviceUsage = D1 ('MetaData "AudioDeviceUsage" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "ForPlayback" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ForCapture" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: AudioDeviceUsage -> Rep AudioDeviceUsage x Source #

to :: Rep AudioDeviceUsage x -> AudioDeviceUsage Source #

Read AudioDeviceUsage Source # |
Instance details Defined in SDL.Audio Methods readsPrec :: Int -> ReadS AudioDeviceUsage Source # readList :: ReadS [AudioDeviceUsage] Source # readPrec :: ReadPrec AudioDeviceUsage Source # readListPrec :: ReadPrec [AudioDeviceUsage] Source #
Show AudioDeviceUsage Source # |
Instance details Defined in SDL.Audio Methods showsPrec :: Int -> AudioDeviceUsage -> ShowS Source # show :: AudioDeviceUsage -> String Source # showList :: [AudioDeviceUsage] -> ShowS Source #
Eq AudioDeviceUsage Source # |
Instance details Defined in SDL.Audio Methods (==) :: AudioDeviceUsage -> AudioDeviceUsage -> Bool Source # (/=) :: AudioDeviceUsage -> AudioDeviceUsage -> Bool Source #
Ord AudioDeviceUsage Source # |

Instance details

Defined in SDL.Audio

Methods

compare :: AudioDeviceUsage -> AudioDeviceUsage -> Ordering Source #

(<) :: AudioDeviceUsage -> AudioDeviceUsage -> Bool Source #

(<=) :: AudioDeviceUsage -> AudioDeviceUsage -> Bool Source #

(>) :: AudioDeviceUsage -> AudioDeviceUsage -> Bool Source #

(>=) :: AudioDeviceUsage -> AudioDeviceUsage -> Bool Source #

max :: AudioDeviceUsage -> AudioDeviceUsage -> AudioDeviceUsage Source #

min :: AudioDeviceUsage -> AudioDeviceUsage -> AudioDeviceUsage Source #

type Rep AudioDeviceUsage Source # |
Instance details Defined in SDL.Audio type Rep AudioDeviceUsage = D1 ('MetaData "AudioDeviceUsage" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "ForPlayback" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ForCapture" 'PrefixI 'False) (U1 :: Type -> Type))

data Channels Source #

How many channels audio should be played on

Constructors

Mono | A single speaker configuration
Stereo | A traditional left/right stereo system
Quad |

FivePointOne

1. 1 surround sound

#### Instances

Instances details

Data Channels Source # |

Instance details

Defined in SDL.Audio

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Channels -> c Channels Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Channels Source #

toConstr :: Channels -> Constr Source #

dataTypeOf :: Channels -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Channels) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Channels) Source #

gmapT :: (forall b. Data b => b -> b) -> Channels -> Channels Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Channels -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Channels -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Channels -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Channels -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Channels -> m Channels Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Channels -> m Channels Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Channels -> m Channels Source #

Bounded Channels Source # |
Instance details Defined in SDL.Audio Methods minBound :: Channels Source # maxBound :: Channels Source #
Enum Channels Source # |

Instance details

Defined in SDL.Audio

Methods

succ :: Channels -> Channels Source #

pred :: Channels -> Channels Source #

toEnum :: Int -> Channels Source #

fromEnum :: Channels -> Int Source #

enumFrom :: Channels -> [Channels] Source #

enumFromThen :: Channels -> Channels -> [Channels] Source #

enumFromTo :: Channels -> Channels -> [Channels] Source #

enumFromThenTo :: Channels -> Channels -> Channels -> [Channels] Source #

Generic Channels Source # |

Instance details

Defined in SDL.Audio

Associated Types

type Rep Channels |

Instance details

Defined in SDL.Audio

type Rep Channels = D1 ('MetaData "Channels" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) ((C1 ('MetaCons "Mono" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Stereo" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Quad" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FivePointOne" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: Channels -> Rep Channels x Source #

to :: Rep Channels x -> Channels Source #

Read Channels Source # |
Instance details Defined in SDL.Audio Methods readsPrec :: Int -> ReadS Channels Source # readList :: ReadS [Channels] Source # readPrec :: ReadPrec Channels Source # readListPrec :: ReadPrec [Channels] Source #
Show Channels Source # |
Instance details Defined in SDL.Audio Methods showsPrec :: Int -> Channels -> ShowS Source # show :: Channels -> String Source # showList :: [Channels] -> ShowS Source #
Eq Channels Source # |
Instance details Defined in SDL.Audio Methods (==) :: Channels -> Channels -> Bool Source # (/=) :: Channels -> Channels -> Bool Source #
Ord Channels Source # |
Instance details Defined in SDL.Audio Methods compare :: Channels -> Channels -> Ordering Source # (<) :: Channels -> Channels -> Bool Source # (<=) :: Channels -> Channels -> Bool Source # (>) :: Channels -> Channels -> Bool Source # (>=) :: Channels -> Channels -> Bool Source # max :: Channels -> Channels -> Channels Source # min :: Channels -> Channels -> Channels Source #
type Rep Channels Source # |

Instance details

Defined in SDL.Audio

type Rep Channels = D1 ('MetaData "Channels" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) ((C1 ('MetaCons "Mono" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Stereo" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Quad" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FivePointOne" 'PrefixI 'False) (U1 :: Type -> Type)))

data Changeable a Source #

Used to indicate to SDL whether it is allowed to open other audio devices (if a property is marked as a `Desire`) or if it should fail if the device is unavailable (`Mandate`).

Constructors

Mandate !a | `Mandate` this exact property value, and fail if a matching audio device cannot be found.
Desire !a | `Desire` this property value, but allow other audio devices to be opened.

#### Instances

Instances details

Functor Changeable Source # |
Instance details Defined in SDL.Audio Methods fmap :: (a -> b) -> Changeable a -> Changeable b Source # (<$) :: a -> Changeable b -> Changeable a Source #
Foldable Changeable Source # |

Instance details

Defined in SDL.Audio

Methods

fold :: Monoid m => Changeable m -> m Source #

foldMap :: Monoid m => (a -> m) -> Changeable a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Changeable a -> m Source #

foldr :: (a -> b -> b) -> b -> Changeable a -> b Source #

foldr' :: (a -> b -> b) -> b -> Changeable a -> b Source #

foldl :: (b -> a -> b) -> b -> Changeable a -> b Source #

foldl' :: (b -> a -> b) -> b -> Changeable a -> b Source #

foldr1 :: (a -> a -> a) -> Changeable a -> a Source #

foldl1 :: (a -> a -> a) -> Changeable a -> a Source #

toList :: Changeable a -> [a] Source #

null :: Changeable a -> Bool Source #

length :: Changeable a -> Int Source #

elem :: Eq a => a -> Changeable a -> Bool Source #

maximum :: Ord a => Changeable a -> a Source #

minimum :: Ord a => Changeable a -> a Source #

sum :: Num a => Changeable a -> a Source #

product :: Num a => Changeable a -> a Source #

Traversable Changeable Source # |
Instance details Defined in SDL.Audio Methods traverse :: Applicative f => (a -> f b) -> Changeable a -> f (Changeable b) Source # sequenceA :: Applicative f => Changeable (f a) -> f (Changeable a) Source # mapM :: Monad m => (a -> m b) -> Changeable a -> m (Changeable b) Source # sequence :: Monad m => Changeable (m a) -> m (Changeable a) Source #
Data a => Data (Changeable a) Source # |

Instance details

Defined in SDL.Audio

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Changeable a -> c (Changeable a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Changeable a) Source #

toConstr :: Changeable a -> Constr Source #

dataTypeOf :: Changeable a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Changeable a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Changeable a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Changeable a -> Changeable a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Changeable a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Changeable a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Changeable a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Changeable a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Changeable a -> m (Changeable a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Changeable a -> m (Changeable a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Changeable a -> m (Changeable a) Source #

Generic (Changeable a) Source # |

Instance details

Defined in SDL.Audio

Associated Types

type Rep (Changeable a) |

Instance details

Defined in SDL.Audio

type Rep (Changeable a) = D1 ('MetaData "Changeable" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "Mandate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "Desire" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))

Methods

from :: Changeable a -> Rep (Changeable a) x Source #

to :: Rep (Changeable a) x -> Changeable a Source #

Read a => Read (Changeable a) Source # |
Instance details Defined in SDL.Audio Methods readsPrec :: Int -> ReadS (Changeable a) Source # readList :: ReadS [Changeable a] Source # readPrec :: ReadPrec (Changeable a) Source # readListPrec :: ReadPrec [Changeable a] Source #
Show a => Show (Changeable a) Source # |
Instance details Defined in SDL.Audio Methods showsPrec :: Int -> Changeable a -> ShowS Source # show :: Changeable a -> String Source # showList :: [Changeable a] -> ShowS Source #
Eq a => Eq (Changeable a) Source # |
Instance details Defined in SDL.Audio Methods (==) :: Changeable a -> Changeable a -> Bool Source # (/=) :: Changeable a -> Changeable a -> Bool Source #
type Rep (Changeable a) Source # |

Instance details

Defined in SDL.Audio

type Rep (Changeable a) = D1 ('MetaData "Changeable" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "Mandate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "Desire" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))

## Working with Opened Devices

### Locking `AudioDevice`s

setAudioDeviceLocked :: MonadIO m => AudioDevice -> LockState -> m () Source #

Lock an `AudioDevice` such that its associated callback will not be called until the device is unlocked.

data LockState Source #

Whether a device should be locked or unlocked.

Constructors

Locked | Lock the device, preventing the callback from producing data.
Unlocked | Unlock the device, resuming calls to the callback.

#### Instances

Instances details

Data LockState Source # |

Instance details

Defined in SDL.Audio

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LockState -> c LockState Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c LockState Source #

toConstr :: LockState -> Constr Source #

dataTypeOf :: LockState -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c LockState) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LockState) Source #

gmapT :: (forall b. Data b => b -> b) -> LockState -> LockState Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LockState -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LockState -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> LockState -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> LockState -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> LockState -> m LockState Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LockState -> m LockState Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LockState -> m LockState Source #

Bounded LockState Source # |
Instance details Defined in SDL.Audio Methods minBound :: LockState Source # maxBound :: LockState Source #
Enum LockState Source # |

Instance details

Defined in SDL.Audio

Methods

succ :: LockState -> LockState Source #

pred :: LockState -> LockState Source #

toEnum :: Int -> LockState Source #

fromEnum :: LockState -> Int Source #

enumFrom :: LockState -> [LockState] Source #

enumFromThen :: LockState -> LockState -> [LockState] Source #

enumFromTo :: LockState -> LockState -> [LockState] Source #

enumFromThenTo :: LockState -> LockState -> LockState -> [LockState] Source #

Generic LockState Source # |

Instance details

Defined in SDL.Audio

Associated Types

type Rep LockState |
Instance details Defined in SDL.Audio type Rep LockState = D1 ('MetaData "LockState" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "Locked" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Unlocked" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: LockState -> Rep LockState x Source #

to :: Rep LockState x -> LockState Source #

Read LockState Source # |
Instance details Defined in SDL.Audio Methods readsPrec :: Int -> ReadS LockState Source # readList :: ReadS [LockState] Source # readPrec :: ReadPrec LockState Source # readListPrec :: ReadPrec [LockState] Source #
Show LockState Source # |
Instance details Defined in SDL.Audio Methods showsPrec :: Int -> LockState -> ShowS Source # show :: LockState -> String Source # showList :: [LockState] -> ShowS Source #
Eq LockState Source # |
Instance details Defined in SDL.Audio Methods (==) :: LockState -> LockState -> Bool Source # (/=) :: LockState -> LockState -> Bool Source #
Ord LockState Source # |
Instance details Defined in SDL.Audio Methods compare :: LockState -> LockState -> Ordering Source # (<) :: LockState -> LockState -> Bool Source # (<=) :: LockState -> LockState -> Bool Source # (>) :: LockState -> LockState -> Bool Source # (>=) :: LockState -> LockState -> Bool Source # max :: LockState -> LockState -> LockState Source # min :: LockState -> LockState -> LockState Source #
type Rep LockState Source # |
Instance details Defined in SDL.Audio type Rep LockState = D1 ('MetaData "LockState" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "Locked" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Unlocked" 'PrefixI 'False) (U1 :: Type -> Type))

### Switching Playback States

data PlaybackState Source #

Whether to allow an `AudioDevice` to play sound or remain paused.

Constructors

Pause | Pause the `AudioDevice`, which will stop producing/capturing audio.
Play | Resume the `AudioDevice`.

#### Instances

Instances details

Data PlaybackState Source # |

Instance details

Defined in SDL.Audio

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PlaybackState -> c PlaybackState Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PlaybackState Source #

toConstr :: PlaybackState -> Constr Source #

dataTypeOf :: PlaybackState -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PlaybackState) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PlaybackState) Source #

gmapT :: (forall b. Data b => b -> b) -> PlaybackState -> PlaybackState Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PlaybackState -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PlaybackState -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> PlaybackState -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> PlaybackState -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> PlaybackState -> m PlaybackState Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PlaybackState -> m PlaybackState Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PlaybackState -> m PlaybackState Source #

Bounded PlaybackState Source # |
Instance details Defined in SDL.Audio Methods minBound :: PlaybackState Source # maxBound :: PlaybackState Source #
Enum PlaybackState Source # |

Instance details

Defined in SDL.Audio

Methods

succ :: PlaybackState -> PlaybackState Source #

pred :: PlaybackState -> PlaybackState Source #

toEnum :: Int -> PlaybackState Source #

fromEnum :: PlaybackState -> Int Source #

enumFrom :: PlaybackState -> [PlaybackState] Source #

enumFromThen :: PlaybackState -> PlaybackState -> [PlaybackState] Source #

enumFromTo :: PlaybackState -> PlaybackState -> [PlaybackState] Source #

enumFromThenTo :: PlaybackState -> PlaybackState -> PlaybackState -> [PlaybackState] Source #

Generic PlaybackState Source # |

Instance details

Defined in SDL.Audio

Associated Types

type Rep PlaybackState |
Instance details Defined in SDL.Audio type Rep PlaybackState = D1 ('MetaData "PlaybackState" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "Pause" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Play" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: PlaybackState -> Rep PlaybackState x Source #

to :: Rep PlaybackState x -> PlaybackState Source #

Read PlaybackState Source # |
Instance details Defined in SDL.Audio Methods readsPrec :: Int -> ReadS PlaybackState Source # readList :: ReadS [PlaybackState] Source # readPrec :: ReadPrec PlaybackState Source # readListPrec :: ReadPrec [PlaybackState] Source #
Show PlaybackState Source # |
Instance details Defined in SDL.Audio Methods showsPrec :: Int -> PlaybackState -> ShowS Source # show :: PlaybackState -> String Source # showList :: [PlaybackState] -> ShowS Source #
Eq PlaybackState Source # |
Instance details Defined in SDL.Audio Methods (==) :: PlaybackState -> PlaybackState -> Bool Source # (/=) :: PlaybackState -> PlaybackState -> Bool Source #
Ord PlaybackState Source # |

Instance details

Defined in SDL.Audio

Methods

compare :: PlaybackState -> PlaybackState -> Ordering Source #

(<) :: PlaybackState -> PlaybackState -> Bool Source #

(<=) :: PlaybackState -> PlaybackState -> Bool Source #

(>) :: PlaybackState -> PlaybackState -> Bool Source #

(>=) :: PlaybackState -> PlaybackState -> Bool Source #

max :: PlaybackState -> PlaybackState -> PlaybackState Source #

min :: PlaybackState -> PlaybackState -> PlaybackState Source #

type Rep PlaybackState Source # |
Instance details Defined in SDL.Audio type Rep PlaybackState = D1 ('MetaData "PlaybackState" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "Pause" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Play" 'PrefixI 'False) (U1 :: Type -> Type))

setAudioDevicePlaybackState :: MonadIO m => AudioDevice -> PlaybackState -> m () Source #

Change the playback state of an `AudioDevice`.

### Querying an `AudioDevice`s Status.

data AudioDeviceStatus Source #

Opened devices are always `Playing` or `Paused` in normal circumstances. A failing device may change its status to `Stopped` at any time, and closing a device will progress to `Stopped` too.

Constructors

Playing | The `AudioDevice` is playing.
Paused | The `AudioDevice` is paused.
Stopped | The `AudioDevice` is stopped.

#### Instances

Instances details

Data AudioDeviceStatus Source # |

Instance details

Defined in SDL.Audio

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AudioDeviceStatus -> c AudioDeviceStatus Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AudioDeviceStatus Source #

toConstr :: AudioDeviceStatus -> Constr Source #

dataTypeOf :: AudioDeviceStatus -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AudioDeviceStatus) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AudioDeviceStatus) Source #

gmapT :: (forall b. Data b => b -> b) -> AudioDeviceStatus -> AudioDeviceStatus Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AudioDeviceStatus -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AudioDeviceStatus -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> AudioDeviceStatus -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AudioDeviceStatus -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AudioDeviceStatus -> m AudioDeviceStatus Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AudioDeviceStatus -> m AudioDeviceStatus Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AudioDeviceStatus -> m AudioDeviceStatus Source #

Bounded AudioDeviceStatus Source # |
Instance details Defined in SDL.Audio Methods minBound :: AudioDeviceStatus Source # maxBound :: AudioDeviceStatus Source #
Enum AudioDeviceStatus Source # |

Instance details

Defined in SDL.Audio

Methods

succ :: AudioDeviceStatus -> AudioDeviceStatus Source #

pred :: AudioDeviceStatus -> AudioDeviceStatus Source #

toEnum :: Int -> AudioDeviceStatus Source #

fromEnum :: AudioDeviceStatus -> Int Source #

enumFrom :: AudioDeviceStatus -> [AudioDeviceStatus] Source #

enumFromThen :: AudioDeviceStatus -> AudioDeviceStatus -> [AudioDeviceStatus] Source #

enumFromTo :: AudioDeviceStatus -> AudioDeviceStatus -> [AudioDeviceStatus] Source #

enumFromThenTo :: AudioDeviceStatus -> AudioDeviceStatus -> AudioDeviceStatus -> [AudioDeviceStatus] Source #

Generic AudioDeviceStatus Source # |

Instance details

Defined in SDL.Audio

Associated Types

type Rep AudioDeviceStatus |
Instance details Defined in SDL.Audio type Rep AudioDeviceStatus = D1 ('MetaData "AudioDeviceStatus" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "Playing" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Paused" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Stopped" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: AudioDeviceStatus -> Rep AudioDeviceStatus x Source #

to :: Rep AudioDeviceStatus x -> AudioDeviceStatus Source #

Read AudioDeviceStatus Source # |
Instance details Defined in SDL.Audio Methods readsPrec :: Int -> ReadS AudioDeviceStatus Source # readList :: ReadS [AudioDeviceStatus] Source # readPrec :: ReadPrec AudioDeviceStatus Source # readListPrec :: ReadPrec [AudioDeviceStatus] Source #
Show AudioDeviceStatus Source # |
Instance details Defined in SDL.Audio Methods showsPrec :: Int -> AudioDeviceStatus -> ShowS Source # show :: AudioDeviceStatus -> String Source # showList :: [AudioDeviceStatus] -> ShowS Source #
Eq AudioDeviceStatus Source # |
Instance details Defined in SDL.Audio Methods (==) :: AudioDeviceStatus -> AudioDeviceStatus -> Bool Source # (/=) :: AudioDeviceStatus -> AudioDeviceStatus -> Bool Source #
Ord AudioDeviceStatus Source # |

Instance details

Defined in SDL.Audio

Methods

compare :: AudioDeviceStatus -> AudioDeviceStatus -> Ordering Source #

(<) :: AudioDeviceStatus -> AudioDeviceStatus -> Bool Source #

(<=) :: AudioDeviceStatus -> AudioDeviceStatus -> Bool Source #

(>) :: AudioDeviceStatus -> AudioDeviceStatus -> Bool Source #

(>=) :: AudioDeviceStatus -> AudioDeviceStatus -> Bool Source #

max :: AudioDeviceStatus -> AudioDeviceStatus -> AudioDeviceStatus Source #

min :: AudioDeviceStatus -> AudioDeviceStatus -> AudioDeviceStatus Source #

type Rep AudioDeviceStatus Source # |
Instance details Defined in SDL.Audio type Rep AudioDeviceStatus = D1 ('MetaData "AudioDeviceStatus" "SDL.Audio" "sdl2-2.5.5.1-AgF6e4ywebPJjPO67cQCnV" 'False) (C1 ('MetaCons "Playing" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Paused" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Stopped" 'PrefixI 'False) (U1 :: Type -> Type)))

audioDeviceStatus :: MonadIO m => AudioDevice -> m AudioDeviceStatus Source #

Query the state of an `AudioDevice`.

## `AudioFormat`

data AudioFormat sampleType where Source #

Information about what format an audio bytestream is. The type variable `t` indicates the type used for audio buffer samples. It is determined by the choice of the provided `SampleBitSize`. For example:

    AudioFormat UnsignedInteger Sample8Bit Native :: AudioFormat Word8

Indicating that an 8-bit audio format in the platforms native endianness uses a buffer of `Word8` values.

Constructors

Signed8BitAudio :: AudioFormat Int8 |
Unsigned8BitAudio :: AudioFormat Word8 |
Signed16BitLEAudio :: AudioFormat Int16 |
Signed16BitBEAudio :: AudioFormat Int16 |
Signed16BitNativeAudio :: AudioFormat Int16 |
Unsigned16BitLEAudio :: AudioFormat Word16 |
Unsigned16BitBEAudio :: AudioFormat Word16 |
Unsigned16BitNativeAudio :: AudioFormat Word16 |
Signed32BitLEAudio :: AudioFormat Int32 |
Signed32BitBEAudio :: AudioFormat Int32 |
Signed32BitNativeAudio :: AudioFormat Int32 |
FloatingLEAudio :: AudioFormat Float |
FloatingBEAudio :: AudioFormat Float |
FloatingNativeAudio :: AudioFormat Float |

#### Instances

Instances details

Show (AudioFormat sampleType) Source # |
Instance details Defined in SDL.Audio Methods showsPrec :: Int -> AudioFormat sampleType -> ShowS Source # show :: AudioFormat sampleType -> String Source # showList :: [AudioFormat sampleType] -> ShowS Source #
Eq (AudioFormat sampleType) Source # |
Instance details Defined in SDL.Audio Methods (==) :: AudioFormat sampleType -> AudioFormat sampleType -> Bool Source # (/=) :: AudioFormat sampleType -> AudioFormat sampleType -> Bool Source #
Ord (AudioFormat sampleType) Source # |

Instance details

Defined in SDL.Audio

Methods

compare :: AudioFormat sampleType -> AudioFormat sampleType -> Ordering Source #

(<) :: AudioFormat sampleType -> AudioFormat sampleType -> Bool Source #

(<=) :: AudioFormat sampleType -> AudioFormat sampleType -> Bool Source #

(>) :: AudioFormat sampleType -> AudioFormat sampleType -> Bool Source #

(>=) :: AudioFormat sampleType -> AudioFormat sampleType -> Bool Source #

max :: AudioFormat sampleType -> AudioFormat sampleType -> AudioFormat sampleType Source #

min :: AudioFormat sampleType -> AudioFormat sampleType -> AudioFormat sampleType Source #

## Enumerating `AudioDevice`s

getAudioDeviceNames :: MonadIO m => AudioDeviceUsage -> m (Maybe (Vector Text)) Source #

Enumerate all `AudioDevice`s attached to this system, that can be used as specified by the given `AudioDeviceUsage`. SDL cannot always guarantee that this list can be produced, in which case `Nothing` will be returned.

# `AudioSpec`

data AudioSpec Source #

`AudioSpec` is the concrete specification of how an `AudioDevice` was sucessfully opened. Unlike `OpenDeviceSpec`, which specifies what you want, `AudioSpec` specifies what you have.

Constructors

AudioSpec |

Fields

- audioSpecFreq :: !CInt

  DSP frequency (samples per second)

- audioSpecFormat :: !(AudioFormat sampleType)

  Audio data format

- audioSpecChannels :: !Channels

  Number of separate sound channels

- audioSpecSilence :: !Word8

  Calculated udio buffer silence value

- audioSpecSamples :: !Word16

  Audio buffer size in samples (power of 2)

- audioSpecSize :: !Word32

  Calculated audio buffer size in bytes

- audioSpecCallback :: AudioFormat sampleType -> IOVector sampleType -> IO ()

  The function to call when the audio device needs more data

# Audio Drivers

getAudioDrivers :: MonadIO m => m (Vector AudioDriver) Source #

Obtain a list of all possible audio drivers for this system. These drivers can be used to specificially initialize the audio system.

currentAudioDriver :: MonadIO m => m (Maybe Text) Source #

Query SDL for the name of the currently initialized audio driver, if possible. This will return `Nothing` if no driver has been initialized.

data AudioDriver Source #

An abstract description of an audio driver on the host machine.

#### Instances

Instances details

Show AudioDriver Source # |
Instance details Defined in SDL.Audio Methods showsPrec :: Int -> AudioDriver -> ShowS Source # show :: AudioDriver -> String Source # showList :: [AudioDriver] -> ShowS Source #
Eq AudioDriver Source # |
Instance details Defined in SDL.Audio Methods (==) :: AudioDriver -> AudioDriver -> Bool Source # (/=) :: AudioDriver -> AudioDriver -> Bool Source #

audioDriverName :: AudioDriver -> Text Source #

Get the human readable name of an `AudioDriver`

# Explicit Initialization

audioInit :: MonadIO m => AudioDriver -> m () Source #

Explicitly initialize the audio system against a specific `AudioDriver`. Note that most users will not need to do this, as the normal initialization routines will already take care of this for you.