| 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; |
|
21
|
11
|
|
|
11
|
|
76
|
use strict; |
|
|
11
|
|
|
|
|
22
|
|
|
|
11
|
|
|
|
|
564
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = "0.021"; |
|
23
|
11
|
|
|
11
|
|
56
|
use Carp; |
|
|
11
|
|
|
|
|
20
|
|
|
|
11
|
|
|
|
|
766
|
|
|
24
|
11
|
|
|
11
|
|
61
|
use constant ABOVE_ZERO => 0.00000000000000000000000000000000000000000000000000000001; |
|
|
11
|
|
|
|
|
25
|
|
|
|
11
|
|
|
|
|
965
|
|
|
25
|
11
|
|
|
11
|
|
16074
|
use Data::Uniqid qw(); |
|
|
11
|
|
|
|
|
823524
|
|
|
|
11
|
|
|
|
|
10349
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub ports { |
|
28
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
29
|
0
|
|
|
|
|
|
return map $self->port_name($_), 0 .. $self->port_count - 1; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub disconnect_all { |
|
33
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
34
|
0
|
|
|
|
|
|
for ($self->ports) { |
|
35
|
0
|
|
|
|
|
|
$self->disconnect($_); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub set { |
|
40
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
41
|
0
|
|
|
|
|
|
my $port_id = shift; |
|
42
|
0
|
0
|
|
|
|
|
ref($self) or croak "Audio::LADSPA::Buffer->set() is an object method!"; |
|
43
|
0
|
0
|
|
|
|
|
my $buffer = $self->get_buffer($port_id) or croak "No buffer for port $port_id"; |
|
44
|
0
|
|
|
|
|
|
$buffer->set(@_); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get { |
|
48
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
49
|
0
|
|
|
|
|
|
my $port_id = shift; |
|
50
|
0
|
0
|
|
|
|
|
ref($self) or croak "Audio::LADSPA::Buffer->get() is an object method!"; |
|
51
|
0
|
0
|
|
|
|
|
my $buffer = $self->get_buffer($port_id) or croak "No buffer for port $port_id"; |
|
52
|
0
|
|
|
|
|
|
return $buffer->get(); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub default_value { |
|
57
|
0
|
|
|
0
|
1
|
|
my ($self,$port) = @_; |
|
58
|
0
|
|
|
|
|
|
my $lower = $self->lower_bound($port); |
|
59
|
0
|
0
|
|
|
|
|
defined($lower) or $lower = -1; |
|
60
|
0
|
|
|
|
|
|
my $upper = $self->upper_bound($port); |
|
61
|
0
|
0
|
|
|
|
|
defined($upper) or $upper = 1; |
|
62
|
0
|
0
|
|
|
|
|
if ($lower > $upper) { |
|
63
|
0
|
|
|
|
|
|
croak "Plugin has only defined upper_bound or lower_bound and it's out of range (-1,1)"; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
0
|
|
|
|
|
|
my $log = $self->is_logarithmic($port); |
|
66
|
0
|
|
|
|
|
|
my $sr = $self->is_sample_rate($port); |
|
67
|
0
|
|
|
|
|
|
for ($self->default($port)) { |
|
68
|
0
|
|
|
|
|
|
local $_ = $_; |
|
69
|
0
|
0
|
|
|
|
|
$_ = 'middle' unless defined $_; |
|
70
|
0
|
0
|
|
|
|
|
if ($_ eq 'minimum') { |
|
71
|
0
|
|
|
|
|
|
return $lower; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
0
|
0
|
|
|
|
|
if ($_ eq 'low') { |
|
74
|
0
|
0
|
0
|
|
|
|
return exp(log($lower || ABOVE_ZERO) * 0.75 + log($upper || ABOVE_ZERO) * 0.25) if $log; |
|
|
|
|
0
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return ($lower * 0.75 + $upper * 0.25); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
0
|
0
|
|
|
|
|
if ($_ eq 'middle') { |
|
78
|
0
|
0
|
0
|
|
|
|
return exp(log($lower || ABOVE_ZERO) * 0.5 + log($upper || ABOVE_ZERO) * 0.5) if $log; |
|
|
|
|
0
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return ($lower * 0.5 + $upper * 0.5); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
0
|
0
|
|
|
|
|
if ($_ eq 'high') { |
|
82
|
0
|
0
|
0
|
|
|
|
return exp(log($lower || ABOVE_ZERO) * 0.25 + log($upper || ABOVE_ZERO) * 0.75) if $log; |
|
|
|
|
0
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
return ($lower * 0.25 + $upper * 0.75); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
0
|
0
|
|
|
|
|
if ($_ eq 'maximum') { |
|
86
|
0
|
|
|
|
|
|
return $upper; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
0
|
0
|
|
|
|
|
if ($_ eq '0') { |
|
89
|
0
|
|
|
|
|
|
return 0; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
0
|
0
|
|
|
|
|
if ($_ eq '1') { |
|
92
|
0
|
|
|
|
|
|
return 1; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
0
|
0
|
|
|
|
|
if ($_ eq '100') { |
|
95
|
0
|
|
|
|
|
|
return 100; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
0
|
0
|
|
|
|
|
if ($_ eq '440') { |
|
98
|
0
|
|
|
|
|
|
return 440; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} |
|
101
|
0
|
|
|
|
|
|
die "Logic error: port = '$port', default ='".$self->default($port)."', lower='".$self->lower_bound($port)."', upper='".$self->upper_bound($port)."'"; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub connect { |
|
105
|
0
|
|
|
0
|
1
|
|
my ($self,$port,$buffer) = @_; |
|
106
|
0
|
0
|
|
|
|
|
if ($self->callback('cb_connect',$self, $port, $buffer )) { |
|
107
|
0
|
0
|
|
|
|
|
if (defined ($self->get_buffer($port))) { |
|
108
|
0
|
|
|
|
|
|
$self->disconnect($port); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
0
|
|
|
|
|
|
$self->_unregistered_connect($port,$buffer); |
|
111
|
0
|
|
|
|
|
|
return 1; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
0
|
|
|
|
|
|
return 0; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub disconnect { |
|
117
|
0
|
|
|
0
|
1
|
|
my ($self,$port) = @_; |
|
118
|
0
|
|
|
|
|
|
$self->callback( 'cb_disconnect', $self, $port ); |
|
119
|
0
|
|
|
|
|
|
$self->_unregistered_disconnect( $port); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub callback { |
|
123
|
0
|
|
|
0
|
0
|
|
my ($self, $method, @args) = @_; |
|
124
|
0
|
0
|
|
|
|
|
if (my $monitor = $self->monitor) { |
|
125
|
0
|
0
|
|
|
|
|
if (my $mref = $monitor->can($method)) { |
|
126
|
0
|
|
|
|
|
|
return $monitor->$mref(@args); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
} |
|
129
|
0
|
|
|
|
|
|
return 1; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub generate_uniqid { |
|
133
|
0
|
|
|
0
|
0
|
|
my ($self) = shift; |
|
134
|
0
|
|
|
|
|
|
return Data::Uniqid::luniqid; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
|
139
|
|
|
|
|
|
|
|