File Coverage

blib/lib/Audio/LADSPA.pm
Criterion Covered Total %
statement 17 37 45.9
branch 0 14 0.0
condition n/a
subroutine 7 10 70.0
pod 3 4 75.0
total 27 65 41.5


line stmt bran cond sub pod time code
1             # Audio::LADSPA perl modules for interfacing with LADSPA plugins
2             # Copyright (C) 2003 Joost Diepenmaat.
3             #
4             # This program is free software; you can redistribute it and/or modify
5             # it under the terms of the GNU General Public License as published by
6             # the Free Software Foundation; either version 2 of the License, or
7             # (at your option) any later version.
8             #
9             # This program is distributed in the hope that it will be useful,
10             # but WITHOUT ANY WARRANTY; without even the implied warranty of
11             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12             # GNU General Public License for more details.
13             #
14             # You should have received a copy of the GNU General Public License
15             # along with this program; if not, write to the Free Software
16             # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17             #
18             # See the COPYING file for more information.
19              
20             package Audio::LADSPA;
21 11     11   239267 use strict;
  11         25  
  11         392  
22 11     11   7089 use Audio::LADSPA::LibraryLoader;
  11         36  
  11         422  
23 11     11   8411 use Audio::LADSPA::Buffer;
  11         30  
  11         313  
24 11     11   254 use 5.006;
  11         33  
  11         412  
25 11     11   60 use Carp;
  11         21  
  11         5668  
26              
27             our $VERSION = "0.021";
28              
29             our @LIBRARIES; # will store the list of found libraries as Perl class names
30             our @PLUGINS; # will store the names of all loaded plugins as Perl class names
31             our %PLUGINS; # will store the values in @PLUGINS indexed by id
32              
33             unless (@LIBRARIES) {
34             for my $lib_path (Audio::LADSPA::LibraryLoader->find_libraries()) {
35             Audio::LADSPA->load($lib_path);
36             }
37             }
38              
39             sub load {
40 0     0 0 0 my ($class,$lib_path) = @_;
41 0 0       0 if (my $lib = Audio::LADSPA::LibraryLoader->load($lib_path)) {
42 0         0 push @LIBRARIES,$lib;
43 0         0 for ($lib->plugins()) {
44 0         0 push @PLUGINS,$_;
45 0         0 $PLUGINS{ $_->id } = $_;
46             }
47 0         0 return $lib;
48             }
49 0         0 return;
50             }
51              
52              
53             sub libraries {
54 10     10 1 6639 @LIBRARIES,'Audio::LADSPA::Library::Perl';
55             }
56              
57             sub plugins {
58 0     0 1   @PLUGINS,'Audio::LADSPA::Library::Perl'->plugins;
59             }
60              
61             sub plugin {
62 0     0 1   shift;
63 0 0         (my (%args) = @_) or croak "usage: Audio::LADSPA::Plugin->( find_args )";
64 0 0         if ($args{id}) {
65 0           return $PLUGINS{$args{id}};
66             }
67             else {
68 0           for (@PLUGINS) {
69 0 0         if ($args{label}) {
70 0 0         next unless $_->label eq $args{label};
71             }
72 0 0         if ($args{name}) {
73 0 0         next unless $_->name eq $args{name};
74             }
75 0           return $_;
76             }
77             }
78             }
79              
80             END {
81 11     11   40712 for (@LIBRARIES) {
82 0         0 Audio::LADSPA::LibraryLoader->unload($_);
83             }
84             }
85              
86             1;
87              
88             __END__