line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: POEConductor.pm,v 1.1.1.1 2004/11/22 17:52:11 root Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package POE::Framework::MIDI::POEConductor; |
4
|
5
|
|
|
5
|
|
324238
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
200
|
|
5
|
5
|
|
|
5
|
|
27
|
use vars '$VERSION'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
225
|
|
6
|
5
|
|
|
5
|
|
2436
|
use POE::Framework::MIDI::Conductor; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
163
|
|
7
|
5
|
|
|
5
|
|
36
|
use base 'POE::Framework::MIDI::Conductor'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
558
|
|
8
|
5
|
|
|
5
|
|
43
|
use POE; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
35
|
|
9
|
5
|
|
|
5
|
|
6501
|
use MIDI::Simple; |
|
5
|
|
|
|
|
120804
|
|
|
5
|
|
|
|
|
5040
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
## Changelog |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Version: 0.3 - updated to change calls to deprecated POE::Session->new to |
14
|
|
|
|
|
|
|
# POE::Session->spawn - 16 March 2006 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$VERSION = 0.3; # updated to change deprecated |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# session builder - ala dngor |
21
|
|
|
|
|
|
|
sub spawn { |
22
|
3
|
|
|
3
|
0
|
5762
|
my $class = shift; |
23
|
3
|
|
|
|
|
37
|
my $self = $class->new(@_); |
24
|
3
|
|
|
|
|
46
|
POE::Session->create( |
25
|
|
|
|
|
|
|
object_states => [ $self => [qw(_start _stop start_musicians made_bar musician_query) ]]); |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
814
|
return undef; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _start { |
31
|
3
|
|
|
3
|
|
846
|
my ( $self, $kernel, $session, $heap ) = @_[ OBJECT, KERNEL, SESSION, HEAP ]; |
32
|
3
|
|
|
|
|
19
|
$kernel->post($session,'start_musicians'); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _stop { |
36
|
3
|
|
|
3
|
|
599
|
my ( $self, $kernel, $session, $heap ) = @_[ OBJECT, KERNEL, SESSION, HEAP ]; |
37
|
3
|
50
|
|
|
|
1024
|
print "rendering...\n" if $self->{cfg}->{verbose}; |
38
|
3
|
|
|
|
|
41
|
$self->render('test.mid'); |
39
|
3
|
50
|
|
|
|
40455
|
print "conductor is all done. take a bow.\n" if $self->{cfg}->{verbose}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub start_musicians { |
43
|
3
|
|
|
3
|
0
|
975
|
my ( $self, $kernel, $session, $heap ) = @_[ OBJECT, KERNEL, SESSION, HEAP ]; |
44
|
3
|
50
|
|
|
|
17
|
my $musicians = $self->{cfg}->{musicians} or die "no musicians defined in config"; |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
11
|
for (@$musicians) { |
47
|
6
|
|
|
|
|
50
|
POE::Framework::MIDI::POEMusician->spawn($_) |
48
|
|
|
|
|
|
|
} |
49
|
3
|
|
|
|
|
35
|
my $musician_names = $self->musician_names; |
50
|
3
|
|
|
|
|
13
|
for my $barnum (1..$self->{cfg}->{bars}) { |
51
|
34
|
|
|
|
|
2407
|
for (@$musician_names) { $kernel->post($_, 'make_a_bar' => $barnum) } |
|
57
|
|
|
|
|
1913
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# grabs bars from musicians as they're created |
56
|
|
|
|
|
|
|
sub made_bar { |
57
|
57
|
|
|
57
|
0
|
4175
|
my ( $self, $kernel, $session, $heap, $barnum, $bar, $musician_object ) |
58
|
|
|
|
|
|
|
= @_[ OBJECT, KERNEL, SESSION, HEAP, ARG0, ARG1, ARG2 ]; |
59
|
|
|
|
|
|
|
|
60
|
57
|
|
|
|
|
175
|
$self->add_bar({ |
61
|
|
|
|
|
|
|
musician_name => $musician_object->name, |
62
|
|
|
|
|
|
|
channel => $musician_object->channel, |
63
|
|
|
|
|
|
|
bar => $bar, |
64
|
|
|
|
|
|
|
barnum => $barnum |
65
|
|
|
|
|
|
|
}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub musician_query { |
69
|
0
|
|
|
0
|
0
|
|
my ( $self, $kernel, $session, $heap, $querystring ) = |
70
|
|
|
|
|
|
|
@_[ OBJECT, KERNEL, SESSION, HEAP, ARG0 ]; |
71
|
0
|
0
|
|
|
|
|
die "null querystring passed from musician $session->{name}" unless $querystring; |
72
|
0
|
|
|
|
|
|
print "query with $querystring\n"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |