| Portability | non-portable |
|---|---|
| Stability | experimental |
| Maintainer | [email protected] |
Sound.Pulse.Simple
Description
Binding to PulseAudio Simple API (original documentation: http://0pointer.de/lennart/projects/pulseaudio/doxygen/simple_8h.html)
playback example(output 440Hz sine wave for 10 seconds):
main=do
s<-simpleNew Nothing "example" Play Nothing "this is an example application"
(SampleSpec (F32 LittleEndian) 44100 1) Nothing Nothing
simpleWrite s ([sin $ 2*pi*440*(t/44100)|t<-[1..44100*10]] :: [Float])
simpleDrain s
simpleFree s
recording example(record for 10 seconds):
main=do
s<-simpleNew Nothing "example" Record Nothing "this is an example application"
(SampleSpec (F32 LittleEndian) 44100 1) Nothing Nothing
xs<-simpleRead s $ 44100*10 :: IO [Float]
simpleFree s
Note that recording starts when simpleNew is called.
- simpleNew :: Maybe String -> String -> Direction -> Maybe String -> String -> SampleSpec -> Maybe [ChannelPosition] -> Maybe BufferAttr -> IO Simple
- simpleFree :: Simple -> IO ()
- simpleGetLatency :: Simple -> IO Integer
- simpleRead :: Storable a => Simple -> Int -> IO [a]
- simpleReadRaw :: Simple -> Int -> IO ByteString
- simpleWrite :: Storable a => Simple -> [a] -> IO ()
- simpleWriteRaw :: Simple -> ByteString -> IO ()
- simpleDrain :: Simple -> IO ()
- simpleFlush :: Simple -> IO ()
- data Simple
- data SampleSpec = SampleSpec SampleFormat Int Int
- data SampleFormat
- data Compression
- data Endian
- data Direction
- data ChannelPosition
- = ChannelMono
- | ChannelNormal ChannelPan
- | ChannelFront ChannelPan
- | ChannelRear ChannelPan
- | ChannelTopRear ChannelPan
- | ChannelTopFront ChannelPan
- | ChannelLFE
- | ChannelSubwoofer
- | ChannelFrontCenterLeft
- | ChannelFrontCenterRight
- | ChannelSideLeft
- | ChannelSideRight
- | ChannelTopCenter
- | ChannelAux Int
- data ChannelPan
- data BufferAttr = BufferAttr (Maybe Int) (Maybe Int) (Maybe Int) (Maybe Int) (Maybe Int)
Documentation
Arguments
| :: Maybe String | server name |
| -> String | client name |
| -> Direction | Play or Record |
| -> Maybe String | name of sink or source |
| -> String | description of client |
| -> SampleSpec | |
| -> Maybe [ChannelPosition] | label channels |
| -> Maybe BufferAttr | buffer size, etc |
| -> IO Simple |
Establish connection to pulseaudio server. You usually don't need to specify optional fields.
simpleFree :: Simple -> IO ()Source
Close the connection.
simpleGetLatency :: Simple -> IO IntegerSource
Get current latency in microseconds.
Read from buffer. (non-blocking if specified # of samples already exist in the internal buffer)
simpleReadRaw :: Simple -> Int -> IO ByteStringSource
Read raw data from buffer.
simpleWrite :: Storable a => Simple -> [a] -> IO ()Source
Write to buffer. (blocks until buffer is almost consumed)
simpleWriteRaw :: Simple -> ByteString -> IO ()Source
Write raw data to buffer.
simpleDrain :: Simple -> IO ()Source
Block until playback buffer is completely consumed.
simpleFlush :: Simple -> IO ()Source
Flush playback buffer.
data SampleSpec Source
Constructors
| SampleSpec SampleFormat Int Int | format, sampling rate, #channels |
Instances
data SampleFormat Source
Constructors
| U8 Compression | 8 bit unsigned (optionally compressed using |
| S16 Endian | 16 bit signed |
| S24 Endian | 24 bit signed |
| S2432 Endian | 24 bit signed padded to 32 bit |
| S32 Endian | 32 bit signed |
| F32 Endian | 32 bit float in [-1,1] |
Instances
data Compression Source
Constructors
| BigEndian | |
| LittleEndian |
data ChannelPosition Source
Constructors
| ChannelMono | |
| ChannelNormal ChannelPan | |
| ChannelFront ChannelPan | |
| ChannelRear ChannelPan | |
| ChannelTopRear ChannelPan | |
| ChannelTopFront ChannelPan | |
| ChannelLFE | low frequency effects |
| ChannelSubwoofer | |
| ChannelFrontCenterLeft | equivalent to PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER |
| ChannelFrontCenterRight | |
| ChannelSideLeft | |
| ChannelSideRight | |
| ChannelTopCenter | |
| ChannelAux Int |
Instances
data ChannelPan Source
data BufferAttr Source
max length, target length, prebuffer, minimum request, fragment size
Instances