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::Plugin::Perl; |
21
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
22
|
1
|
|
|
1
|
|
4
|
use Audio::LADSPA; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
23
|
1
|
|
|
1
|
|
5
|
use Audio::LADSPA::Library; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
47
|
|
24
|
|
|
|
|
|
|
our @ISA = qw(Audio::LADSPA::Plugin); |
25
|
|
|
|
|
|
|
our $VERSION = "0.021"; |
26
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
27
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
161
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__PACKAGE__->description( |
30
|
|
|
|
|
|
|
name => 'Audio::LADSPA::Plugin::Perl', |
31
|
|
|
|
|
|
|
label => 'perl', |
32
|
|
|
|
|
|
|
maker => 'Joost Diepenmaat', |
33
|
|
|
|
|
|
|
copyright => 'GPL', |
34
|
|
|
|
|
|
|
id => '0', |
35
|
|
|
|
|
|
|
ports => [ |
36
|
|
|
|
|
|
|
], |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub description { |
40
|
|
|
|
|
|
|
my ($class,%desc) = @_; |
41
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
328
|
|
42
|
|
|
|
|
|
|
for my $sub qw(id label name maker copyright is_realtime |
43
|
|
|
|
|
|
|
is_hard_rt_capable is_inplace_broken) { |
44
|
|
|
|
|
|
|
*{"${class}::$sub"} = sub { |
45
|
|
|
|
|
|
|
return $desc{$sub}; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
for my $sub qw(is_input is_control lower_bound upper_bound |
49
|
|
|
|
|
|
|
is_toggled is_integer is_sample_rate is_logarithmic default) { |
50
|
|
|
|
|
|
|
*{"${class}::$sub"} = sub { |
51
|
|
|
|
|
|
|
my ($self,$port) = @_; |
52
|
|
|
|
|
|
|
return $self->_portd($port)->{$sub}; |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
*{"${class}::_description"} = sub { |
56
|
|
|
|
|
|
|
return \%desc; |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
Audio::LADSPA::Library::Perl->register($class) unless $class eq __PACKAGE__; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub port_count { |
62
|
|
|
|
|
|
|
my ($class) = @_; |
63
|
|
|
|
|
|
|
return scalar @{$class->_description->{ports}}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _portd { |
67
|
|
|
|
|
|
|
my ($class,$port) = @_; |
68
|
|
|
|
|
|
|
return $class->_description->{ports}->[ $class->port2index($port) ]; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub port_name { |
72
|
|
|
|
|
|
|
my ($class,$port) = @_; |
73
|
|
|
|
|
|
|
return $class->_portd($port)->{name}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _unregistered_connect { |
77
|
|
|
|
|
|
|
my ($self,$port,$buffer) = @_; |
78
|
|
|
|
|
|
|
$self->{buffers}->[ $self->port2index($port) ] = $buffer; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub get_buffer { |
82
|
|
|
|
|
|
|
my ($self,$port) = @_; |
83
|
|
|
|
|
|
|
return $self->{buffers}->[ $self->port2index($port) ]; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _unregistered_disconnect { |
87
|
|
|
|
|
|
|
my ($self,$port) = @_; |
88
|
|
|
|
|
|
|
$self->{buffers}->[ $self->port2index($port) ] = undef; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub set_monitor { |
92
|
|
|
|
|
|
|
my ($self,$monitor) = @_; |
93
|
|
|
|
|
|
|
$self->{monitor} = $monitor; |
94
|
|
|
|
|
|
|
weaken($self->{monitor}) if defined $self->{monitor}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub monitor { |
98
|
|
|
|
|
|
|
my ($self) = @_; |
99
|
|
|
|
|
|
|
return $self->{monitor}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub port2index { |
103
|
|
|
|
|
|
|
my ($self,$name) = @_; |
104
|
|
|
|
|
|
|
croak "Port name/index undefined" unless defined $name; |
105
|
|
|
|
|
|
|
if ($name =~ /\D/) { |
106
|
|
|
|
|
|
|
if ($self->port_count > 0) { |
107
|
|
|
|
|
|
|
# warn "get index for $name - port_count = ".$self->port_count; |
108
|
|
|
|
|
|
|
for ( 0 .. $self->port_count -1 ) { |
109
|
|
|
|
|
|
|
# warn "test $_"; |
110
|
|
|
|
|
|
|
return $_ if $self->port_name($_) eq $name; |
111
|
|
|
|
|
|
|
# warn "that isn't it.."; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
croak "No such port $name"; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
return $name; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub new { |
120
|
|
|
|
|
|
|
my ($class, $sample_rate, $uid) = @_; |
121
|
|
|
|
|
|
|
if ($class eq 'Audio::LADSPA::Plugin::Perl') { |
122
|
|
|
|
|
|
|
croak "Audio::LADSPA::Plugin::Perl is an abstract class and cannot be instantiated!"; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
$uid ||= $class->generate_uniqid; |
125
|
|
|
|
|
|
|
my $self = bless { |
126
|
|
|
|
|
|
|
sample_rate => $sample_rate, |
127
|
|
|
|
|
|
|
uniqid => $uid, |
128
|
|
|
|
|
|
|
},$class; |
129
|
|
|
|
|
|
|
$self->init(); |
130
|
|
|
|
|
|
|
return $self; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub has_run { |
134
|
|
|
|
|
|
|
return $_[0]->can('run'); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub has_activate { |
138
|
|
|
|
|
|
|
return $_[0]->can('activate'); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub has_deactivate { |
142
|
|
|
|
|
|
|
return $_[0]->can('deactivate'); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub has_run_adding { |
146
|
|
|
|
|
|
|
return $_[0]->can('run_adding'); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub set_uniqid { |
150
|
|
|
|
|
|
|
$_[0]->{uniqid} = $_[1]; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub get_uniqid { |
154
|
|
|
|
|
|
|
$_[0]->{uniqid}; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
__END__ |