| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::OpenSoundControl::Client; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3978
|
use 5.006; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
42
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
129
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
34
|
|
|
6
|
1
|
|
|
1
|
|
1002
|
use IO::Socket; |
|
|
1
|
|
|
|
|
29773
|
|
|
|
1
|
|
|
|
|
5
|
|
|
7
|
1
|
|
|
1
|
|
1124
|
use Net::OpenSoundControl; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
501
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Net::OpenSoundControl::Client - OpenSound Control client implementation |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Net::OpenSoundControl::Client; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $client = Net::OpenSoundControl::Client->new( |
|
22
|
|
|
|
|
|
|
Host => "192.168.3.240", Port => 7777) |
|
23
|
|
|
|
|
|
|
or die "Could not start client: $@\n"; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# This is a very slow fade-in... |
|
26
|
|
|
|
|
|
|
for (0..100) { |
|
27
|
|
|
|
|
|
|
$client->send(['/Main/Volume', 'f', $_ / 100]); |
|
28
|
|
|
|
|
|
|
sleep(1); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
This module implements an OSC client sending messages via UDP. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item new(Host => Host, Port => $port, Name => $name) |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Creates a new client object. The default host is localhost, the default port 7123 and the default name C. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Returns undef on failure (in this case, $@ is set). |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub new { |
|
48
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
49
|
0
|
|
|
|
|
|
my %opts = @_; |
|
50
|
0
|
|
|
|
|
|
my $self = {}; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
0
|
|
|
|
$self->{HOST} = $opts{Host} || "localhost"; |
|
53
|
0
|
|
0
|
|
|
|
$self->{PORT} = $opts{Port} || 7123; |
|
54
|
0
|
|
0
|
|
|
|
$self->{NAME} = $opts{Name} |
|
55
|
|
|
|
|
|
|
|| 'Net-OpenSoundControl-Client talking to ' . $self->{HOST} . ':' . |
|
56
|
|
|
|
|
|
|
$self->{PORT}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
$self->{SOCKET} = IO::Socket::INET->new( |
|
59
|
|
|
|
|
|
|
PeerAddr => $self->{HOST}, |
|
60
|
|
|
|
|
|
|
PeerPort => $self->{PORT}, |
|
61
|
|
|
|
|
|
|
Proto => 'udp') |
|
62
|
|
|
|
|
|
|
or return undef; # error is in $@ |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
bless $self, $class; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item name() |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns the name of the client |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub name { |
|
74
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $self->{NAME}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item host() |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns the server host we are talking to |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub host { |
|
86
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $self->{HOST}; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item port() |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns the server port we are talking to |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub port { |
|
98
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return $self->{PORT}; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item send($data) |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Sends an OSC message or bundle to the server |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub send { |
|
110
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
111
|
0
|
|
|
|
|
|
my ($data) = @_; |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
$self->{SOCKET}->send(Net::OpenSoundControl::encode($data)); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The OpenSound Control website: http://www.cnmat.berkeley.edu/OpenSoundControl/ |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHOR |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Christian Renz, Ecrenz @ web42.comE |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Copyright 2004-2005 by Christian Renz Ecrenz @ web42.comE |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
135
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |