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

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

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 aSource

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

Single audio sample.

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

Play a (possibly) infinite list of samples.

type AudioBlock = Vector SampleSource

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.