NAME

Peta::Synth::Output::Pulse - sound to the sound server as it plays (PulseAudio or PipeWire)

VERSION

version 0.2610180

SYNOPSIS

my $out = Peta::Synth::Output::Pulse->new(rate => 48000, latency => 0.1);
$out->write(\@left, \@right) while ...;    # waits when the server has enough
$out->close;                                # plays the rest to its end

DESCRIPTION

A client of the PulseAudio native protocol in Perl, core modules only. It plays through PulseAudio and through PipeWire (whose pipewire-pulse serves the same protocol, on the same socket). The server is the one $PULSE_SERVER names (a local socket), or the user's own.

METHODS

new

new(rate => 48000, latency => 0.1, name => ..., title => ...): connected, with a stream of floats in two channels; latency the seconds the server holds ahead of what it plays.

write

write(\@left, \@right): sends the sound as the server asks for it, and waits while it has enough.

wants

Whether the server would take more now.

sent

Seconds of sound sent.

close, stop

close plays what the server holds to its end; stop drops it.

FUNCTIONS

available

Whether there is a server's socket.

address, rate

The path of the server's socket; the sample rate played.

AUTHOR

PetaMem s.r.o. <info@petamem.com>

COPYRIGHT

Copyright (c) 2026 PetaMem s.r.o.

LICENSE

This package is free software, dual-licensed under the Artistic License 2.0 and the BSD 2-Clause License. See the LICENSE file of the distribution.