1 |
|
|
2 |
|
=encoding euc-jp |
3 |
|
|
4 |
=head1 NAME |
=head1 NAME |
5 |
|
|
6 |
|
=begin original |
7 |
|
|
8 |
MIDI::Score - MIDI scores |
MIDI::Score - MIDI scores |
9 |
|
|
10 |
=head1 SYNOPSIS |
=end original |
11 |
|
|
12 |
|
MIDI::Score - MIDIスコア |
13 |
|
|
14 |
|
=head1 概要 |
15 |
|
|
16 |
# it's a long story; see below |
# 話せば長くなるので、下をみよ。 |
17 |
|
|
18 |
=head1 DESCRIPTION |
=head1 説明 |
19 |
|
|
20 |
|
=begin original |
21 |
|
|
22 |
This module provides functions to do with with MIDI scores. |
This module provides functions to do with with MIDI scores. |
23 |
It is used as the basis for all the functions in MIDI::Simple. |
It is used as the basis for all the functions in MIDI::Simple. |
24 |
(Incidentally, MIDI::Opus's draw() method also uses some of the |
(Incidentally, MIDI::Opus's draw() method also uses some of the |
25 |
functions in here.) |
functions in here.) |
26 |
|
|
27 |
|
=end original |
28 |
|
|
29 |
|
このモジュールはMIDIスコアを扱うための機能を提供する。 |
30 |
|
MIDI::Simpleの全ての機能の基として利用されている。 |
31 |
|
ちなみに、MIDI::Opusのdraw()メソッドもこのモジュールの機能の |
32 |
|
一部を利用している。 |
33 |
|
|
34 |
|
=begin original |
35 |
|
|
36 |
Whereas the events in a MIDI event structure are items whose timing |
Whereas the events in a MIDI event structure are items whose timing |
37 |
is expressed in delta-times, the timing of items in a score is |
is expressed in delta-times, the timing of items in a score is |
38 |
expressed as an absolute number of ticks from the track's start time. |
expressed as an absolute number of ticks from the track's start time. |
39 |
Moreover, pairs of 'note_on' and 'note_off' events in an event structure |
Moreover, pairs of 'note_on' and 'note_off' events in an event structure |
40 |
are abstracted into a single 'note' item in a score structure. |
are abstracted into a single 'note' item in a score structure. |
41 |
|
|
42 |
|
=end original |
43 |
|
|
44 |
|
MIDIイベント構造体の中に入っている各イベントは、デルタタイムで表される |
45 |
|
時間間隔を持った要素である。これに対してスコアの中の要素が持つ時間間隔は、 |
46 |
|
そのトラックの開始時間から計ったティックの絶対値として表現される。 |
47 |
|
さらに、イベント構造内で対になっているノートオン('note_on')と |
48 |
|
ノートオフ('note_off')は、スコアの中では単体のノート('note')へと |
49 |
|
抽象化される。 |
50 |
|
|
51 |
|
=begin original |
52 |
|
|
53 |
'note' takes the following form: |
'note' takes the following form: |
54 |
|
|
55 |
('note_on', I<start_time>, I<duration>, I<channel>, I<note>, I<velocity>) |
=end original |
56 |
|
|
57 |
|
ノート('note')は次の形式をとる: |
58 |
|
|
59 |
|
('note', I<start_time>, I<duration>, I<channel>, I<note>, I<velocity>) |
60 |
|
|
61 |
|
=begin original |
62 |
|
|
63 |
The problem that score structures are meant to solve is that 1) |
The problem that score structures are meant to solve is that 1) |
64 |
people definitely don't think in delta-times -- they think in absolute |
people definitely don't think in delta-times -- they think in absolute |
65 |
times or in structures based on that (like 'time from start of measure'); |
times or in structures based on that (like 'time from start of measure'); |
66 |
2) people think in notes, not note_on and note_off events. |
2) people think in notes, not note_on and note_off events. |
67 |
|
|
68 |
|
=end original |
69 |
|
|
70 |
|
スコア構造体によって次の問題が解決する。 |
71 |
|
(1)人々は明らかにデルタタイムでは考えない。絶対時間か、上に述べた |
72 |
|
ような構造(スタートからの時間)でもって考える。 |
73 |
|
(2)人々はノート(音符)で考えるのであって、ノートオンやノートオフで |
74 |
|
ではない。 |
75 |
|
|
76 |
|
=begin original |
77 |
|
|
78 |
So, given this event structure: |
So, given this event structure: |
79 |
|
|
80 |
|
=end original |
81 |
|
|
82 |
|
そこで、次のようなイベント構造体があるとする: |
83 |
|
|
84 |
['text_event', 0, 'www.ely.anglican.org/parishes/camgsm/chimes.html'], |
['text_event', 0, 'www.ely.anglican.org/parishes/camgsm/chimes.html'], |
85 |
['text_event', 0, 'Lord through this hour/ be Thou our guide'], |
['text_event', 0, 'Lord through this hour/ be Thou our guide'], |
86 |
['text_event', 0, 'so, by Thy power/ no foot shall slide'], |
['text_event', 0, 'so, by Thy power/ no foot shall slide'], |
118 |
['note_on', 0, 1, 25, 96], |
['note_on', 0, 1, 25, 96], |
119 |
['note_off', 192, 0, 1, 0], |
['note_off', 192, 0, 1, 0], |
120 |
|
|
121 |
|
=begin original |
122 |
|
|
123 |
here is the corresponding score sctructure: |
here is the corresponding score sctructure: |
124 |
|
|
125 |
|
=end original |
126 |
|
|
127 |
|
これに対応するスコア構造体は: |
128 |
|
|
129 |
['text_event', 0, 'www.ely.anglican.org/parishes/camgsm/chimes.html'], |
['text_event', 0, 'www.ely.anglican.org/parishes/camgsm/chimes.html'], |
130 |
['text_event', 0, 'Lord through this hour/ be Thou our guide'], |
['text_event', 0, 'Lord through this hour/ be Thou our guide'], |
131 |
['text_event', 0, 'so, by Thy power/ no foot shall slide'], |
['text_event', 0, 'so, by Thy power/ no foot shall slide'], |
147 |
['note', 1632, 96, 1, 29, 96], |
['note', 1632, 96, 1, 29, 96], |
148 |
['note', 1728, 192, 1, 25, 96] |
['note', 1728, 192, 1, 25, 96] |
149 |
|
|
150 |
|
=begin original |
151 |
|
|
152 |
Note also that scores aren't crucially ordered. So this: |
Note also that scores aren't crucially ordered. So this: |
153 |
|
|
154 |
|
=end original |
155 |
|
|
156 |
|
スコアは厳密に順番に並んでいるわけではない。だから: |
157 |
|
|
158 |
['note', 768, 192, 1, 25, 96], |
['note', 768, 192, 1, 25, 96], |
159 |
['note', 960, 96, 1, 29, 96], |
['note', 960, 96, 1, 29, 96], |
160 |
['note', 1056, 96, 1, 25, 96], |
['note', 1056, 96, 1, 25, 96], |
161 |
|
|
162 |
|
=begin original |
163 |
|
|
164 |
means the same thing as: |
means the same thing as: |
165 |
|
|
166 |
|
=end original |
167 |
|
|
168 |
|
これは次のものと同じだ: |
169 |
|
|
170 |
['note', 960, 96, 1, 29, 96], |
['note', 960, 96, 1, 29, 96], |
171 |
['note', 768, 192, 1, 25, 96], |
['note', 768, 192, 1, 25, 96], |
172 |
['note', 1056, 96, 1, 25, 96], |
['note', 1056, 96, 1, 25, 96], |
173 |
|
|
174 |
|
=begin original |
175 |
|
|
176 |
The only exception to this is in the case of things like: |
The only exception to this is in the case of things like: |
177 |
|
|
178 |
|
=end original |
179 |
|
|
180 |
|
この唯一の例外は、次のようなケースの時だ: |
181 |
|
|
182 |
['patch_change', 200, 2, 15], |
['patch_change', 200, 2, 15], |
183 |
['note', 200, 96, 2, 25, 96], |
['note', 200, 96, 2, 25, 96], |
184 |
|
|
185 |
|
=begin original |
186 |
|
|
187 |
where two (or more) score items happen I<at the same time> and where one |
where two (or more) score items happen I<at the same time> and where one |
188 |
affects the meaning of the other. |
affects the meaning of the other. |
189 |
|
|
190 |
=head1 WHAT CAN BE IN A SCORE |
=end original |
191 |
|
|
192 |
|
二つ以上のスコア要素が同時に発生し、かつ、一つが他方の意味に |
193 |
|
影響を与える場合。 |
194 |
|
|
195 |
|
|
196 |
|
=head1 スコアの中に何があるのか |
197 |
|
|
198 |
|
=begin original |
199 |
|
|
200 |
Besides the new score structure item C<note> (covered above), |
Besides the new score structure item C<note> (covered above), |
201 |
the possible contents of a score structure can be summarized thus: |
the possible contents of a score structure can be summarized thus: |
204 |
delta-time in ticks, but instead denotes the absolute number of ticks |
delta-time in ticks, but instead denotes the absolute number of ticks |
205 |
from the start of the track. |
from the start of the track. |
206 |
|
|
207 |
|
=end original |
208 |
|
|
209 |
|
(先に述べた)C<note>以外に、スコア構造体が持ちうる構成要素をもとめると: |
210 |
|
イベント構造体に現れるものは何でもスコア構造体に現れうるということだ。 |
211 |
|
要素が保持する第二パラメータはティックで表現されるデルタタイムではなく、 |
212 |
|
トラック開始からの絶対的なティックの数を意味している。 |
213 |
|
|
214 |
|
=begin original |
215 |
|
|
216 |
To avoid the long periphrase "items in a score structure", I will |
To avoid the long periphrase "items in a score structure", I will |
217 |
occasionally refer to items in a score structure as "notes", whether or |
occasionally refer to items in a score structure as "notes", whether or |
218 |
not they are actually C<note> commands. This leaves "event" to |
not they are actually C<note> commands. This leaves "event" to |
219 |
unambiguously denote items in an event structure. |
unambiguously denote items in an event structure. |
220 |
|
|
221 |
|
=end original |
222 |
|
|
223 |
|
「スコア構造体の要素」などという回りくどい言い方は避けたいので、 |
224 |
|
私はしばしばこれをノート("notes")と呼ぶ。それが本当にC<note>コマンド |
225 |
|
なのかどうかとは関係ない。"event"の方は、明確にイベント構造体の要素を |
226 |
|
意味するよう、そのままにしておく。 |
227 |
|
|
228 |
|
=begin original |
229 |
|
|
230 |
These, below, are all the items that can appear in a score. |
These, below, are all the items that can appear in a score. |
231 |
This is basically just a repetition of the table in |
This is basically just a repetition of the table in |
232 |
L<MIDI::Event>, with starttime substituting for dtime -- |
L<MIDI::Event>, with starttime substituting for dtime -- |
234 |
(like "velocity" or "pitch_wheel"). |
(like "velocity" or "pitch_wheel"). |
235 |
As far as order, the first items are generally the most important: |
As far as order, the first items are generally the most important: |
236 |
|
|
237 |
|
=end original |
238 |
|
|
239 |
|
以下はスコアに登場する全項目である。 |
240 |
|
基本的にL<MIDI::Event>にあった表の繰り返しでしかない。デルタタイムの |
241 |
|
代わりにスタート時からのタイムに置き換わってはいるが。だから、 |
242 |
|
データタイプ("velocity"や"pitch_wheel"など)の説明はL<MIDI::Event>を |
243 |
|
参照して欲しい。順番に限っていえば、一般的に最初のほうに出てくるものが |
244 |
|
最も重要である。 |
245 |
|
|
246 |
=over |
=over |
247 |
|
|
248 |
=item ('note', I<starttime>, I<duration>, I<channel>, I<note>, I<velocity>) |
=item ('note', I<starttime>, I<duration>, I<channel>, I<note>, I<velocity>) |
318 |
=back |
=back |
319 |
|
|
320 |
|
|
321 |
=head1 FUNCTIONS |
=head1 関数 |
322 |
|
|
323 |
|
=begin original |
324 |
|
|
325 |
This module provides these functions: |
This module provides these functions: |
326 |
|
|
327 |
|
=end original |
328 |
|
|
329 |
|
このモジュールは以下の関数を提供する: |
330 |
|
|
331 |
=over |
=over |
332 |
|
|
333 |
=item $score2_r = MIDI::Score::copy_structure($score_r) |
=item $score2_r = MIDI::Score::copy_structure($score_r) |
334 |
|
|
335 |
|
=begin original |
336 |
|
|
337 |
This takes a I<reference> to a score structure, and returns a |
This takes a I<reference> to a score structure, and returns a |
338 |
I<reference> to a copy of it. Example usage: |
I<reference> to a copy of it. Example usage: |
339 |
|
|
340 |
|
=end original |
341 |
|
|
342 |
|
この関数はスコア構造体へのリファレンスを引数にとり、そのコピーへの |
343 |
|
リファレンスを返す。例えば: |
344 |
|
|
345 |
@new_score = @{ MIDI::Score::copy_structure( \@old_score ) }; |
@new_score = @{ MIDI::Score::copy_structure( \@old_score ) }; |
346 |
|
|
347 |
=item $events_r = MIDI::Score::score_r_to_events_r( $score_r ) |
=item $events_r = MIDI::Score::score_r_to_events_r( $score_r ) |
348 |
|
|
349 |
=item ($events_r, $ticks) = MIDI::Score::score_r_to_events_r( $score_r ) |
=item ($events_r, $ticks) = MIDI::Score::score_r_to_events_r( $score_r ) |
350 |
|
|
351 |
|
=begin original |
352 |
|
|
353 |
This takes a I<reference> to a score structure, and converts it to an |
This takes a I<reference> to a score structure, and converts it to an |
354 |
event structure, which it returns a I<reference> to. In list context, |
event structure, which it returns a I<reference> to. In list context, |
355 |
also returns a second value, a count of the number of ticks that |
also returns a second value, a count of the number of ticks that |
356 |
structure takes to play (i.e., the end-time of the temporally last |
structure takes to play (i.e., the end-time of the temporally last |
357 |
item). |
item). |
358 |
|
|
359 |
|
=end original |
360 |
|
|
361 |
|
この関数はスコア構造体へのリファレンスを引数にとってイベント構造体に |
362 |
|
変換し、そのリファレンスを返す。リストコンテキストでは、二つ目の値も |
363 |
|
返す。これはその構造体が演奏に要するティックの総数(時間的に最後の |
364 |
|
項目の終了時間)である。 |
365 |
|
|
366 |
=item $score2_r = MIDI::Score::sort_score_r( $score_r) |
=item $score2_r = MIDI::Score::sort_score_r( $score_r) |
367 |
|
|
368 |
|
=begin original |
369 |
|
|
370 |
This takes a I<reference> to a score structure, and returns a |
This takes a I<reference> to a score structure, and returns a |
371 |
I<reference> to a sorted (by time) copy of it. Example usage: |
I<reference> to a sorted (by time) copy of it. Example usage: |
372 |
|
|
373 |
|
=end original |
374 |
|
|
375 |
|
この関数はスコア構造体へのリファレンスを引数にとり、(時間によって) |
376 |
|
ソートされたコピーへのリファレンスを返す。例えば: |
377 |
|
|
378 |
@sorted_score = @{ MIDI::Score::sort_score_r( \@old_score ) }; |
@sorted_score = @{ MIDI::Score::sort_score_r( \@old_score ) }; |
379 |
|
|
380 |
=item $score_r = MIDI::Score::events_r_to_score_r( $events_r ) |
=item $score_r = MIDI::Score::events_r_to_score_r( $events_r ) |
381 |
|
|
382 |
=item ($score_r, $ticks) = MIDI::Score::events_r_to_score_r( $events_r ) |
=item ($score_r, $ticks) = MIDI::Score::events_r_to_score_r( $events_r ) |
383 |
|
|
384 |
|
=begin original |
385 |
|
|
386 |
This takes a I<reference> to an event structure, converts it to a |
This takes a I<reference> to an event structure, converts it to a |
387 |
score structure, which it returns a I<reference> to. If called in |
score structure, which it returns a I<reference> to. If called in |
388 |
list context, also returns a count of the number of ticks that |
list context, also returns a count of the number of ticks that |
389 |
structure takes to play (i.e., the end-time of the temporally last |
structure takes to play (i.e., the end-time of the temporally last |
390 |
item). |
item). |
391 |
|
|
392 |
|
=end original |
393 |
|
|
394 |
|
この関数はイベント構造体へのリファレンスを引数にとってスコア構造体に |
395 |
|
変換し、そのリファレンスを返す。リストコンテキストでこの関数を |
396 |
|
呼び出すと、その構造体が演奏に要するティックの総数(時間的に最後の項目の |
397 |
|
終了時間)を返す。 |
398 |
|
|
399 |
=item $ticks = MIDI::Score::score_r_time( $score_r ) |
=item $ticks = MIDI::Score::score_r_time( $score_r ) |
400 |
|
|
401 |
|
=begin original |
402 |
|
|
403 |
This takes a I<reference> to a score structure, and returns |
This takes a I<reference> to a score structure, and returns |
404 |
a count of the number of ticks that structure takes to play |
a count of the number of ticks that structure takes to play |
405 |
(i.e., the end-time of the temporally last item). |
(i.e., the end-time of the temporally last item). |
406 |
|
|
407 |
|
=end original |
408 |
|
|
409 |
|
この関数はスコア構造体へのリファレンスを引数にとり、その構造体が |
410 |
|
演奏に要するティックの総数(時間的に最後の項目の終了時間)を返す。 |
411 |
|
|
412 |
=item MIDI::Score::dump_score( $score_r ) |
=item MIDI::Score::dump_score( $score_r ) |
413 |
|
|
414 |
|
=begin original |
415 |
|
|
416 |
This dumps (via C<print>) a text representation of the contents of |
This dumps (via C<print>) a text representation of the contents of |
417 |
the event structure you pass a reference to. |
the event structure you pass a reference to. |
418 |
|
|
419 |
|
=end original |
420 |
|
|
421 |
|
この関数は(C<print>を通じて)リファレンス先のイベント構造体 |
422 |
|
[訳補足:スコア構造体の間違い?]の中身をテキスト表記でダンプする。 |
423 |
|
|
424 |
=back |
=back |
425 |
|
|
426 |
=head1 COPYRIGHT |
=head1 著作権 |
427 |
|
|
428 |
Copyright (c) 1998-2002 Sean M. Burke. All rights reserved. |
Copyright (c) 1998-2002 Sean M. Burke. All rights reserved. |
429 |
|
|
430 |
This library is free software; you can redistribute it and/or |
This library is free software; you can redistribute it and/or |
431 |
modify it under the same terms as Perl itself. |
modify it under the same terms as Perl itself. |
432 |
|
|
433 |
=head1 AUTHOR |
=head1 作者 |
434 |
|
|
435 |
Sean M. Burke C<sburke@cpan.org> |
Sean M. Burke C<sburke@cpan.org> |
436 |
|
|