Safe Haskell | None |
---|---|
Language | Haskell98 |
- 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 = 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]
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
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.