Csound/ScoreStatement/i.pm

filter: Statementstmt 100% 42 / 42 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 85.9% 55 / 64 CC 7 SCAR 8.9
CC
7
Cov
89%
instrument_nr
3.1
score_text
3.0
new
3.0
CRAP 2.4
« Csound/ScoreStatement/t.pm ↑ Summary Csound/ScoreStatement/f.pm »
1 #_{ Encoding and name
2 =encoding utf8
3 =head1 NAME
4  
5 Csound::ScoreStatement
6  
7 L<http://www.csounds.com/manual/html/ScoregensTop.html>
8  
9 =cut
10 #_}
11  
12 package Csound::ScoreStatement::i;
13  
14 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 # use 5.10.0; # state
17  
18 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 ▶use Csound::ScoreStatement;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 our $VERSION = $Csound::VERSION;
23 2 our @ISA = qw(Csound::ScoreStatement);
24 #_{ Synopsis
25  
26 =head1 SYNOPSIS
27  
28 use Csound::ScoreStatement::i;
29  
30 ...
31  
32 =cut
33 #_}
34 #_{ Description
35 =head DESCRIPTION
36  
37 The C<f> statement causes a so called GEN subroutine to place values in a stored function table.
38  
39 The syntax is
40  
41 f tableNumber actionTime size genRoutine …
42  
43 =cut
44 #_}
45 #_{ Methods
46 #_{
47 =head1 METHODS
48 =cut
49 #_}
50 4 ▶sub new { #_{
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
51 #_{ POD
52 =head2 new
53  
54 This method should not be called by the end user, it should be called by L<Csound::Instrument/i>.
55  
56 =cut
57 #_}
58  
59  
60 4 my $class = shift;
61  
62 4 my $instr = shift;
63 4 my $t_start = shift;
64 4 my $t_len = shift;
65 4 my @params = @_;
66  
67 4 ▶ croak "No instrument passed" unless $instr->isa('Csound::Instrument');
Branch: 1 branch
BranchTrueFalseTotal
unless $instr->isa("Csound::Instrument") 0 4 4
68  
69 4 my $self = {};
70 4 bless $self, $class;
71 4 ▶ croak unless $self->isa('Csound::ScoreStatement::i');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("Csound::ScoreStatement::i") 0 4 4
72  
73 4 $self -> {instr } = $instr;
74 4 $self -> {t_start } = $t_start;
75 4 $self -> {t_len } = $t_len;
76 4 $self -> {params } =\@params;
77  
78 4 return $self;
79  
80 } #_}
81 1 ▶sub score_text { #_{
Subroutine score_text: called CC=3 SCAR=11.1
Pod undocumented
82 #_{ POD
83 =head2 score_text
84  
85 my $txt = $i->score_text();
86  
87 Returns the text to be written into the score.
88  
89 =cut
90 #_}
91  
92  
93 1 my $self = shift;
94 1 ▶ die unless $self->isa('Csound::ScoreStatement::i');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("Csound::ScoreStatement::i") 0 1 1
95  
96 1 my $score_text = sprintf ('i%d %s %s', $self->instrument_nr(), $self->{t_start}, $self->{t_len});
97  
98 1 ▶ if (@{$self->{params}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"params"};}) 1 0 1
99  
100 1 $score_text .= ' ';
101  
102 1 $score_text .= join ' ', @{$self->{params}};
103 }
104  
105 1 return $score_text;
106  
107 } #_}
108 5 ▶sub instrument_nr { #_{
Subroutine instrument_nr: called CC=3 SCAR=11.4
Pod undocumented
109 #_{ POD
110 =head2 instrument_nr
111  
112 my $inr = $i->instrument_nr();
113  
114 Returns the number of the instrument to which this C<I statement> belongs.
115  
116 =cut
117 #_}
118  
119  
120 5 my $self = shift;
121  
122 5 ▶ croak unless $self->isa('Csound::ScoreStatement::i');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("Csound::ScoreStatement::i") 0 5 5
123  
124 5 ▶ die "\$sself->instr is not an Csound::Instrument" unless $self->{instr}->isa('Csound::Instrument');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"instr"}->isa("Csound::Instrument") 0 5 5
125  
126 5 return $self->{instr}->{nr};
127  
128 } #_}
129 #_}
130 #_{ POD: Copyright
131  
132 =head1 Copyright
133 Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved.
134 This program is free software; you can redistribute it and/or modify it
135 under the terms of the the Artistic License (2.0). You may obtain a
136 copy of the full license at: L<http://www.perlfoundation.org/artistic_license_2_0>
137 =cut
138  
139 #_}
140  
141 2 'tq84';
142  
« Csound/ScoreStatement/t.pm ↑ Summary Csound/ScoreStatement/f.pm »