jp.crestmuse.cmx.filewrappers
クラス MusicXMLWrapper

java.lang.Object
  上位を拡張 jp.crestmuse.cmx.filewrappers.CMXFileWrapper
      上位を拡張 jp.crestmuse.cmx.filewrappers.MusicXMLWrapper
すべての実装されたインタフェース:
FileWrapperCompatible

public class MusicXMLWrapper
extends CMXFileWrapper

The MusicXMLWrapper class wraps a MusicXML document.

MusicXMLWrapperクラスは, MusicXMLドキュメントをラップします.

MusicXMLについては, ここここなどを参照してください. 本クラスでは, PartwiseとTimewiseのうち, Partwiseのみをサポートします. また, ここの要素から情報を取り出すNodeInterfaceについては, MusicXMLのすべての要素に対応しているわけではありません.

MusicXMLWrapperオブジェクトからデータを取り出すためには, 主に2つの方法が あります. 1つは, getPartListメソッドを用いる方法です. これを用いると, Partクラスの配列が得られます. Partクラスはpart要素から情報を取り出すためのクラスです. その後, 各Partオブジェクトに対してgetMeasureListメソッドを呼び出します. そうすると, 当該part要素内のmeasure要素をラップするMeasureオブジェクトの 配列が得られます. 同様に, 各Measureオブジェクトに対してgetMusicDataListメソッドを呼び出して 当該measure要素内の要素を得ます. getMusicDataListメソッドで返されるのはMusicDataクラスの配列ですが, 実際は, その要素に合わせてNoteクラスだったりAttributeクラスだったり ForwardクラスだったりBackupクラスだったりしますので, instanceof演算子でどのクラスのインスタンスなのかを確かめた上で ダウンキャストしてすべき処理を行います. もう1つの方法は, processNotePartwiseメソッドを用いる方法です. NoteHandlerPartwiseインターフェイスを実装したクラスに 自分のしたい処理を記述して, processNotePartwiseメソッドの引数に渡すと, 上記の処理を自動的に行ってくれます.

PartwiseNoteViewとTimewiseNoteView

MusicXMLWrapperクラスでは, 各音符(Noteオブジェクト)を二分木に納めたTreeViewを 提供します. TreeViewで提供されている各種メソッドを利用することで, 指定した音(Noteオブジェクト)の次の音や同時になる他の音を探索することが可能です. 現在のバージョンでは, TreeViewは2種類提供されます. 1つがPartwiseTreeViewで, パートごとに別々の二分木を構成したものです. このTreeViewでは, backup要素を使って声部をわけてある場合に, 枝わかれするように要素が追加されていきます. これは, ある音に対して同一パート(あるいは声部内)で次の音や前の音をたどるのに 便利です. もう1つがTimewiseTreeViewで, すべてのパートの音を1つの二分木にまとめて 格納したものです. これは, ある音と同時に鳴る音をパートや声部を越えてすべて洗い出すといった場面で 便利です. また, スラーを自動的に検出し, スラーに続する音の列もTreeViewで管理します.

スラーの管理

スラーもTreeViewを利用して管理します. スラーごとにTreeViewオブジェクトが生成され, たとえば指定した音からはじまるスラーに対応するTreeViewのリストを取得するといった ことが簡単にできます. ただし, 現在のバージョンでは声部にまたがるスラーは対応しておらず, 無視されます.

バージョン:
0.21
作成者:
Tetsuro Kitahara

入れ子のクラスの概要
 class MusicXMLWrapper.Attributes
           Attributes要素から情報を取り出すためのメソッドを提供します.
 class MusicXMLWrapper.Backup
           backup要素から情報を取り出すためのメソッドを提供します. backup要素は時刻を巻き戻すために使用されます.
 class MusicXMLWrapper.BarLine
           
 class MusicXMLWrapper.Direction
           Direction要素から情報を取り出すためのメソッドを提供します.
 class MusicXMLWrapper.DirectionType
           DirectionType要素から情報を取り出すためのメソッドを提供します.
 class MusicXMLWrapper.Forward
           forward要素から情報を取り出すためのメソッドを提供します.
 class MusicXMLWrapper.Measure
           This class provides methods for getting information from a measure element.
 class MusicXMLWrapper.MusicData
           MusicXMLドキュメントの要素のうち, score.dtdでmusic-dataエンティティに 指定されているもの, 具体的には note, backup, forward, direction, attributes, harmony, figured-bass, print, sound, barline, grouping, link, bookmark をラップするクラスです.
 class MusicXMLWrapper.Notations
           notations要素内で記述される情報を取り出すためのメソッドを提供します. notations要素はnote要素の子として記述され, 主に対象となる音符になんらかの 情報を付加します.
 class MusicXMLWrapper.Note
           note要素からの情報を取り出すためのメソッドを提供します.
 class MusicXMLWrapper.Part
           This class provides methods for getting information from a "part" element.
 class MusicXMLWrapper.StartStopElement
           StartStopElementクラスは, type属性とnumber属性を持ち, type属性はstart, stop, continueのいずれか, number属性は正の整数を 値に持つ, という性質を満たす要素をラップするクラスです.
 class MusicXMLWrapper.XPathView
          XML中のノード集合を表すXPath式を利用して、MusicXMLWrapperがラップするオブジェクトを取得するためのクラスです。
 
コンストラクタの概要
MusicXMLWrapper()
           
 
メソッドの概要
protected  void analyze()
          各種処理の準備として, 内部で各種ノートビューを作成します.
 void eachnote(groovy.lang.Closure closure)
           
 void eachpart(groovy.lang.Closure closure)
           
 int getCumulativeTicks(int measure, boolean startsWithX, int ticksPerBeat)
           
 int getCumulativeTicks(int measure, int ticksPerBeat)
           
 java.util.List<MusicXMLWrapper.Attributes> getMeasureAttributesList(int partIndex)
           小節のattributeタグを取得します.
 java.lang.String getMovementTitle()
           楽曲タイトルを取得します.
 java.util.List<? extends TreeView<MusicXMLWrapper.Note>> getNoteViewsEndingWith(MusicXMLWrapper.Note note)
           
 java.util.List<? extends TreeView<MusicXMLWrapper.Note>> getNoteViewsIncluding(MusicXMLWrapper.Note note)
           
 java.util.List<? extends TreeView<MusicXMLWrapper.Note>> getNoteViewsStartingWith(MusicXMLWrapper.Note note)
           
 MusicXMLWrapper.Part[] getPartList()
           Returns the array of the parts contained in the MusicXML document.
 java.util.List<TreeView<MusicXMLWrapper.Note>> getPartwiseNoteView()
           Returns the partwise note view.
 java.util.List<? extends TreeView<MusicXMLWrapper.Note>> getSlurredNoteViews(byte number)
           
 TreeView<MusicXMLWrapper.Note> getTimewiseNoteView()
           Returns the non-partwise note view.
 MusicXMLWrapper.XPathView getXPathView()
           
 boolean hasMovementTitle()
           
 SCCXMLWrapper makeDeadpanSCCXML(int ticksPerBeat)
           
 void processNotePartwise(NoteHandlerPartwise handler)
           Repeats the same process for each of music data in the MusicXML document based on the specified handler.
 
クラス jp.crestmuse.cmx.filewrappers.CMXFileWrapper から継承されたメソッド
addChild, addChild, addChildAndText, addChildAndText, addChildAndText, addChildOf, addClassTable, addDocumentTypeTable, addLinks, addLinks, addPathFirst, addPathLast, addSibling, addSibling, addText, addText, addText, changeCurrentNode, checkFinalized, createDocument, finalizeDocument, getAbsolutePath, getDocument, getFileName, getParentPath, getPath, getTopTagAttribute, getTopTagAttributeNS, getURI, init, isFinalized, println, read, readfile, readfile, readfile, resetXPath, returnToParent, returnToPrevCurrentNode, selectNodeList, selectNodeList, selectSingleNode, selectSingleNode, setAttribute, setAttribute, setAttribute, setAttributeNS, setAttributeNS, setAttributeNS, setNamespaceContext, setTopTagAttribute, setTopTagAttributeNS, wrap, write, write, writefile, writefile, writeGZippedFile, writeGZippedFile
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

