tomato-rubato-openal- Easy to use library for audio programming.

Safe HaskellNone





Very small module for playing audio data on your speakers.

Currently based on the Haskell OpenAL bindings.

Setting up audio devices

data Speakers Source

Data type representing your loudspeakers.

type SampleRate = Frequency Source

Audio sample rate. Needs to be one of the standardSampleRates .

standardSampleRates :: [SampleRate] Source

List of standard sample rates, from high quality to low quality

standardSampleRates = [44100,22050,11025]

type BlockSize = Int Source

Size of an audio block.

The lower the block size, the lower the latency. However, if the block size is too low, there will be jitter.

Recommended values: 64, 128, 256, 512

withSpeakers :: SampleRate -> BlockSize -> (Speakers -> IO a) -> IO a Source

Initialize audio environment.

testSine :: Frequency -> IO () Source

Play a test sine wave. Look at the source code to see how the library is used.

This should be a clear sound, similar to a telephone test tone. If there is rattling or hissing, you have a problem.

> testSine 440

Audio data and playback

type Sample = Float Source

Single audio sample.

playSamples :: Speakers -> [Sample] -> IO () Source

Play a (possibly) infinite list of samples.

type AudioBlock = Vector Sample Source

Memory block containing audio data. Blockwise audio processing may be faster than lazy lists of samples.

playBlock :: Speakers -> AudioBlock -> IO () Source

Add a block of audio data to the speaker queue. May block if the speaker has too much pending data.