1 |
iwai |
1.4 |
|
2 |
|
|
=encoding euc-jp |
3 |
|
|
|
4 |
makamaka |
1.1 |
=head1 NAME |
5 |
|
|
|
6 |
|
|
MIDI::Score - MIDI scores |
7 |
|
|
|
8 |
makamaka |
1.2 |
MIDI::Score - MIDIスコア |
9 |
makamaka |
1.1 |
|
10 |
makamaka |
1.2 |
=head1 概要 |
11 |
makamaka |
1.1 |
|
12 |
makamaka |
1.3 |
# 話せば長くなるので、下をみよ。 |
13 |
makamaka |
1.2 |
|
14 |
|
|
=head1 説明 |
15 |
makamaka |
1.1 |
|
16 |
|
|
This module provides functions to do with with MIDI scores. |
17 |
|
|
It is used as the basis for all the functions in MIDI::Simple. |
18 |
|
|
(Incidentally, MIDI::Opus's draw() method also uses some of the |
19 |
|
|
functions in here.) |
20 |
|
|
|
21 |
makamaka |
1.2 |
このモジュールはMIDIスコアを扱うための機能を提供する。 |
22 |
|
|
MIDI::Simpleの全ての機能の基として利用されている。 |
23 |
makamaka |
1.3 |
ちなみに、MIDI::Opusのdraw()メソッドもこのモジュールの機能の |
24 |
|
|
一部を利用している。 |
25 |
makamaka |
1.2 |
|
26 |
makamaka |
1.1 |
Whereas the events in a MIDI event structure are items whose timing |
27 |
|
|
is expressed in delta-times, the timing of items in a score is |
28 |
|
|
expressed as an absolute number of ticks from the track's start time. |
29 |
|
|
Moreover, pairs of 'note_on' and 'note_off' events in an event structure |
30 |
|
|
are abstracted into a single 'note' item in a score structure. |
31 |
|
|
|
32 |
makamaka |
1.3 |
MIDIイベント構造体の中に入っている各イベントは、デルタタイムで表される |
33 |
|
|
時間間隔を持った要素である。これに対してスコアの中の要素が持つ時間間隔は、 |
34 |
|
|
そのトラックの開始時間から計ったティックの絶対値として表現される。 |
35 |
|
|
さらに、イベント構造内で対になっているノートオン('note_on')と |
36 |
|
|
ノートオフ('note_off')は、スコアの中では単体のノート('note')へと |
37 |
|
|
抽象化される。 |
38 |
makamaka |
1.2 |
|
39 |
makamaka |
1.1 |
'note' takes the following form: |
40 |
|
|
|
41 |
makamaka |
1.3 |
ノート('note')は次の形式をとる: |
42 |
makamaka |
1.2 |
|
43 |
makamaka |
1.3 |
('note', I<start_time>, I<duration>, I<channel>, I<note>, I<velocity>) |
44 |
makamaka |
1.1 |
|
45 |
|
|
The problem that score structures are meant to solve is that 1) |
46 |
|
|
people definitely don't think in delta-times -- they think in absolute |
47 |
|
|
times or in structures based on that (like 'time from start of measure'); |
48 |
|
|
2) people think in notes, not note_on and note_off events. |
49 |
|
|
|
50 |
makamaka |
1.3 |
スコア構造体によって次の問題が解決する。 |
51 |
|
|
(1)人々は明らかにデルタタイムでは考えない。絶対時間か、上に述べた |
52 |
|
|
ような構造(スタートからの時間)でもって考える。 |
53 |
|
|
(2)人々はノート(音符)で考えるのであって、ノートオンやノートオフで |
54 |
|
|
ではない。 |
55 |
makamaka |
1.2 |
|
56 |
makamaka |
1.1 |
So, given this event structure: |
57 |
|
|
|
58 |
makamaka |
1.3 |
そこで、次のようなイベント構造体があるとする: |
59 |
makamaka |
1.2 |
|
60 |
makamaka |
1.1 |
['text_event', 0, 'www.ely.anglican.org/parishes/camgsm/chimes.html'], |
61 |
|
|
['text_event', 0, 'Lord through this hour/ be Thou our guide'], |
62 |
|
|
['text_event', 0, 'so, by Thy power/ no foot shall slide'], |
63 |
|
|
['patch_change', 0, 1, 8], |
64 |
|
|
['note_on', 0, 1, 25, 96], |
65 |
|
|
['note_off', 96, 0, 1, 0], |
66 |
|
|
['note_on', 0, 1, 29, 96], |
67 |
|
|
['note_off', 96, 0, 1, 0], |
68 |
|
|
['note_on', 0, 1, 27, 96], |
69 |
|
|
['note_off', 96, 0, 1, 0], |
70 |
|
|
['note_on', 0, 1, 20, 96], |
71 |
|
|
['note_off', 192, 0, 1, 0], |
72 |
|
|
['note_on', 0, 1, 25, 96], |
73 |
|
|
['note_off', 96, 0, 1, 0], |
74 |
|
|
['note_on', 0, 1, 27, 96], |
75 |
|
|
['note_off', 96, 0, 1, 0], |
76 |
|
|
['note_on', 0, 1, 29, 96], |
77 |
|
|
['note_off', 96, 0, 1, 0], |
78 |
|
|
['note_on', 0, 1, 25, 96], |
79 |
|
|
['note_off', 192, 0, 1, 0], |
80 |
|
|
['note_on', 0, 1, 29, 96], |
81 |
|
|
['note_off', 96, 0, 1, 0], |
82 |
|
|
['note_on', 0, 1, 25, 96], |
83 |
|
|
['note_off', 96, 0, 1, 0], |
84 |
|
|
['note_on', 0, 1, 27, 96], |
85 |
|
|
['note_off', 96, 0, 1, 0], |
86 |
|
|
['note_on', 0, 1, 20, 96], |
87 |
|
|
['note_off', 192, 0, 1, 0], |
88 |
|
|
['note_on', 0, 1, 20, 96], |
89 |
|
|
['note_off', 96, 0, 1, 0], |
90 |
|
|
['note_on', 0, 1, 27, 96], |
91 |
|
|
['note_off', 96, 0, 1, 0], |
92 |
|
|
['note_on', 0, 1, 29, 96], |
93 |
|
|
['note_off', 96, 0, 1, 0], |
94 |
|
|
['note_on', 0, 1, 25, 96], |
95 |
|
|
['note_off', 192, 0, 1, 0], |
96 |
|
|
|
97 |
|
|
here is the corresponding score sctructure: |
98 |
|
|
|
99 |
makamaka |
1.3 |
これに対応するスコア構造体は: |
100 |
makamaka |
1.2 |
|
101 |
makamaka |
1.1 |
['text_event', 0, 'www.ely.anglican.org/parishes/camgsm/chimes.html'], |
102 |
|
|
['text_event', 0, 'Lord through this hour/ be Thou our guide'], |
103 |
|
|
['text_event', 0, 'so, by Thy power/ no foot shall slide'], |
104 |
|
|
['patch_change', 0, 1, 8], |
105 |
|
|
['note', 0, 96, 1, 25, 96], |
106 |
|
|
['note', 96, 96, 1, 29, 96], |
107 |
|
|
['note', 192, 96, 1, 27, 96], |
108 |
|
|
['note', 288, 192, 1, 20, 96], |
109 |
|
|
['note', 480, 96, 1, 25, 96], |
110 |
|
|
['note', 576, 96, 1, 27, 96], |
111 |
|
|
['note', 672, 96, 1, 29, 96], |
112 |
|
|
['note', 768, 192, 1, 25, 96], |
113 |
|
|
['note', 960, 96, 1, 29, 96], |
114 |
|
|
['note', 1056, 96, 1, 25, 96], |
115 |
|
|
['note', 1152, 96, 1, 27, 96], |
116 |
|
|
['note', 1248, 192, 1, 20, 96], |
117 |
|
|
['note', 1440, 96, 1, 20, 96], |
118 |
|
|
['note', 1536, 96, 1, 27, 96], |
119 |
|
|
['note', 1632, 96, 1, 29, 96], |
120 |
|
|
['note', 1728, 192, 1, 25, 96] |
121 |
|
|
|
122 |
|
|
Note also that scores aren't crucially ordered. So this: |
123 |
|
|
|
124 |
makamaka |
1.2 |
スコアは厳密に順番に並んでいるわけではない。だから: |
125 |
|
|
|
126 |
makamaka |
1.1 |
['note', 768, 192, 1, 25, 96], |
127 |
|
|
['note', 960, 96, 1, 29, 96], |
128 |
|
|
['note', 1056, 96, 1, 25, 96], |
129 |
|
|
|
130 |
|
|
means the same thing as: |
131 |
|
|
|
132 |
makamaka |
1.2 |
これは次のものと同じだ: |
133 |
|
|
|
134 |
makamaka |
1.1 |
['note', 960, 96, 1, 29, 96], |
135 |
|
|
['note', 768, 192, 1, 25, 96], |
136 |
|
|
['note', 1056, 96, 1, 25, 96], |
137 |
|
|
|
138 |
|
|
The only exception to this is in the case of things like: |
139 |
|
|
|
140 |
makamaka |
1.2 |
この唯一の例外は、次のようなケースの時だ: |
141 |
|
|
|
142 |
makamaka |
1.1 |
['patch_change', 200, 2, 15], |
143 |
|
|
['note', 200, 96, 2, 25, 96], |
144 |
|
|
|
145 |
|
|
where two (or more) score items happen I<at the same time> and where one |
146 |
|
|
affects the meaning of the other. |
147 |
|
|
|
148 |
makamaka |
1.3 |
二つ以上のスコア要素が同時に発生し、かつ、一つが他方の意味に |
149 |
|
|
影響を与える場合。 |
150 |
makamaka |
1.2 |
|
151 |
|
|
|
152 |
|
|
=head1 スコアの中に何があるのか |
153 |
makamaka |
1.1 |
|
154 |
|
|
Besides the new score structure item C<note> (covered above), |
155 |
|
|
the possible contents of a score structure can be summarized thus: |
156 |
|
|
Whatever can appear in an event structure can appear in a score |
157 |
|
|
structure, save that its second parameter denotes not a |
158 |
|
|
delta-time in ticks, but instead denotes the absolute number of ticks |
159 |
|
|
from the start of the track. |
160 |
|
|
|
161 |
makamaka |
1.2 |
(先に述べた)C<note>以外に、スコア構造体が持ちうる構成要素をもとめると: |
162 |
makamaka |
1.3 |
イベント構造体に現れるものは何でもスコア構造体に現れうるということだ。 |
163 |
makamaka |
1.2 |
要素が保持する第二パラメータはティックで表現されるデルタタイムではなく、 |
164 |
|
|
トラック開始からの絶対的なティックの数を意味している。 |
165 |
|
|
|
166 |
makamaka |
1.1 |
To avoid the long periphrase "items in a score structure", I will |
167 |
|
|
occasionally refer to items in a score structure as "notes", whether or |
168 |
|
|
not they are actually C<note> commands. This leaves "event" to |
169 |
|
|
unambiguously denote items in an event structure. |
170 |
|
|
|
171 |
makamaka |
1.3 |
「スコア構造体の要素」などという回りくどい言い方は避けたいので、 |
172 |
|
|
私はしばしばこれをノート("notes")と呼ぶ。それが本当にC<note>コマンド |
173 |
|
|
なのかどうかとは関係ない。"event"の方は、明確にイベント構造体の要素を |
174 |
|
|
意味するよう、そのままにしておく。 |
175 |
makamaka |
1.2 |
|
176 |
makamaka |
1.1 |
These, below, are all the items that can appear in a score. |
177 |
|
|
This is basically just a repetition of the table in |
178 |
|
|
L<MIDI::Event>, with starttime substituting for dtime -- |
179 |
|
|
so refer to L<MIDI::Event> for an explanation of what the data types |
180 |
|
|
(like "velocity" or "pitch_wheel"). |
181 |
|
|
As far as order, the first items are generally the most important: |
182 |
|
|
|
183 |
makamaka |
1.2 |
以下はスコアに登場する全項目である。 |
184 |
makamaka |
1.3 |
基本的にL<MIDI::Event>にあった表の繰り返しでしかない。デルタタイムの |
185 |
|
|
代わりにスタート時からのタイムに置き換わってはいるが。だから、 |
186 |
|
|
データタイプ("velocity"や"pitch_wheel"など)の説明はL<MIDI::Event>を |
187 |
|
|
参照して欲しい。順番に限っていえば、一般的に最初のほうに出てくるものが |
188 |
|
|
最も重要である。 |
189 |
makamaka |
1.2 |
|
190 |
makamaka |
1.1 |
=over |
191 |
|
|
|
192 |
|
|
=item ('note', I<starttime>, I<duration>, I<channel>, I<note>, I<velocity>) |
193 |
|
|
|
194 |
|
|
=item ('key_after_touch', I<starttime>, I<channel>, I<note>, I<velocity>) |
195 |
|
|
|
196 |
|
|
=item ('control_change', I<starttime>, I<channel>, I<controller(0-127)>, I<value(0-127)>) |
197 |
|
|
|
198 |
|
|
=item ('patch_change', I<starttime>, I<channel>, I<patch>) |
199 |
|
|
|
200 |
|
|
=item ('channel_after_touch', I<starttime>, I<channel>, I<velocity>) |
201 |
|
|
|
202 |
|
|
=item ('pitch_wheel_change', I<starttime>, I<channel>, I<pitch_wheel>) |
203 |
|
|
|
204 |
|
|
=item ('set_sequence_number', I<starttime>, I<sequence>) |
205 |
|
|
|
206 |
|
|
=item ('text_event', I<starttime>, I<text>) |
207 |
|
|
|
208 |
|
|
=item ('copyright_text_event', I<starttime>, I<text>) |
209 |
|
|
|
210 |
|
|
=item ('track_name', I<starttime>, I<text>) |
211 |
|
|
|
212 |
|
|
=item ('instrument_name', I<starttime>, I<text>) |
213 |
|
|
|
214 |
|
|
=item ('lyric', I<starttime>, I<text>) |
215 |
|
|
|
216 |
|
|
=item ('marker', I<starttime>, I<text>) |
217 |
|
|
|
218 |
|
|
=item ('cue_point', I<starttime>, I<text>) |
219 |
|
|
|
220 |
|
|
=item ('text_event_08', I<starttime>, I<text>) |
221 |
|
|
|
222 |
|
|
=item ('text_event_09', I<starttime>, I<text>) |
223 |
|
|
|
224 |
|
|
=item ('text_event_0a', I<starttime>, I<text>) |
225 |
|
|
|
226 |
|
|
=item ('text_event_0b', I<starttime>, I<text>) |
227 |
|
|
|
228 |
|
|
=item ('text_event_0c', I<starttime>, I<text>) |
229 |
|
|
|
230 |
|
|
=item ('text_event_0d', I<starttime>, I<text>) |
231 |
|
|
|
232 |
|
|
=item ('text_event_0e', I<starttime>, I<text>) |
233 |
|
|
|
234 |
|
|
=item ('text_event_0f', I<starttime>, I<text>) |
235 |
|
|
|
236 |
|
|
=item ('end_track', I<starttime>) |
237 |
|
|
|
238 |
|
|
=item ('set_tempo', I<starttime>, I<tempo>) |
239 |
|
|
|
240 |
|
|
=item ('smpte_offset', I<starttime>, I<hr>, I<mn>, I<se>, I<fr>, I<ff>) |
241 |
|
|
|
242 |
|
|
=item ('time_signature', I<starttime>, I<nn>, I<dd>, I<cc>, I<bb>) |
243 |
|
|
|
244 |
|
|
=item ('key_signature', I<starttime>, I<sf>, I<mi>) |
245 |
|
|
|
246 |
|
|
=item ('sequencer_specific', I<starttime>, I<raw>) |
247 |
|
|
|
248 |
|
|
=item ('raw_meta_event', I<starttime>, I<command>(0-255), I<raw>) |
249 |
|
|
|
250 |
|
|
=item ('sysex_f0', I<starttime>, I<raw>) |
251 |
|
|
|
252 |
|
|
=item ('sysex_f7', I<starttime>, I<raw>) |
253 |
|
|
|
254 |
|
|
=item ('song_position', I<starttime>) |
255 |
|
|
|
256 |
|
|
=item ('song_select', I<starttime>, I<song_number>) |
257 |
|
|
|
258 |
|
|
=item ('tune_request', I<starttime>) |
259 |
|
|
|
260 |
|
|
=item ('raw_data', I<starttime>, I<raw>) |
261 |
|
|
|
262 |
|
|
=back |
263 |
|
|
|
264 |
|
|
|
265 |
makamaka |
1.2 |
=head1 関数 |
266 |
makamaka |
1.1 |
|
267 |
|
|
This module provides these functions: |
268 |
|
|
|
269 |
makamaka |
1.2 |
このモジュールは以下の関数を提供する: |
270 |
|
|
|
271 |
makamaka |
1.1 |
=over |
272 |
|
|
|
273 |
|
|
=item $score2_r = MIDI::Score::copy_structure($score_r) |
274 |
|
|
|
275 |
|
|
This takes a I<reference> to a score structure, and returns a |
276 |
|
|
I<reference> to a copy of it. Example usage: |
277 |
|
|
|
278 |
makamaka |
1.2 |
この関数はスコア構造体へのリファレンスを引数にとり、そのコピーへの |
279 |
|
|
リファレンスを返す。例えば: |
280 |
|
|
|
281 |
makamaka |
1.1 |
@new_score = @{ MIDI::Score::copy_structure( \@old_score ) }; |
282 |
|
|
|
283 |
|
|
=item $events_r = MIDI::Score::score_r_to_events_r( $score_r ) |
284 |
|
|
|
285 |
|
|
=item ($events_r, $ticks) = MIDI::Score::score_r_to_events_r( $score_r ) |
286 |
|
|
|
287 |
|
|
This takes a I<reference> to a score structure, and converts it to an |
288 |
|
|
event structure, which it returns a I<reference> to. In list context, |
289 |
|
|
also returns a second value, a count of the number of ticks that |
290 |
|
|
structure takes to play (i.e., the end-time of the temporally last |
291 |
|
|
item). |
292 |
|
|
|
293 |
makamaka |
1.3 |
この関数はスコア構造体へのリファレンスを引数にとってイベント構造体に |
294 |
|
|
変換し、そのリファレンスを返す。リストコンテキストでは、二つ目の値も |
295 |
|
|
返す。これはその構造体が演奏に要するティックの総数(時間的に最後の |
296 |
|
|
項目の終了時間)である。 |
297 |
makamaka |
1.2 |
|
298 |
makamaka |
1.1 |
=item $score2_r = MIDI::Score::sort_score_r( $score_r) |
299 |
|
|
|
300 |
|
|
This takes a I<reference> to a score structure, and returns a |
301 |
|
|
I<reference> to a sorted (by time) copy of it. Example usage: |
302 |
|
|
|
303 |
makamaka |
1.3 |
この関数はスコア構造体へのリファレンスを引数にとり、(時間によって) |
304 |
|
|
ソートされたコピーへのリファレンスを返す。例えば: |
305 |
makamaka |
1.2 |
|
306 |
makamaka |
1.1 |
@sorted_score = @{ MIDI::Score::sort_score_r( \@old_score ) }; |
307 |
|
|
|
308 |
|
|
=item $score_r = MIDI::Score::events_r_to_score_r( $events_r ) |
309 |
|
|
|
310 |
|
|
=item ($score_r, $ticks) = MIDI::Score::events_r_to_score_r( $events_r ) |
311 |
|
|
|
312 |
|
|
This takes a I<reference> to an event structure, converts it to a |
313 |
|
|
score structure, which it returns a I<reference> to. If called in |
314 |
|
|
list context, also returns a count of the number of ticks that |
315 |
|
|
structure takes to play (i.e., the end-time of the temporally last |
316 |
|
|
item). |
317 |
|
|
|
318 |
makamaka |
1.3 |
この関数はイベント構造体へのリファレンスを引数にとってスコア構造体に |
319 |
|
|
変換し、そのリファレンスを返す。リストコンテキストでこの関数を |
320 |
|
|
呼び出すと、その構造体が演奏に要するティックの総数(時間的に最後の項目の |
321 |
|
|
終了時間)を返す。 |
322 |
makamaka |
1.2 |
|
323 |
makamaka |
1.1 |
=item $ticks = MIDI::Score::score_r_time( $score_r ) |
324 |
|
|
|
325 |
|
|
This takes a I<reference> to a score structure, and returns |
326 |
|
|
a count of the number of ticks that structure takes to play |
327 |
|
|
(i.e., the end-time of the temporally last item). |
328 |
|
|
|
329 |
makamaka |
1.2 |
この関数はスコア構造体へのリファレンスを引数にとり、その構造体が |
330 |
|
|
演奏に要するティックの総数(時間的に最後の項目の終了時間)を返す。 |
331 |
|
|
|
332 |
makamaka |
1.1 |
=item MIDI::Score::dump_score( $score_r ) |
333 |
|
|
|
334 |
|
|
This dumps (via C<print>) a text representation of the contents of |
335 |
|
|
the event structure you pass a reference to. |
336 |
|
|
|
337 |
makamaka |
1.3 |
この関数は(C<print>を通じて)リファレンス先のイベント構造体 |
338 |
|
|
[訳補足:スコア構造体の間違い?]の中身をテキスト表記でダンプする。 |
339 |
makamaka |
1.2 |
|
340 |
makamaka |
1.1 |
=back |
341 |
|
|
|
342 |
makamaka |
1.2 |
=head1 著作権 |
343 |
makamaka |
1.1 |
|
344 |
|
|
Copyright (c) 1998-2002 Sean M. Burke. All rights reserved. |
345 |
|
|
|
346 |
|
|
This library is free software; you can redistribute it and/or |
347 |
|
|
modify it under the same terms as Perl itself. |
348 |
|
|
|
349 |
makamaka |
1.2 |
=head1 作者 |
350 |
makamaka |
1.1 |
|
351 |
|
|
Sean M. Burke C<sburke@cpan.org> |
352 |
|
|
|