MusicXMLWrapper

public MusicXMLWrapper()
メソッドの詳細

analyze

protected void analyze()
各種処理の準備として, 内部で各種ノートビューを作成します.

オーバーライド:
クラス CMXFileWrapper 内の analyze

eachnote

public void eachnote(groovy.lang.Closure closure)
              throws javax.xml.transform.TransformerException
例外:
javax.xml.transform.TransformerException

eachpart

public void eachpart(groovy.lang.Closure closure)
              throws javax.xml.transform.TransformerException
例外:
javax.xml.transform.TransformerException

getCumulativeTicks

public int getCumulativeTicks(int measure,
                              boolean startsWithX,
                              int ticksPerBeat)

getCumulativeTicks

public int getCumulativeTicks(int measure,
                              int ticksPerBeat)

getMeasureAttributesList

public java.util.List<MusicXMLWrapper.Attributes> getMeasureAttributesList(int partIndex)

小節のattributeタグを取得します.

パラメータ:
partIndex - 声部番号(0始まり)
戻り値:

getMovementTitle

public java.lang.String getMovementTitle()

楽曲タイトルを取得します.

導入されたバージョン:
20007.8.31

getNoteViewsEndingWith

public java.util.List<? extends TreeView<MusicXMLWrapper.Note>> getNoteViewsEndingWith(MusicXMLWrapper.Note note)

getNoteViewsIncluding

public java.util.List<? extends TreeView<MusicXMLWrapper.Note>> getNoteViewsIncluding(MusicXMLWrapper.Note note)

getNoteViewsStartingWith

public java.util.List<? extends TreeView<MusicXMLWrapper.Note>> getNoteViewsStartingWith(MusicXMLWrapper.Note note)

getPartList

public MusicXMLWrapper.Part[] getPartList()

Returns the array of the parts contained in the MusicXML document.

MusicXMLドキュメントに含まれるパート(Partオブジェクト)の配列を返します.


getPartwiseNoteView

public java.util.List<TreeView<MusicXMLWrapper.Note>> getPartwiseNoteView()
                                                                   throws javax.xml.transform.TransformerException

Returns the partwise note view.

パートごとのノートビューを取得します.

例外:
javax.xml.transform.TransformerException

getSlurredNoteViews

public java.util.List<? extends TreeView<MusicXMLWrapper.Note>> getSlurredNoteViews(byte number)

getTimewiseNoteView

public TreeView<MusicXMLWrapper.Note> getTimewiseNoteView()
                                                   throws javax.xml.transform.TransformerException

Returns the non-partwise note view.

パートごとでないノートビュー(すべての音符を1つのノートビューに納めてある)を 取得します.

例外:
javax.xml.transform.TransformerException

getXPathView

public MusicXMLWrapper.XPathView getXPathView()
型パラメータ:
T -
戻り値:

hasMovementTitle

public boolean hasMovementTitle()

makeDeadpanSCCXML

public SCCXMLWrapper makeDeadpanSCCXML(int ticksPerBeat)
                                throws java.io.IOException
例外:
java.io.IOException

processNotePartwise

public void processNotePartwise(NoteHandlerPartwise handler)

Repeats the same process for each of music data in the MusicXML document based on the specified handler.

指定されたハンドラに基づいて, MusicXMLドキュメントに含まれる各音楽要素に対して 同じ処理を繰り返します. このメソッドは基本的には以下の処理と等価です.

 or (Part part : getPartList()) {
  handler.beginPart(part, this);
  for (Measure measure : part.getMeasureList()) {
    handler.beginMeasure(measure, this);
    for (MusicData md : measure.getMusicDataList())
      handler.processMusicData(md, this);
    handler.endMeasure(measure, this);
  }
  handler.endPart(part, this);