Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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 = forall sampleType.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
- data Channels
- = Mono
- | Stereo
- | Quad
- | FivePointOne
- data Changeable a
- setAudioDeviceLocked :: MonadIO m => AudioDevice -> LockState -> m ()
- data LockState
- data PlaybackState
- setAudioDevicePlaybackState :: MonadIO m => AudioDevice -> PlaybackState -> m ()
- data AudioDeviceStatus
- 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 = forall sampleType.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
Eq AudioDevice Source # | |
Defined in SDL.Audio (==) :: 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
.
forall sampleType. OpenDeviceSpec | |
|
data AudioDeviceUsage Source #
How you intend to use an AudioDevice
ForPlayback | The device will be used for sample playback. |
ForCapture | The device will be used for sample capture. |
Instances
How many channels audio should be played on
Mono | A single speaker configuration |
Stereo | A traditional left/right stereo system |
Quad | |
FivePointOne |
|
Instances
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
).
Mandate !a |
|
Desire !a |
|
Instances
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.
Whether a device should be locked or unlocked.
Locked | Lock the device, preventing the callback from producing data. |
Unlocked | Unlock the device, resuming calls to the callback. |
Instances
Switching Playback States
data PlaybackState Source #
Whether to allow an AudioDevice
to play sound or remain paused.
Pause | Pause the |
Play | Resume the |
Instances
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.
Playing | The |
Paused | The |
Stopped | The |
Instances
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.
Instances
Show (AudioFormat sampleType) Source # | |
Eq (AudioFormat sampleType) Source # | |
Defined in SDL.Audio (==) :: AudioFormat sampleType -> AudioFormat sampleType -> Bool Source # (/=) :: AudioFormat sampleType -> AudioFormat sampleType -> Bool Source # | |
Ord (AudioFormat sampleType) Source # | |
Defined in SDL.Audio 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
AudioSpec
is the concrete specification of how an AudioDevice
was
sucessfully opened. Unlike OpenDeviceSpec
, which specifies what you
want, AudioSpec
specifies what you have.
forall sampleType. AudioSpec | |
|
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
Show AudioDriver Source # | |
Eq AudioDriver Source # | |
Defined in SDL.Audio (==) :: 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.