Audio::Beep::Linux::beep - Audio::Beep player module using the B<beep> program


Audio-Beep documentation Contained in the Audio-Beep distribution.

Index


Code Index:

NAME

Top

Audio::Beep::Linux::beep - Audio::Beep player module using the beep program

SYNOPIS

Top

    my $player = Audio::Beep::Linux::beep->new([%options]);

USAGE

Top

The new class method can receive as option in hash fashion the following directives

path => '/full/path/to/beep'

With the path option you can set the full path to the beep program in the object. If you don't use this option the new method will look anyway in some likely places where beep should be before returning undef.

NOTES

Top

The beep program is a Linux program wrote by Johnathan Nightingale. You should find C sources in the tarball where you found this file. The beep program needs to be (usually) executed as root to actually work. Please check beep(1) for more info.

BUGS

Top

None known.

COPYRIGHT

Top


Audio-Beep documentation Contained in the Audio-Beep distribution.

package Audio::Beep::Linux::beep;

$Audio::Beep::Linux::beep::VERSION = 0.11;

use strict;

sub new {
    my $class = shift;
    my %hash = @_;
    $hash{path} ||= _search_path();
    return unless $hash{path};
    return bless \%hash, $class;
}

sub play {
    my $self = shift;
    my ($pitch, $duration) = @_;
    return `\Q$self->{path}\E -l $duration -f $pitch`;
}

sub rest {
    my $self = shift;
    my ($duration) = @_;
    select undef, undef, undef, $duration/1000;
    return 1;
}

sub _search_path {
    my @prob_paths = qw(
        /usr/bin/beep
        /usr/local/bin/beep
        /bin/beep
    );
    do { return $_ if -e and -x _ } for @prob_paths;
    return;
}

1;