An open audio device. These can be created via openAudioDevice and should be closed with closeAudioDevice
Instances1Eq
Eq AudioDeviceDefined in sdl2-2.5.5.0 · SDL.Audio
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulesdl2-2.5.5.0Haskell2010
SDL.Audio provides a high-level API to SDL's audio device capabilities.
An open audio device. These can be created via openAudioDevice and should be closed with closeAudioDevice
Eq AudioDeviceDefined in sdl2-2.5.5.0 · SDL.AudioAttempt to open the closest matching AudioDevice, as specified by the given OpenDeviceSpec.
See SDL_OpenAudioDevice for C documentation.
See SDL_CloseAudioDevice for C documentation.
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. OpenDeviceSpecopenDeviceFreq :: !Changeable CIntThe output audio frequency in herts.
openDeviceFormat :: !Changeable (AudioFormat sampleType)The format of audio that will be sampled from the output buffer.
openDeviceChannels :: !Changeable ChannelsThe amount of audio channels.
openDeviceSamples :: !Word16Output 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 :: !AudioDeviceUsageHow you intend to use the opened AudioDevice - either for outputting or capturing audio.
openDeviceName :: !Maybe TextThe name of the AudioDevice that should be opened. If Nothing, any suitable AudioDevice will be used.
How you intend to use an AudioDevice
ForPlaybackThe device will be used for sample playback.
ForCaptureThe device will be used for sample capture.
Bounded AudioDeviceUsageDefined in sdl2-2.5.5.0 · SDL.AudioEnum AudioDeviceUsageDefined in sdl2-2.5.5.0 · SDL.AudioEq AudioDeviceUsageDefined in sdl2-2.5.5.0 · SDL.AudioData AudioDeviceUsageDefined in sdl2-2.5.5.0 · SDL.AudioOrd AudioDeviceUsageDefined in sdl2-2.5.5.0 · SDL.AudioRead AudioDeviceUsageDefined in sdl2-2.5.5.0 · SDL.AudioShow AudioDeviceUsageDefined in sdl2-2.5.5.0 · SDL.AudioGeneric AudioDeviceUsageDefined in sdl2-2.5.5.0 · SDL.Audiotype Rep AudioDeviceUsage = D1 ('MetaData "AudioDeviceUsage"
"SDL.Audio"
"sdl2-2.5.5.0-3sH3mgPhw4837qWuaPOiH"
'False) (C1 ('MetaCons "ForPlayback"
'PrefixI 'False) U1 :+: C1 ('MetaCons "ForCapture"
'PrefixI 'False) U1)Defined in sdl2-2.5.5.0 · SDL.AudioHow many channels audio should be played on
MonoA single speaker configuration
StereoA traditional left/right stereo system
QuadFivePointOne1 surround sound
Bounded ChannelsDefined in sdl2-2.5.5.0 · SDL.AudioEnum ChannelsDefined in sdl2-2.5.5.0 · SDL.AudioEq ChannelsDefined in sdl2-2.5.5.0 · SDL.AudioData ChannelsDefined in sdl2-2.5.5.0 · SDL.AudioOrd ChannelsDefined in sdl2-2.5.5.0 · SDL.AudioRead ChannelsDefined in sdl2-2.5.5.0 · SDL.AudioShow ChannelsDefined in sdl2-2.5.5.0 · SDL.AudioGeneric ChannelsDefined in sdl2-2.5.5.0 · SDL.Audiotype Rep Channels = D1 ('MetaData "Channels"
"SDL.Audio"
"sdl2-2.5.5.0-3sH3mgPhw4837qWuaPOiH"
'False) ((C1 ('MetaCons "Mono"
'PrefixI 'False) U1 :+: C1 ('MetaCons "Stereo"
'PrefixI 'False) U1) :+: (C1 ('MetaCons "Quad"
'PrefixI 'False) U1 :+: C1 ('MetaCons "FivePointOne"
'PrefixI 'False) U1))Defined in sdl2-2.5.5.0 · SDL.AudioFunctor ChangeableDefined in sdl2-2.5.5.0 · SDL.AudioFoldable ChangeableDefined in sdl2-2.5.5.0 · SDL.AudioTraversable ChangeableDefined in sdl2-2.5.5.0 · SDL.AudioEq a => Eq (Changeable a)Defined in sdl2-2.5.5.0 · SDL.AudioData a => Data (Changeable a)Defined in sdl2-2.5.5.0 · SDL.AudioRead a => Read (Changeable a)Defined in sdl2-2.5.5.0 · SDL.AudioShow a => Show (Changeable a)Defined in sdl2-2.5.5.0 · SDL.AudioGeneric (Changeable a)Defined in sdl2-2.5.5.0 · SDL.Audiotype Rep (Changeable a) = D1 ('MetaData "Changeable"
"SDL.Audio"
"sdl2-2.5.5.0-3sH3mgPhw4837qWuaPOiH"
'False) (C1 ('MetaCons "Mandate"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "Desire"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))Defined in sdl2-2.5.5.0 · SDL.AudioLock an AudioDevice such that its associated callback will not be called until the device is unlocked.
Whether a device should be locked or unlocked.
Bounded LockStateDefined in sdl2-2.5.5.0 · SDL.AudioEnum LockStateDefined in sdl2-2.5.5.0 · SDL.AudioEq LockStateDefined in sdl2-2.5.5.0 · SDL.AudioData LockStateDefined in sdl2-2.5.5.0 · SDL.AudioOrd LockStateDefined in sdl2-2.5.5.0 · SDL.AudioRead LockStateDefined in sdl2-2.5.5.0 · SDL.AudioShow LockStateDefined in sdl2-2.5.5.0 · SDL.AudioGeneric LockStateDefined in sdl2-2.5.5.0 · SDL.Audiotype Rep LockState = D1 ('MetaData "LockState"
"SDL.Audio"
"sdl2-2.5.5.0-3sH3mgPhw4837qWuaPOiH"
'False) (C1 ('MetaCons "Locked"
'PrefixI 'False) U1 :+: C1 ('MetaCons "Unlocked"
'PrefixI 'False) U1)Defined in sdl2-2.5.5.0 · SDL.AudioWhether to allow an AudioDevice to play sound or remain paused.
PausePause the AudioDevice, which will stop producing/capturing audio.
PlayResume the AudioDevice.
Bounded PlaybackStateDefined in sdl2-2.5.5.0 · SDL.AudioEnum PlaybackStateDefined in sdl2-2.5.5.0 · SDL.AudioEq PlaybackStateDefined in sdl2-2.5.5.0 · SDL.AudioData PlaybackStateDefined in sdl2-2.5.5.0 · SDL.AudioOrd PlaybackStateDefined in sdl2-2.5.5.0 · SDL.AudioRead PlaybackStateDefined in sdl2-2.5.5.0 · SDL.AudioShow PlaybackStateDefined in sdl2-2.5.5.0 · SDL.AudioGeneric PlaybackStateDefined in sdl2-2.5.5.0 · SDL.Audiotype Rep PlaybackState = D1 ('MetaData "PlaybackState"
"SDL.Audio"
"sdl2-2.5.5.0-3sH3mgPhw4837qWuaPOiH"
'False) (C1 ('MetaCons "Pause"
'PrefixI 'False) U1 :+: C1 ('MetaCons "Play"
'PrefixI 'False) U1)Defined in sdl2-2.5.5.0 · SDL.AudioChange the playback state of an AudioDevice.
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.
PlayingThe AudioDevice is playing.
PausedThe AudioDevice is paused.
StoppedThe AudioDevice is stopped.
Bounded AudioDeviceStatusDefined in sdl2-2.5.5.0 · SDL.AudioEnum AudioDeviceStatusDefined in sdl2-2.5.5.0 · SDL.AudioEq AudioDeviceStatusDefined in sdl2-2.5.5.0 · SDL.AudioData AudioDeviceStatusDefined in sdl2-2.5.5.0 · SDL.AudioOrd AudioDeviceStatusDefined in sdl2-2.5.5.0 · SDL.AudioRead AudioDeviceStatusDefined in sdl2-2.5.5.0 · SDL.AudioShow AudioDeviceStatusDefined in sdl2-2.5.5.0 · SDL.AudioGeneric AudioDeviceStatusDefined in sdl2-2.5.5.0 · SDL.Audiotype Rep AudioDeviceStatus = D1 ('MetaData "AudioDeviceStatus"
"SDL.Audio"
"sdl2-2.5.5.0-3sH3mgPhw4837qWuaPOiH"
'False) (C1 ('MetaCons "Playing"
'PrefixI 'False) U1 :+: (C1 ('MetaCons "Paused"
'PrefixI 'False) U1 :+: C1 ('MetaCons "Stopped"
'PrefixI 'False) U1))Defined in sdl2-2.5.5.0 · SDL.AudioQuery the state of an AudioDevice.
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 Word8Indicating that an 8-bit audio format in the platforms native endianness uses a buffer of Word8 values.
Signed8BitAudio :: AudioFormat Int8Unsigned8BitAudio :: AudioFormat Word8Signed16BitLEAudio :: AudioFormat Int16Signed16BitBEAudio :: AudioFormat Int16Signed16BitNativeAudio :: AudioFormat Int16Unsigned16BitLEAudio :: AudioFormat Word16Unsigned16BitBEAudio :: AudioFormat Word16Unsigned16BitNativeAudio :: AudioFormat Word16Signed32BitLEAudio :: AudioFormat Int32Signed32BitBEAudio :: AudioFormat Int32Signed32BitNativeAudio :: AudioFormat Int32FloatingLEAudio :: AudioFormat FloatFloatingBEAudio :: AudioFormat FloatFloatingNativeAudio :: AudioFormat FloatEq (AudioFormat sampleType)Defined in sdl2-2.5.5.0 · SDL.AudioOrd (AudioFormat sampleType)Defined in sdl2-2.5.5.0 · SDL.AudioShow (AudioFormat sampleType)Defined in sdl2-2.5.5.0 · SDL.AudioEnumerate all AudioDevices 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 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. AudioSpecaudioSpecFreq :: !CIntDSP frequency (samples per second)
audioSpecFormat :: !AudioFormat sampleTypeAudio data format
audioSpecChannels :: !ChannelsNumber of separate sound channels
audioSpecSilence :: !Word8Calculated udio buffer silence value
audioSpecSamples :: !Word16Audio buffer size in samples (power of 2)
audioSpecSize :: !Word32Calculated audio buffer size in bytes
audioSpecCallback :: AudioFormat sampleType -> IOVector sampleType -> IO ()The function to call when the audio device needs more data
Obtain a list of all possible audio drivers for this system. These drivers can be used to specificially initialize the audio system.
Query SDL for the name of the currently initialized audio driver, if possible. This will return Nothing if no driver has been initialized.
An abstract description of an audio driver on the host machine.
Eq AudioDriverDefined in sdl2-2.5.5.0 · SDL.AudioShow AudioDriverDefined in sdl2-2.5.5.0 · SDL.AudioGet the human readable name of an AudioDriver
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.