proteaaudio-0.9.4: Simple audio library for Windows, Linux, OSX.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Sound.ProteaAudio

Description

ProteaAudio is a stereo audio mixer/playback library for

  • Linux (PusleAudio)
  • Macintosh OS X (CoreAudio)
  • Windows (DirectSound)
Synopsis

Sample

data Sample Source #

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

data Sound Source #

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

Audio System Setup

initAudio Source #

Arguments

:: Int

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

-> 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.

-> 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.

-> IO Bool

returns True on success

Initializes the audio system.

finishAudio :: IO () Source #

Releases the audio device and cleans up resources.

Main Mixer

volume Source #

Arguments

:: Float

left

-> Float

right

-> IO () 

Set main mixer volume.

soundActiveAll :: IO Int Source #

Return the number of currently active sounds.

soundStopAll :: IO () Source #

Stops all sounds immediately.

Sample Loading

loaderAvailable Source #

Arguments

:: String

file extension (e.g. ogg)

-> IO Bool 

Checks if loader for this file type is available.

sampleFromMemoryPcm Source #

Arguments

:: ByteString

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

-> Int

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

-> Int

sample rate, i.e. 44100 Hz

-> Int

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

-> Float

volume

-> IO Sample

return sample handle

Loads raw linear pcm sound sample from memory buffer.

sampleFromMemoryWav Source #

Arguments

:: ByteString

wav sample data

-> Float

volume

-> IO Sample

return sample handle

Loads wav sound sample from memory buffer.

sampleFromMemoryOgg Source #

Arguments

:: ByteString

ogg sample data

-> Float

volume

-> IO Sample

return sample handle

Loads ogg sound sample from memory buffer.

sampleFromFile Source #

Arguments

:: String

sample filepath

-> Float

volume

-> IO Sample

returns handle

Loads a sound sample from file.

sampleDestroy :: Sample -> IO Bool Source #

Unloads a previously loaded sample from memory, invalidating the handle.

Sample Playback

soundLoop Source #

Arguments

:: Sample

handle of a previously loaded sample

-> Float

left volume

-> Float

right volume

-> 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

-> Float

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

-> IO Sound 

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

soundPlay Source #

Arguments

:: Sample

handle of a previously loaded sample

-> Float

left volume

-> Float

right volume

-> 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

-> Float

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

-> IO Sound 

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

soundLoopOn Source #

Arguments

:: Int

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

-> Sample

handle of a previously loaded sample

-> Float

left volume

-> Float

right volume

-> 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

-> Float

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

-> IO Sound 

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

soundPlayOn Source #

Arguments

:: Int

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

-> Sample

handle of a previously loaded sample

-> Float

left volume

-> Float

right volume

-> 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

-> Float

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

-> IO Sound 

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

soundUpdate Source #

Arguments

:: Sound

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

-> Float

left volume

-> Float

right volume

-> 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

-> Float

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

-> IO Bool

return True in case the parameters have been updated successfully

Updates parameters of a specified sound.

soundStop :: Sound -> IO Bool Source #

Stops a specified sound immediately.

soundActive :: Sound -> IO Bool Source #

Checks if a specified sound is still active.