=encoding euc-jp
=head1 NAME
=begin original
MIDI - read, compose, modify, and write MIDI files
=end original
MIDI - MIDIファイルの読み込み、作成、修正、書き出し
=head1 概要
use MIDI;
$chimes_track = MIDI::Track->new({ 'events' => [
['text_event',0, 'www.ely.anglican.org/parishes/camgsm/chimes.html'],
['text_event',0, 'Lord through this hour/ be Thou our guide'],
['text_event',0, 'so, by Thy power/ no foot shall slide'],
['text_event',0, '(coded at ' . scalar(localtime) . ' )'],
['patch_change', 0, 1, 8], # Patch 8 = Celesta
map( (['note_on',0,1,$_->[0],96], ['note_off',$_->[1],1,$_->[0],0]),
[25,96],[29,96],[27,96],[20,192],[25,96],[27,96],[29,96],[25,192],
[29,96],[25,96],[27,96],[20,192],[20,96],[27,96],[29,96],[25,192],
)# [Note,Duration] ==> ['note_on',0,1, N ,96], ['note_off', D ,1, N ,0]
] });
$chimes = MIDI::Opus->new(
{ 'format' => 0, 'ticks' => 96, 'tracks' => [ $chimes_track ] } );
$chimes->write_to_file('chimes.mid');
=head1 説明
=begin original
This suite of modules provides routines for reading, composing, modifying,
and writing MIDI files.
=end original
このモジュールセットは、MIDIファイルの読込・作成・修正・書出を行う
ルーチンを提供する。
=begin original
From FOLDOC (C):
=end original
FOLDOC (C) から引用:
B
=begin original
Emultimedia, file formatE (MIDI /mi'-dee/, /mee'-dee/) A
hardware specification and protocol used to communicate note and
effect information between synthesisers, computers, music keyboards,
controllers and other electronic music devices. [...]
=end original
B
Eマルチメディア、ファイルフォーマットE (MIDI 発音はミディ
あるいはミィディ) シンセサイザー、コンピューター、ミュージックキーボード、
制御装置、その他の電子音楽機器の間で、音符と効果の情報をやりとりするために
使われるハードウェアの仕様及び、プロトコルのこと。…
=begin original
The basic unit of information is a "note on/off" event which includes
a note number (pitch) and key velocity (loudness). There are many
other message types for events such as pitch bend, patch changes and
synthesizer-specific events for loading new patches etc.
=end original
情報の基本単位はノートナンバー(音階)とキーベロシティ(音の強さ)を含む
"ノート オン/オフ"イベント。それ以外にも多くのメッセージタイプがある。
ピッチベンド、パッチチェンジや、新しいパッチをロードするシンセサイザー特有の
イベント等々。
=begin original
There is a file format for expressing MIDI data which is like a dump
of data sent over a MIDI port. [...]
=end original
MIDIデータを表現するためのファイルフォーマットがある。このデータは
MIDIポートへ送られるデータダンプのようなものである。…
=head1 構成
=begin original
The MIDI-Perl suite consists of these modules:
=end original
MIDI-Perlパッケージは以下のモジュールで構成される。
=begin original
L (which you're looking at), L, L,
L, L, and
L. All of these contain documentation in pod format.
You should read all of these pods.
=end original
L (あなたが今読んでいる), L, L,
L, L, L。
これら全てのモジュールにPODドキュメントが含まれている。
全てのPODに目を通してもらいたい。
=begin original
The order you want to read them in will depend on what you want to do
with this suite of modules: if you are focused on manipulating the
guts of existing MIDI files, read the pods in the order given above.
=end original
ドキュメントを読む順番は、あなたがこのモジュールを使って何をしたいかによって
決まる。もし既存のMIDIファイルの中身を弄繰り回すことに関心があるなら、
上にあげた順番で読めばよい。
=begin original
But if you aim to compose music with this suite, read this pod, then
L and L, and then skim the rest.
=end original
だが、もしこのパッケージを使って作曲をするのが目的なら、
このドキュメントの次にLと Lを読んで欲しい。
それから残りはざっと目を通せばよい。
=begin original
(For your reference, there is also a document in pod format which is
not itself an actual module: L. It is an old version
of the MIDI file specification.)
=end original
(参考:パッケージの中にもう一つPODドキュメントがあるが、これは実際には
使われていないモジュールLのもの。これはMIDIファイル仕様の
古いバージョンだ。)
=head1 はじめに
=begin original
This suite of modules is basically object-oriented, with the exception
of MIDI::Simple. MIDI opuses ("songs") are represented as objects
belonging to the class MIDI::Opus. An opus contains tracks, which are
objects belonging to the class MIDI::Track. A track will generally
contain a list of events, where each event is a list consisting of a
command, a delta-time, and some number of parameters. In other words,
opuses and tracks are objects, and the events in a track comprise a
LoL (and if you don't know what an LoL is, you must read L).
=end original
このモジュールパッケージはMIDI::Simpleを除いて基本的にオブジェクト指向である。
MIDIのオプス(ソング)はMIDI::Opusクラスに属するオブジェクトを表す。
一つのオプスはトラックを有する。トラックはMIDI::Trackクラスに属する
オブジェクトである。トラックは一般的にイベントリストを含み、各イベントは
命令、デルタタイムや、いくつかのパラメーターで構成されたリストである。
つまり、オプスとトラックはオブジェクトで、トラック内のイベントは
LoL(リストのリスト)からなっている(もしもLoLが何なのかわからない
場合はLを読むこと)。
=begin original
Furthermore, for some purposes it's useful to analyze the totality of
a track's events as a "score" -- where a score consists of notes where
each event is a list consisting of a command, a time offset from the
start of the track, and some number of parameters. This is the level
of abstraction that MIDI::Score and MIDI::Simple deal with.
=end original
さらに、何かの目的でトラックイベント全体を"スコア"として分析すると便利だ。
スコアはノート(音符)から構成される。ノートとはイベントであり、
このイベントはコマンド、トラック開始からの時間経過、そしていくつかの
パラメータからなるリストである。
これがMIDI::ScoreとMIDI::Simpleが扱う抽象的なレベルである。
=begin original
While this suite does provide some functionality accessible only if
you're comfortable with various kinds of references, and while there
are some options that deal with the guts of MIDI encoding, you can (I
hope) get along just fine with just a basic grasp of the MIDI
"standard", and a command of LoLs. I have tried, at various points in
this documentation, to point out what things are not likely to be of
use to the casual user.
=end original
もしもあなたが様々な種類のリファレンスに満足した場合にのみ、
このパッケージは使いやすい機能を提供することになる。また、
MIDIエンコードの内幕を扱うためにいくつかの選択肢がある。
"標準"MIDIと、リストのリストを操作する基礎を理解することで
素晴らしい日々を過ごすことができるだろう(と私は望みたい)。
私はこのドキュメントの中の様々な個所で、何がひょっこりやってきた
ユーザーにとって役立つようなものではないかを指摘しようと努めてきた。
=head1 TO DO
=begin original
Maybe have a MIDI cookbook of commonly used short scripts?
=end original
MIDIは広く利用されるような便利なショートスクリプト集を持っているだろうか?
=begin original
B: Currently this suite can only read/write MIDI data from/to
MIDI I. However, it would be desirable to have realtime access
to a MIDI device -- at least on systems where a MIDI device (whether
thru a hardware port or as a virtual sequencer in a sound card) is
accessable as a virtual file (C, C,
C, or whatever). However, I have no such MIDI devices
(much less ports) at hand for development and testing. But if I
have such devices (I'm thinking a Linuxer with a synth hooked to their
MIDI port), and if you want to help me experiment with directly
accessing them from Perl, then please email me. I already have a
pretty good idea of how it should work -- but as always, the proof is
as much in the pudding as the devil is in the details.
=end original
B<いいわけ>:現在、このパッケージはMIDI I<ファイル>に対してのみ、
MIDIデータの読み書きができる。だがMIDI機器へリアルタイムにアクセス出来た
方が望ましい。少なくともMIDI機器(ハードウェアポートを通じてなのか、
サウンドカードの仮想シーケンサであるかに関係なく)がバーチャルファイル
(C、 C、Cなど)としてアクセスできる
システム上でのアクセスが。
ところが私は開発とテストに利用できるようなMIDI機器を持っていない
(いわんやポートをや)。しかしあなたがそのような機器を持っていて
(MIDIポートにフックされたシンセを持っているLinux使いの方なら
あるのではないかと思う)、かつ、Perlから直接それらの機器にアクセスする実験を
私のためにやってくれるのなら、Eメールを送って頂きたい。
私は既にいかにリアルタイムアクセスを行うかについての素晴らしいアイディアを
持っている。だが世の常で、悪は細部に宿るが如く、証拠はプディングの中に
宿っているのだ[訳補足:プディングの味は食べてみなければわからない。
実際にやってみせるしかないということを言っている]。
=head1 小物
=begin original
The bare module MIDI.pm doesn't I much more than C