This is a wrapper to PulseAudio for Ruby.
Here comes a short code sample. Currently almost no docs. Currently it does only a bit more than just connecting to PA server and reading some of it parameters, but please note that this is new and rapidly evolving project.
require 'glib2' require 'lib/pulseaudio' pa = PulseAudio::Asynchronous::Context.new pa.state_callback_proc = Proc.new{ |context, user_data| puts "Connection state has changed to #{context.state}" if context.state == :ready puts "I am connected, my index is #{context.index}" context.operation.clients.all do |operation, list, user_data| puts "List of all clients connected to this PulseAudio server:" puts list.inspect end end } pa.connect GLib::Timeout.add(3000) do puts "Disconnecting" pa.disconnect end mainloop = GLib::MainLoop.new mainloop.run
Please notice that code is very young, not well-tested and can contain bugs. API is not stable.
It was tested with ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux] under Ubuntu 10.10.
The source code is available at github.com/saepia/pulseaudio-ffi-ruby.