LoginSignup
5
3

More than 5 years have passed since last update.

GitBookに楽譜(MusicXML)を埋め込む

Last updated at Posted at 2018-05-15

Screen Shot 2018-05-15 at 12.49.57.png

GitBookMusicXML を埋め込むというのを試してみたので紹介。

MusicXMLFinaleSibeliusなどのミュージックノーテーションソフトなら大体対応しているフォーマットなので、MusicXMLGitBookでそのまま扱えれば楽譜ファイルはMusicXMLだけ管理すればいいことになるので非常によさそうです。

設定

難しいことは特にする必要がなく、gitbook-plugin-musicxml というプラグインがあるので、インストールするだけです。

boook.jsonpluginsmusicxml を追加。

{
  "plugins": ["musicxml"]
}

インストールを実行

$ gitbook install

使い方

書式はこのような感じです。

{% musicxml %}xmlファイルのパスを指定{% endmusicxml %}

パスはrootからの相対パスで指定します。

GitBookディレクトリ/assets/musicxml/myscore.xml にファイルがあれば、
{% musicxml %}assets/musicxml/myscore.xml{% endmusicxml %} という感じです。

実際に作ってみるとこんな感じになります。

README.md
# MusicXML with GitBook

MusicXML を GitBook で表示させるとこのようになります。

{% musicxml %}assets/musicxml/myscore.xml{% endmusicxml %}

カンタンですね。
assets/musicxml/myscore.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.1">
  <work>
    <work-number>UWV. 911</work-number>
    <work-title>just Do it.</work-title>
  </work>
  <part-list>
    <score-part id="P1">
      <part-name>pf</part-name>
    </score-part>
  </part-list>
  <part id="P1">
    <measure number="1">
      <attributes>
        <divisions>1</divisions>
        <key>
          <fifths>0</fifths>
        </key>
        <time>
          <beats>4</beats>
          <beat-type>4</beat-type>
        </time>
        <clef>
          <sign>G</sign>
          <line>2</line>
        </clef>
      </attributes>
      <note>
        <pitch>
          <step>C</step>
          <octave>4</octave>
        </pitch>
        <duration>4</duration>
        <type>whole</type>
      </note>
    </measure>
  </part>
</score-partwise>

$ gitbook serve して http://localhost:4000 をひらくと

Screen Shot 2018-05-15 at 12.49.57.png

うまくいきました。

やってみて分かったのですが、現在はPDFePubmobiなどの出力には対応していません(対応する気配はなさそう)。

Screen Shot 2018-05-15 at 13.03.20.png

↑このように何もなかったことのようになる。

最近のミュージックノーテーションソフトならSVG出力に対応しているので、PDFなどに出力したい場合はSVGファイルを埋め込むのが良さそうかなという感じです。
ただ、やはり楽譜ファイルと画像ファイル両方を管理しないといけないと言うのはスマートじゃないですよね。

なにか良い方法を知っている方は教えてくださると嬉しいです。

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3