line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Audio::Ardour::Irc; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23492
|
use 5.008008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
99
|
|
7
|
1
|
|
|
1
|
|
5
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
8
|
1
|
|
|
1
|
|
378
|
use Net::LibLO; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use File::HomeDir; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Audio::Ardour::Irc - Automate the Ardour DAW software. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Audio::Ardour::Irc; |
20
|
|
|
|
|
|
|
my $ardour_controller = Audio::Ardour::Irc->new($url); |
21
|
|
|
|
|
|
|
$ardour_controller->sendOSCMessage($message); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
example messages (see http://ardour.org/osc_control for full list): |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$ardour_controller->sendOSCMessage('transport_play'); |
26
|
|
|
|
|
|
|
$ardour_controller->sendOSCMessage('transport_stop'); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
etc... |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This module sends OSC messages to the Ardour DAW. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
NOTE: this is a direct replacement for Audio::Ardour::Control and |
35
|
|
|
|
|
|
|
builds on Jonathan Stowe's original work. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=over 2 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item new |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Construct a new Audio::Ardour::Irc object. The only argument is the |
45
|
|
|
|
|
|
|
URL of the Ardour OSC instance in the form C:/>, |
46
|
|
|
|
|
|
|
this is printed to STDERR by Ardour when the OSC is enabled. For versions |
47
|
|
|
|
|
|
|
of Ardour from 2.2 onwards the URL will be written to a file in the user |
48
|
|
|
|
|
|
|
specific config directory and an attempt will be made to determine the URL |
49
|
|
|
|
|
|
|
from that source, if it is not present and no URL has been specified as an |
50
|
|
|
|
|
|
|
argument then this will croak. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new |
55
|
|
|
|
|
|
|
{ |
56
|
|
|
|
|
|
|
my ( $class, $url ) = @_; |
57
|
|
|
|
|
|
|
my $self = bless {}, $class; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if( ! $self->url($url) ) |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
croak "Cannot discover URL and no URL specified"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $self; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item sendOscMessage |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Make sure you pass a valid OSC command... |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub sendOscMessage |
76
|
|
|
|
|
|
|
{ |
77
|
|
|
|
|
|
|
my ( $self ) = @_; |
78
|
|
|
|
|
|
|
my $message = '/ardour/' . $_[1]; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#print "$message\n"; |
81
|
|
|
|
|
|
|
return $self->send($message, undef); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 INTERNAL METHODS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The below methods are used internally and might not be useful for |
90
|
|
|
|
|
|
|
general use unless you are sub-classing or extending this module. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item url |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Get and/or set the URL to connect to the instance of Ardour we want to |
97
|
|
|
|
|
|
|
control. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
If the url is not specifiied and has not been previously set then |
100
|
|
|
|
|
|
|
discover_url() will be called. It will return undef if no URL can be |
101
|
|
|
|
|
|
|
found. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub url |
106
|
|
|
|
|
|
|
{ |
107
|
|
|
|
|
|
|
my ( $self, $url ) = @_; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
if ( defined $url ) |
110
|
|
|
|
|
|
|
{ |
111
|
|
|
|
|
|
|
$self->{_url} = $url; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
if ( not exists $self->{_url} ) |
115
|
|
|
|
|
|
|
{ |
116
|
|
|
|
|
|
|
if ( $url = $self->discover_url() ) |
117
|
|
|
|
|
|
|
{ |
118
|
|
|
|
|
|
|
$self->{_url} = $url; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
return $self->{_url}; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item discover_url |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Attempt to read the URL from the $HOME/.ardour2/osc_url file, returns undef |
128
|
|
|
|
|
|
|
if the file doesn't exist. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This will not work for Ardour versions earlier than 2.2 |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub discover_url |
135
|
|
|
|
|
|
|
{ |
136
|
|
|
|
|
|
|
my ( $self ) = @_; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my $home = File::HomeDir->my_home(); |
139
|
|
|
|
|
|
|
my $osc_url = File::Spec->catfile($home,'.ardour2','osc_url'); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $url; |
142
|
|
|
|
|
|
|
if ( open URL, $osc_url ) |
143
|
|
|
|
|
|
|
{ |
144
|
|
|
|
|
|
|
chomp($url = ); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
return $url; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item send |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Send a request to the OSC host. The arguments are the OSC path and the |
152
|
|
|
|
|
|
|
arguments for the call. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub send |
157
|
|
|
|
|
|
|
{ |
158
|
|
|
|
|
|
|
my ( $self, $path, $argspec, $args ) = @_; |
159
|
|
|
|
|
|
|
$self->lo()->send($self->address, $path, $argspec, $args); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item lo |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Get and/or set the underlying L object that we are using. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub lo |
169
|
|
|
|
|
|
|
{ |
170
|
|
|
|
|
|
|
my ( $self, $lo ) = @_; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
if ( defined $lo ) |
173
|
|
|
|
|
|
|
{ |
174
|
|
|
|
|
|
|
$self->{_lo} = $lo; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
if ( not exists $self->{_lo} ) |
178
|
|
|
|
|
|
|
{ |
179
|
|
|
|
|
|
|
$self->{_lo} = Net::LibLO->new(); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
return $self->{_lo}; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item address |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Get and/or set the L object based on the URL of the |
189
|
|
|
|
|
|
|
Ardour OSC instance that we are going to use. If the address has not previously |
190
|
|
|
|
|
|
|
been set then a new object will be created. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub address |
195
|
|
|
|
|
|
|
{ |
196
|
|
|
|
|
|
|
my ( $self, $address ) = @_; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
if ( defined $address ) |
199
|
|
|
|
|
|
|
{ |
200
|
|
|
|
|
|
|
$self->{_addr} = $address; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
if ( not exists $self->{_addr} ) |
204
|
|
|
|
|
|
|
{ |
205
|
|
|
|
|
|
|
$self->{_addr} = Net::LibLO::Address->new($self->url()); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
return $self->{_addr}; |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=back |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 EXPORT |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
None. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 BUGS AND SUPPORT |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
The OSC support in Ardour and this module should be considered experimental, |
221
|
|
|
|
|
|
|
you almost certainly don't want to use this on any important Sessions without |
222
|
|
|
|
|
|
|
thorough testing. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 SEE ALSO |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
L, Ardour documentation L, |
227
|
|
|
|
|
|
|
OSC |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 AUTHOR |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Noel Darlow, Ecpan@aperiplus.co.ukE |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Copyright (C) 2012 by Noel Darlow |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
238
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
239
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=cut |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
1; |
246
|
|
|
|
|
|
|
__END__ |