Safe Haskell | Safe-Infered |
---|
- data Speakers
- type SampleRate = Frequency
- standardSampleRates :: [SampleRate]
- type BlockSize = Int
- withSpeakers :: SampleRate -> BlockSize -> (Speakers -> IO a) -> IO a
- testSine :: Frequency -> IO ()
- type Sample = Float
- playSamples :: Speakers -> [Sample] -> IO ()
- type AudioBlock = Vector Sample
- playBlock :: Speakers -> AudioBlock -> IO ()
Synopsis
Very small module for playing audio data on your speakers.
Currently based on the Haskell OpenAL bindings.
Setting up audio devices
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]
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 AudioBlock = Vector SampleSource
Memory block containing audio data. Blockwise audio processing may be faster than lazy lists of samples.