扩展:乐谱
![]() | 警告: 此处描述的代码或配置会导致主要安全风险。 致网站管理员: 建议您不要使用它,直到此安全问题被解决为止。 问题: 易受代码注入攻击,因为它将用户输入直接传送到可执行语句,例如exec()、passthru()或include()。 这可能导致在您的服务器上运行任意代码及其他内容。 解决方案: 严格验证用户输入和/或对所有在可执行语句中有特殊意义的字符应用转义。 |
Score 发布状态: 不稳定 |
|
---|---|
![]() |
|
实现 | 标签 |
描述 | 允许通过LilyPond渲染乐谱 |
作者 | Alexander Klauer, Étienne Beaulé |
最新版本 | 0.3.0 (2019-03-23) |
MediaWiki | 1.31+ |
PHP | 5.3+ |
许可协议 | GNU通用公眾授權條款3.0或更新版本 |
下载 | README |
|
|
score |
|
翻譯Score擴充功能如在translatewiki.net可用 | |
问题 | 尚未完成的工作 · 回報錯誤 |
乐谱扩展允许你像PNG这样使用LilyPond渲染乐谱,并且可以将其转化为音频和MIDI文件。
Acknowledgements
- The original Extension:LilyPond was written by Johannes E. Schindelin.
- This extension is based on a code review of Extension:LilyPond by Tim Starling.
- The original Extension:ABC was written by River Tarnell.
用法
After setup, you can embed simple LilyPond notation into your wikitext inside a <score>...</score>
tag. For example:
<score>\relative c' { f d f a d f e d cis a cis e a g f e }</score>
yields:

You may also specify attributes to the score tags in the general form
<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>
yields:
The following attributes are available:
Attribute | Allowed values | Effect |
---|---|---|
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 扩展:TimedMediaHandler . An audio player will be embedded in the HTML after the score image(s). |
vorbis | 0 (default), 1 | (已弃用) Alias for sound. |
The LilyPond language
Lyrics may be added like this:
<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>

For advanced users, the \set Staff.midiInstrument
command can be used to change the MIDI instrument for the sound.
Prerequisites
The following packages are recommended:
- LilyPond
- Ghostscript
- ImageMagick
- FluidSynth
- Firejail
This extension uses LilyPond to render score images, so you need a working LilyPond installation (Special:Version displays the LilyPond version). 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.
The extension is also capable of creating audio files from the MIDI files generated by LilyPond. If you want to make use of this functionality, you need to have 扩展:TimedMediaHandler installed.
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. 完成 – 在您的wiki上导航至Special:Version,以验证扩展已成功安装。
致使用MediaWiki 1.26或更早版本的用户:
上面的说明介绍的是安装此扩展的新方法,它使用wfLoadExtension()
。
如果您需要在早期版本(MediaWiki 1.26和更早版本)中安装此扩展,而不是wfLoadExtension( 'Score' );
,您需要使用:
require_once "$IP/extensions/Score/Score.php";
配置
Currently, the extension has the following global configuration parameters.
$wgScoreLilyPond
Set $wgScoreLilyPond
to the path to your LilyPond executable (typically /usr/bin/lilypond
or /usr/local/bin/lilypond
).
$wgScoreTrim
The $wgScoreTrim
is a boolean which defaults to the value of $wgUseImageMagick
. If true
, the resulting score PNG images are trimmed with ImageMagick. If you don't want trimming, or don't want to install ImageMagick, set $wgScoreTrim
to false
.
$wgScoreAbc2Ly
Set $wgScoreAbc2Ly
to the path of your ABC to LilyPond converter executable (typically /usr/bin/abc2ly
or /usr/local/bin/abc2ly
).
$wgScoreFluidsynth
Set $wgScoreFluidsynth
to the path of your Fluidsynth executable (typically /usr/bin/fluidsynth
or /usr/local/bin/fluidsynth
).
$wgScoreSoundfont
Set $wgScoreSoundfont
to the path of your soundfont file (typically /usr/share/sounds/sf2/FluidR3_GM.sf2
or /usr/share/sounds/sf2/FluidR3_GS.sf2
).
$wgScoreTimidity
Set $wgScoreTimidity
to the path of your TiMidity++ executable (typically /usr/bin/timidity
or /usr/local/bin/timidity
).
If $wgScoreFluidsynth
does not exist, TiMidity++ will be used as fallback instead.
$wgScoreLame
Set $wgScoreLame
to the path of your Lame executable (typically /usr/bin/lame
or /usr/local/bin/lame
). Required if the generated audio file should be a MP3.
Remarks
This extension runs various binaries on a shell. You may have to increase $wgMaxShellMemory if you get out of memory errors.
Finding scores
Pages with scores on them will have the "score" page property set. Using Special:PagesWithProp, you can find pages that have scores. (Example query for the English Wikipedia.)
See also
- Help:Score on English Wikipedia and Help:Sheet music on Wikisource have more examples of LilyPond syntax.
- Vexflow Open source SVG/Canvas music renderer
![]() | 此扩展被用于一个或多个维基媒体项目上。 这可能意味着扩展稳定且工作良好,足以用在同等高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中寻找此扩展名称以查看安装它的网站。 详细的已安装扩展的完整列表可在wiki的Special:Version页面找到。 |
- Extensions with arbitrary execution vulnerabilities/zh
- Unstable extensions/zh
- Tag extensions/zh
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- ParserFirstCallInit extensions/zh
- SoftwareInfo extensions/zh
- WikibaseClientDataTypes extensions/zh
- WikibaseRepoDataTypes extensions/zh
- All extensions/zh
- Extensions used on Wikimedia/zh
- Music editor extensions/zh
- Extensions with VisualEditor support/zh