pulse-simple-0.1.14: binding to Simple API of pulseaudio

Portabilitynon-portable
Stabilityexperimental
Maintainerxanxys@gmail.com
Safe HaskellNone

Sound.Pulse.Simple

Description

Binding to PulseAudio Simple API (original documentation: http://freedesktop.org/software/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.

Synopsis

Documentation

simpleNewSource

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.

simpleReadSource

Arguments

:: Storable a 
=> Simple 
-> Int

number of samples to read

-> IO [a] 

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 Compression)

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

Raw 
ALaw 
MuLaw 

data Endian Source

Constructors

BigEndian 
LittleEndian 

data Direction Source

Constructors

Play 
Record 

Instances

data BufferAttr Source

max length, target length, prebuffer, minimum request, fragment size

Constructors

BufferAttr (Maybe Int) (Maybe Int) (Maybe Int) (Maybe Int) (Maybe Int) 

Instances