HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

  • Packagesdl2-2.5.6.1
  • Exports21
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceAudio.hs

Managing AudioDevices

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

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.

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

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

Explicit Initialization

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.