Extension:Score
警告: ここで記述しているコードまたは設定には、セキュリティ上の重大なリスクがあります。 サイトの管理者へ: このセキュリティ上の問題が解決されるまで、これを使用しないように勧告します。 問題点: Vulnerable to code injection attacks, because it passes user input directly to executable statements, such as exec(), passthru() or include(). This may lead to arbitrary code being run on your server, among other things. 解決法: Strictly validate user input and/or apply escaping to all characters that have a special meaning in executable statements. |
Score リリースの状態: 不安定 |
|
---|---|
![]() |
|
実装 | タグ |
説明 | LilyPond で楽譜をレンダリングできるようにする |
作者 | Alexander Klauer, Étienne Beaulé |
最新バージョン | 0.3.0 (2019-03-23) |
MediaWiki | 1.31+ |
PHP | 5.3+ |
ライセンス | GNU 一般公衆利用許諾書 3.0 以降 |
ダウンロード | README |
|
|
score |
|
translatewiki.net で翻訳を利用できる場合は、Score 拡張機能の翻訳にご協力ください | |
問題点 | 未解決のタスク · バグを報告 |
Score 拡張機能は、LilyPond を使用して楽譜を PNG 画像としてレンダリングできるようにします。またそれらを音声ファイルや MIDI ファイルに変換することもできます。
謝辞
- オリジナルの Extension:LilyPond はJohannes E. Schindelinによって書かれました。
- この拡張機能は、Tim Starling の Extension:LilyPond のコードレビューに基づいています。
- オリジナルの Extension:ABC は River Tarnell によって書かれました。
使用法
設定の後、<score>...</score>
タグ内に簡単な LilyPond 記法をウィキテキストに埋め込むことができます。例えば:
<score>\relative c' { f d f a d f e d cis a cis e a g f e }</score>
変換結果:
一般的な形式でscoreタグに属性を指定することもできます
<score attribute1="value1" attribute2="value2">…</score>.
例えば:
<score sound="1">\relative c' { f d f a d f e d cis a cis e a g f e }</score>
変換結果:
使用できる属性は次の通りです。
属性 | 許容される値 | 効果 |
---|---|---|
lang | ABC, lilypond (default) |
Sets the score language. For example, to provide a score in ABC notation, you might use
<score lang="ABC">
X:1
M:C
L:1/4
K:C
C, D, E, F,|G, A, B, C|D E F G|A B c d|
e f g a|b c' d' e'|f' g' a' b'|]
</score>
|
midi | obsolete This used to control whether the rendered score image linked to a MIDI file. | |
override_midi | Known file name, that is, if override_midi="name" is given, [[File:name]] does not yield a red link |
(廃止予定) Instead you can add a [[File:superior midi filename.mid]] wikilink after the closing </score> tag.Uses the specified MIDI file instead of generating one with LilyPond. Use this attribute together with the midi attribute (see before) or the sound attribute (see later). This attribute is useful if you already have a MIDI file whose quality is superior to what would be generated by LilyPond. |
override_audio | Known file name, that is, if override_audio="name" is given, [[File:Name]] does not yield a red link |
(廃止予定) Instead you can add a [[File:superior audio filename.oga]] wikilink after the closing </score> tag.Embeds the media specified by the file name in the HTML after the score image(s). This is an alternative to the sound attribute (see further). It can, for example, be useful if you have a suitable audio file of superior quality compared with the auto-generated audio file. Of course, you can still omit both attributes in this case and add the file manually to the page, if you prefer. |
override_ogg | Doubly-deprecated alias for override_audio. | |
raw | 0 (default), 1 | If set to 1, the score code is interpreted as a complete LilyPond file. Use this option if you want to create more complex scores. If the score language (lang attribute) is not set to lilypond, this attribute is ignored. By default (when raw=0), provided code is wrapped in a \score{...} block, along with default \layout{...} and \midi{...} blocks, if not already provided.
|
sound | 0 (default), 1 | If set to 1, an audio file will be generated for the score, provided you installed and configured Extension:TimedMediaHandler . An audio player will be embedded in the HTML after the score image(s). |
vorbis | 0 (default), 1 | (廃止予定) Alias for sound. |
LilyPond 言語
歌詞は以下のようにして追加できます:
<score>\relative c'' { \time 4/4 \key c \major
c4 g8 g a4 g r b^> c^> r \bar "|." }
\addlyrics { Shave and a hair -- cut: two bits. }</score>
上級の利用者には\set Staff.midiInstrument
コマンドの利用でMIDI楽器を変更できます。
要件
The following packages are recommended:
- LilyPond
- Ghostscript
- ImageMagick
- FluidSynth
- Firejail
この拡張機能は LilyPond を使用してスコア画像をレンダリングするため、LilyPond をインストールする必要があります (Special:Version に LilyPond のバージョンが表示されます)。 If you install LilyPond from a package, Ghostscript will also be installed, since LilyPond depends on Ghostscript. ImageMagick should be installed to trim the images, otherwise they will contain an excessive amount of whitespace.
For security reasons, it is highly recommended to install firejail to further restrict what LilyPond and Ghostscript can do if untrusted users are allowed to edit your wiki.
拡張機能は、LilyPond によって生成された MIDI ファイルから音声ファイルを作成することもできます。この機能を利用するには、Extension:TimedMediaHandler をインストールする必要があります。
FluidSynth is the preferred method to convert MIDI files to audio files, however TiMidity++ is also supported.
インストール
- ダウンロードして、ファイルを
extensions/
フォルダー内のScore
という名前のディレクトリ内に配置します。 - 以下のコードを LocalSettings.php の末尾に追加します:
wfLoadExtension( 'Score' ); $wgScoreTrim = true; $wgImageMagickConvertCommand = '/usr/bin/convert'; $wgShellRestrictionMethod = 'firejail';
- Create a subdirectory named
lilypond
in your $wgUploadDirectory (usually the directory namedimages
in your MediaWiki directory). Make sure the directory is writable by your Web server. - 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
MediaWiki 1.26 以前を稼働させている利用者へ:
上記の手順では、wfLoadExtension()
を使用してこの拡張機能をインストールする新しい方法を記載しています。
この拡張機能をこれらの過去のバージョン (MediaWiki 1.26 以前) にインストールする必要がある場合は、wfLoadExtension( 'Score' );
の代わりに以下を使用する必要があります:
require_once "$IP/extensions/Score/Score.php";
設定
現状ではこの拡張機能に次のようなグローバルな設定パラメータがあります。
$wgScoreLilyPond
$wgScoreLilyPond
のパスを実行可能な LilyPond に設定(通常は
/usr/bin/lilypond
または/usr/local/bin/lilypond
)。
$wgScoreTrim
$wgScoreTrim
というブール値は既定で$wgUseImageMagick
の値です。true
の場合、実行結果の score PNG 画像を ImageMagick でトリミング加工できます。それが不要の場合もしくは ImageMagick をインストールしたくない場合、$wgScoreTrim
はfalse
に設定します。
$wgScoreAbc2Ly
ABC 記法の$wgScoreAbc2Ly
のパスを実行可能な LilyPond 変換機能に設定(通常は
/usr/bin/abc2ly
または/usr/local/bin/abc2ly
)。
$wgScoreFluidsynth
$wgScoreFluidsynth
のパスを実行可能な FluidSynth に設定(通常は/usr/bin/fluidsynth
または/usr/local/bin/fluidsynth
)。
$wgScoreSoundfont
$wgScoreSoundfont
をSoundFontファイルのパスに設定(通常は/usr/share/sounds/sf2/FluidR3_GM.sf2
または /usr/share/sounds/sf2/FluidR3_GS.sf2
)。
$wgScoreTimidity
$wgScoreTimidity
のパスを実行可能なTiMidity++に設定(通常は/usr/bin/timidity
または/usr/local/bin/timidity
)。
もし$wgScoreFluidsynth
がない場合は、TiMidity++ にフォールバックして実行します。
$wgScoreLame
$wgScoreTimidity
のパスを実行可能なLAMEに設定(通常は/usr/bin/lame
または/usr/local/bin/lame
)。生成する音声ファイルは必ず MP3 になるという制約があります。
注記
この拡張機能はシェル上で多種のバイナリを実行します。そのためメモリ不足のエラー発生時には、$wgMaxShellMemory の拡張が必要な場合があります。
楽譜の検索
楽譜を含むページにはページ プロパティに「score」というセットが備わっています。楽譜のあるページの検索には 特別:プロパティがあるページ を使います。(日本語版ウィキペディアでは「プロパティ名:」欄で score を選択して実行。)
関連項目
- Help:Score on English Wikipedia and Help:Sheet music on Wikisource have more examples of LilyPond syntax.
- Vexflow オープンソースの SVG/Canvas 楽譜用変換機能
- LilyPond 記法
- ABC 記法
- github 上にある vexflow リポジトリ
この拡張機能は 1 つ以上のウィキメディアのプロジェクトで使用されています。 これはおそらく、この拡張機能が安定していて高いトラフィックのウェブサイトでも十分に動作することを意味します。 この拡張機能がインストールされている場所を確認するには、ウィキメディアの設定ファイル CommonSettings.php および InitialiseSettings.php 内で、この拡張機能の名前を探してください。 特定のウィキにインストールされている拡張機能の完全な一覧は、そのウィキの Special:Version ページにあります。 |