| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Audio::Beep::Linux::beep; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | $Audio::Beep::Linux::beep::VERSION = 0.11; | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 1 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 324 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | sub new { | 
| 8 | 1 |  |  | 1 | 0 | 2 | my $class = shift; | 
| 9 | 1 |  |  |  |  | 3 | my %hash = @_; | 
| 10 | 1 |  | 33 |  |  | 8 | $hash{path} ||= _search_path(); | 
| 11 | 1 | 50 |  |  |  | 7 | return unless $hash{path}; | 
| 12 | 0 |  |  |  |  | 0 | return bless \%hash, $class; | 
| 13 |  |  |  |  |  |  | } | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | sub play { | 
| 16 | 0 |  |  | 0 | 0 | 0 | my $self = shift; | 
| 17 | 0 |  |  |  |  | 0 | my ($pitch, $duration) = @_; | 
| 18 | 0 |  |  |  |  | 0 | return `\Q$self->{path}\E -l $duration -f $pitch`; | 
| 19 |  |  |  |  |  |  | } | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | sub rest { | 
| 22 | 0 |  |  | 0 | 0 | 0 | my $self = shift; | 
| 23 | 0 |  |  |  |  | 0 | my ($duration) = @_; | 
| 24 | 0 |  |  |  |  | 0 | select undef, undef, undef, $duration/1000; | 
| 25 | 0 |  |  |  |  | 0 | return 1; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub _search_path { | 
| 29 | 1 |  |  | 1 |  | 5 | my @prob_paths = qw( | 
| 30 |  |  |  |  |  |  | /usr/bin/beep | 
| 31 |  |  |  |  |  |  | /usr/local/bin/beep | 
| 32 |  |  |  |  |  |  | /bin/beep | 
| 33 |  |  |  |  |  |  | ); | 
| 34 | 1 | 50 | 33 |  |  | 3 | do { return $_ if -e and -x _ } for @prob_paths; | 
|  | 3 |  |  |  |  | 72 |  | 
| 35 | 1 |  |  |  |  | 6 | return; | 
| 36 |  |  |  |  |  |  | } | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | =head1 NAME | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | Audio::Beep::Linux::beep - Audio::Beep player module using the B program | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head1 SYNOPIS | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | my $player = Audio::Beep::Linux::beep->new([%options]); | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | =head1 USAGE | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | The C class method can receive as option in hash fashion the following | 
| 49 |  |  |  |  |  |  | directives | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =over 4 | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | =item path => '/full/path/to/beep' | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | With the path option you can set the full path to the B program in | 
| 56 |  |  |  |  |  |  | the object. If you don't use this option the new method will look anyway | 
| 57 |  |  |  |  |  |  | in some likely places where B should be before returning undef. | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =back | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =head1 NOTES | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | The B program is a Linux program wrote by Johnathan Nightingale. | 
| 64 |  |  |  |  |  |  | You should find C sources in the tarball where you found this file. | 
| 65 |  |  |  |  |  |  | The B program needs to be (usually) executed as root to actually work. | 
| 66 |  |  |  |  |  |  | Please check C for more info. | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =head1 BUGS | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | None known. | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | Copyright 2003-2004 Giulio Motta L. | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or | 
| 77 |  |  |  |  |  |  | modify it under the same terms as Perl itself. | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =cut | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | 1; |