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

Moduleproteaaudio-sdl-0.10.1Haskell2010

Sound.ProteaAudio.SDL

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

Contents
  1. Sample
  2. Audio System Setup
  3. Main Mixer
  4. Sample Loading
  5. Sample Playback
Synopsis

Sample

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

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.

Main Mixer

Sample Loading

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

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.