HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Moduleproteaaudio-sdl-0.10.1Haskell2010

Sound.ProteaAudio.SDL

ProteaAudio-SDL is a stereo audio mixer and playback library for SDL (platform independent)

  • 2 types
  • 20 values

Sample

2 declarations
newtypenewtype Sample
#

Audio sample resource handle. A sample can be shared between multiple Sound tracks. (abstraction for data)

newtypenewtype Sound
#

Sound track handle. It is used to control the audio playback. (abstraction for playback)

Audio System Setup

2 declarations
valueinitAudio
  1. :: Int

    the maximum number of sounds that are played parallely, at most 1024. Computation time is linearly correlated to this factor.

  2. -> Int

    sample frequency of the playback in Hz. 22050 corresponds to FM radio 44100 is CD quality. Computation time is linearly correlated to this factor.

  3. -> Int

    the number of bytes that are sent to the sound card at once. Low numbers lead to smaller latencies but need more computation time (thread switches). If a too small number is chosen, the sounds might not be played continuously. The default value 512 guarantees a good latency below 40 ms at 22050 Hz sample frequency.

  4. -> IO Bool

    returns True on success

#

Initializes the audio system.

valuefinishAudio :: IO ()
#

Releases the audio device and cleans up resources.

Main Mixer

3 declarations

Sample Loading

8 declarations
valuesampleFromMemoryPcm
  1. :: ByteString

    pcm sample data; array of pcm samples (signed 8 bit int, signed 16 bit int or 32 bit float)

  2. -> Int

    number of channels, e.g. 1 for mono, 2 for stereo.

  3. -> Int

    sample rate, i.e. 44100 Hz

  4. -> Int

    bits per sample, i.e. 8, 16, 32

  5. -> Float

    volume

  6. -> IO Sample

    return sample handle

#

Loads raw linear pcm sound sample from memory buffer.

Sample Playback

7 declarations
valuesoundLoop
  1. :: Sample

    handle of a previously loaded sample

  2. -> Float

    left volume

  3. -> Float

    right volume

  4. -> Float

    time difference between left and right channel in seconds. Use negative values to specify a delay for the left channel, positive for the right

  5. -> Float

    pitch factor for playback. 0.5 corresponds to one octave below, 2.0 to one above the original sample

  6. -> IO Sound
#

Plays a specified sound sample continuously any free channel and sets its parameters.

valuesoundPlay
  1. :: Sample

    handle of a previously loaded sample

  2. -> Float

    left volume

  3. -> Float

    right volume

  4. -> Float

    time difference between left and right channel in seconds. Use negative values to specify a delay for the left channel, positive for the right

  5. -> Float

    pitch factor for playback. 0.5 corresponds to one octave below, 2.0 to one above the original sample

  6. -> IO Sound
#

Plays a specified sound sample once any free channel and sets its parameters.

valuesoundLoopOn
  1. :: Int

    number of the channel to use for playback with the first channel starting at 0

  2. -> Sample

    handle of a previously loaded sample

  3. -> Float

    left volume

  4. -> Float

    right volume

  5. -> Float

    time difference between left and right channel in seconds. Use negative values to specify a delay for the left channel, positive for the right

  6. -> Float

    pitch factor for playback. 0.5 corresponds to one octave below, 2.0 to one above the original sample

  7. -> IO Sound
#

Plays a specified sound sample continuously on a specific channel and sets its parameters.

valuesoundPlayOn
  1. :: Int

    number of the channel to use for playback with the first channel starting at 0

  2. -> Sample

    handle of a previously loaded sample

  3. -> Float

    left volume

  4. -> Float

    right volume

  5. -> Float

    time difference between left and right channel in seconds. Use negative values to specify a delay for the left channel, positive for the right

  6. -> Float

    pitch factor for playback. 0.5 corresponds to one octave below, 2.0 to one above the original sample

  7. -> IO Sound
#

Plays a specified sound sample once on a specific channel and sets its parameters.

valuesoundUpdate
  1. :: Sound

    handle of a currently active sound (if sound has stopped, this is a no-op)

  2. -> Bool

    is paused state, this does not change the sound active state

  3. -> Float

    left volume

  4. -> Float

    right volume

  5. -> Float

    time difference between left and right channel in seconds. Use negative values to specify a delay for the left channel, positive for the right

  6. -> Float

    pitch factor for playback. 0.5 corresponds to one octave below, 2.0 to one above the original sample

  7. -> IO Bool

    return True in case the parameters have been updated successfully

#

Updates parameters of a specified sound.