| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#_{ Encoding and name |
|
2
|
|
|
|
|
|
|
=encoding utf8 |
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Csound::ScoreStatement |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
|
8
|
|
|
|
|
|
|
#_} |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Csound::Score; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
388
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
39
|
|
|
13
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
14
|
1
|
|
|
1
|
|
7
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
31
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
66
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
7
|
use Csound; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
26
|
|
|
19
|
1
|
|
|
1
|
|
8
|
use Csound::Orchestra; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
27
|
|
|
20
|
1
|
|
|
1
|
|
354
|
use Csound::ScoreStatement::f; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
994
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = $Csound::VERSION; |
|
23
|
|
|
|
|
|
|
#_{ Synopsis |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use Csound::Score; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
... |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
|
32
|
|
|
|
|
|
|
#_} |
|
33
|
|
|
|
|
|
|
#_{ Description |
|
34
|
|
|
|
|
|
|
=head DESCRIPTION |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Scores |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
#_} |
|
40
|
|
|
|
|
|
|
#_{ Methods |
|
41
|
|
|
|
|
|
|
#_{ |
|
42
|
|
|
|
|
|
|
=head1 METHODS |
|
43
|
|
|
|
|
|
|
=cut |
|
44
|
|
|
|
|
|
|
#_} |
|
45
|
|
|
|
|
|
|
sub new { #_{ |
|
46
|
|
|
|
|
|
|
#_{ POD |
|
47
|
|
|
|
|
|
|
=head2 new |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $score = Csound::Score->new(); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
#_} |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
55
|
|
|
|
|
|
|
# my $params = shift // {}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $self = {}; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
bless $self, $class; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# $self->{orchestra} = Csound::Orchestra->new(); |
|
62
|
0
|
|
|
|
|
|
$self->{i_stmts} = []; |
|
63
|
0
|
|
|
|
|
|
$self->{f_stmts} = {}; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $self; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} #_} |
|
68
|
|
|
|
|
|
|
sub play { #_{ |
|
69
|
|
|
|
|
|
|
#_{ POD |
|
70
|
|
|
|
|
|
|
=head2 play |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $instr = Csound::Instrument->new(…) |
|
73
|
|
|
|
|
|
|
… |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$orchestra->play($instr, $t_start, $t_len, "c♯3"); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
|
78
|
|
|
|
|
|
|
#_} |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
81
|
0
|
|
|
|
|
|
my $instr = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $t_start = shift; |
|
84
|
0
|
|
|
|
|
|
my $t_len = shift; |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
if ($instr->plays_note()) { #_{ |
|
87
|
0
|
|
|
|
|
|
my $note = $_[0]; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
croak 'instrument plays a note, but none was given' unless defined $note; |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
croak "instrument plays a note, but $note is none" unless Csound::is_note($note); |
|
92
|
|
|
|
|
|
|
} #_} |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
die unless $self->isa('Csound::Score'); |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
croak "First argument is not an instrument" unless $instr->isa('Csound::Instrument'); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# $self->{orchestra}->use_instrument($instr); |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my $i; |
|
101
|
0
|
0
|
|
|
|
|
if ($instr->plays_note) { |
|
102
|
0
|
|
|
|
|
|
my $note = shift; |
|
103
|
0
|
0
|
|
|
|
|
croak "Instrument plays notes, but $note is not a note" unless Csound::is_note($note); |
|
104
|
0
|
|
|
|
|
|
my $pch = Csound::note_to_pch($note); |
|
105
|
0
|
|
|
|
|
|
$i = $instr->i($t_start, $t_len, $pch, @_); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
else { |
|
108
|
0
|
|
|
|
|
|
$i = $instr->i($t_start, $t_len, @_); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
die "i is not an Csound::ScoreStatement::i" unless $i->isa('Csound::ScoreStatement::i'); |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
push @{$self->{i_stmts}}, $i; |
|
|
0
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return $self; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} #_} |
|
118
|
|
|
|
|
|
|
sub f { #_{ |
|
119
|
|
|
|
|
|
|
#_{ POD |
|
120
|
|
|
|
|
|
|
=head2 f |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Create a L<< Csound::ScoreStatement::f >>. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Probably called from L<< Csound::Instrument/orchestra_text >> |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
|
127
|
|
|
|
|
|
|
#_} |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
my @f_parameters = @_; |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
croak unless $self->isa('Csound::Score'); |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my $f_key =join '/', @f_parameters; |
|
137
|
0
|
0
|
|
|
|
|
if (exists $self->{f_stmts}{$f_key}) { |
|
138
|
0
|
|
|
|
|
|
return $self->{f_stmts}{$f_key}; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
$self->{f_stmts}{$f_key} = Csound::ScoreStatement::f->new(@f_parameters); |
|
142
|
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
return $self->{f_stmts}{$f_key}; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
} #_} |
|
146
|
|
|
|
|
|
|
sub t { #_{ |
|
147
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
148
|
0
|
|
|
|
|
|
my $t = shift; |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
0
|
|
|
|
|
croak "need Csound::ScoreStatement::t" unless $t->isa('Csound::ScoreStatement::t'); |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
$self->{t} = $t; |
|
153
|
|
|
|
|
|
|
} #_} |
|
154
|
|
|
|
|
|
|
sub write { #_{ |
|
155
|
|
|
|
|
|
|
#_{ POD |
|
156
|
|
|
|
|
|
|
=head2 write |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
$score->write('filename'); |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Writes C and C. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
C is written by calling C<< $self->{orchestra}->write("$filename.orc") >> which |
|
163
|
|
|
|
|
|
|
in turn is called by C<< $composition -> write($filename) >>. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
|
167
|
|
|
|
|
|
|
#_} |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
170
|
0
|
|
|
|
|
|
my $filename = shift; |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
0
|
|
|
|
|
open (my $sco_fh, '>', "$filename.sco") or croak "Could not open $filename.sco"; |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
$self->_write_f_statements($sco_fh); |
|
176
|
0
|
|
|
|
|
|
print $sco_fh "\n"; |
|
177
|
|
|
|
|
|
|
|
|
178
|
0
|
0
|
|
|
|
|
if ($self->{t}) { |
|
179
|
0
|
|
|
|
|
|
print $sco_fh $self->{t}->score_text, "\n"; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
$self->_write_i_statements($sco_fh); |
|
183
|
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
print $sco_fh "\ne\n"; |
|
185
|
0
|
|
|
|
|
|
close $sco_fh; |
|
186
|
|
|
|
|
|
|
} #_} |
|
187
|
|
|
|
|
|
|
sub _write_f_statements { #_{ |
|
188
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
189
|
0
|
|
|
|
|
|
my $fh = shift; |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
for my $f_key (sort {$self->{f_stmts}{$a}->{table_nr} <=> $self->{f_stmts}{$b}->{table_nr}} keys %{$self->{f_stmts}}) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
print $fh $self->{f_stmts}{$f_key}->score_text(), "\n"; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
} #_} |
|
195
|
|
|
|
|
|
|
sub _write_i_statements { #_{ |
|
196
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
197
|
0
|
|
|
|
|
|
my $fh = shift; |
|
198
|
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
for my $i (@{$self->{i_stmts}}) { |
|
|
0
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
print $fh $i->score_text(), "\n"; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
} #_} |
|
203
|
|
|
|
|
|
|
#_} |
|
204
|
|
|
|
|
|
|
#_{ POD: Copyright |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 Copyright |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved. |
|
209
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
210
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
|
211
|
|
|
|
|
|
|
copy of the full license at: L |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
#_} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
'tq84'; |