Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
ProteaAudio-SDL is a stereo audio mixer and playback library for SDL (platform independent)
Synopsis
- data Sample
- data Sound
- initAudio :: Int -> Int -> Int -> IO Bool
- finishAudio :: IO ()
- volume :: Float -> Float -> IO ()
- soundActiveAll :: IO Int
- soundStopAll :: IO ()
- loaderAvailable :: String -> IO Bool
- sampleFromMemoryPcm :: ByteString -> Int -> Int -> Int -> Float -> IO Sample
- sampleFromMemoryWav :: ByteString -> Float -> IO Sample
- sampleFromMemoryOgg :: ByteString -> Float -> IO Sample
- sampleFromMemoryMp3 :: ByteString -> Float -> IO Sample
- sampleFromFile :: String -> Float -> IO Sample
- sampleDestroy :: Sample -> IO Bool
- soundLoop :: Sample -> Float -> Float -> Float -> Float -> IO Sound
- soundPlay :: Sample -> Float -> Float -> Float -> Float -> IO Sound
- soundLoopOn :: Int -> Sample -> Float -> Float -> Float -> Float -> IO Sound
- soundPlayOn :: Int -> Sample -> Float -> Float -> Float -> Float -> IO Sound
- soundUpdate :: Sound -> Bool -> Float -> Float -> Float -> Float -> IO Bool
- soundStop :: Sound -> IO Bool
- soundActive :: Sound -> IO Bool
Sample
Audio sample resource handle. A sample can be shared between multiple Sound tracks. (abstraction for data)
Sound track handle. It is used to control the audio playback. (abstraction for playback)
Audio System Setup
:: 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
soundActiveAll :: IO Int Source #
Return the number of currently active sounds.
soundStopAll :: IO () Source #
Stops all sounds immediately.
Sample Loading
Checks if loader for this file type is available.
:: 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.
:: ByteString | wav sample data |
-> Float | volume |
-> IO Sample | return sample handle |
Loads wav sound sample from memory buffer.
:: ByteString | ogg sample data |
-> Float | volume |
-> IO Sample | return sample handle |
Loads ogg sound sample from memory buffer.
:: ByteString | mp3 sample data |
-> Float | volume |
-> IO Sample | return sample handle |
Loads mp3 sound sample from memory buffer.
Loads a sound sample from file.
sampleDestroy :: Sample -> IO Bool Source #
Unloads a previously loaded sample from memory, invalidating the handle.
Sample Playback
:: 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.
:: 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.
:: 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.
:: 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.
:: Sound | handle of a currently active sound (if sound has stopped, this is a no-op) |
-> Bool | is paused state, this does not change the sound active state |
-> 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.