HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulesdl2-2.5.5.0Haskell2010

SDL.Audio

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

  • 11 types
  • 10 values
  • Packagesdl2-2.5.5.0
  • Exports21
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceAudio.hs

Managing AudioDevices

1 declaration

Opening and Closing AudioDevices

datadata OpenDeviceSpec
#

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

datadata AudioDeviceUsage
#

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.

Instances9Bounded, Enum, Eq, Data, Ord, Read, …
datadata Channels
#

How many channels audio should be played on

Constructors

Instances9Bounded, Enum, Eq, Data, Ord, Read, …
datadata Changeable a
#

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.

Instances9Functor, Foldable, Traversable, Eq, Data, Read, …

Working with Opened Devices

Locking AudioDevices

datadata LockState
#

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.

Instances9Bounded, Enum, Eq, Data, Ord, Read, …

Switching Playback States

datadata PlaybackState
#

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

Constructors

Instances9Bounded, Enum, Eq, Data, Ord, Read, …

Querying an AudioDevices Status.

datadata AudioDeviceStatus
#

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

Instances9Bounded, Enum, Eq, Data, Ord, Read, …

AudioFormat

datadata AudioFormat sampleType where
#

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.

Instances3Eq, Ord, Show

Enumerating AudioDevices

AudioSpec

1 declaration
datadata 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.

Constructors

Audio Drivers

4 declarations
newtypenewtype AudioDriver
#

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

Instances2Eq, Show

Explicit Initialization

1 declaration
valueaudioInit :: MonadIO m => AudioDriver -> m ()
#

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.