在学习玩键盘的时候,我发现写下我演奏的曲子的分数是很有帮助的,不管是否已经存在一个分数。
代码使用弗雷科迪作为开发环境,LilyPond (文档)作为模板下的格式和雕刻工具。音乐被刻在PDF中,并生成一个MIDI文件。
用LilyPond写音乐有点像用LaTeX写一本书。
我想分享其中一个简单的部分。简略的钢琴版本的晨曦(摩根斯坦宁)由埃德沃德格里格。具体来说,这是流动键提供的版本的1:1翻译(没有关联)。
\version "2.18.2"
\language "english"
\header {
title = "Morning Mood"
% Morgenstemning Suite No. 1, Op. 46 (Peer Gynt)
composer = "Edvard Grieg"
tagline = \markup {
Engraved at
\simple #(strftime "%Y-%m-%d" (localtime (current-time)))
with \with-url #"http://lilypond.org/"
\line { LilyPond \simple #(lilypond-version) (http://lilypond.org/) }
}
}
topNotes =
\relative c'' {
\time 6/8
\clef treble
\key c \major
\override Score.BarNumber.break-visibility = ##(#f #t #t)
g8 e d c d e g e d c d16 e d e g8 e g a e a g e d c4.
g'8 e d c d e g e d c d16 e d e g8 e g a e a b gs fs e4.
b'8 gs fs e fs gs b gs fs e fs16 gs fs gs b8 gs b c gs c d b a g4.
g8 e d c d e g e d c d16 e d e g4. a4. <e c'>2.
}
bottomNotes =
\relative c {
\time 6/8
\clef bass
\key c \major
<c e g>2. <c e g> <c e g>4. <c e a>4. <c e g>4. g'8 e d
<c e g>2. <c e g> <c e g>4. <c e a>4. <e gs b>4. b'8 gs fs
<e gs b>2. <e gs b>2. <e gs b>4. <c' gs e>4. <g b d>4 . d'8 b a
<c, e g>4. <c e a>4. <c e g>4. <c e a>4. <c e g>4. <c f a>4. <c e g>2.
}
\score {
<<
\new Staff \with {
instrumentName = "Piano"
midiInstrument = "acoustic grand"
} { \topNotes }
\new Staff \with {
instrumentName = "Piano"
midiInstrument = "acoustic grand"
} { \bottomNotes }
>>
\layout {}
\midi {}
}生成PDF的部分屏幕截图:

音频:这里
注:和弦的持续时间应超过所提供的音频中所能听到的时间,这是一种与所编写的代码无关的不幸的转换伪音。
感兴趣的想法:
tagline必须在页脚中声明,但到目前为止,我看到的每个示例都在页眉中声明了它。所以这就是我放的地方。不管您在哪里声明它,它无论如何都会放在页面的底部。\override Score.BarNumber.break-visibility = ##(#f #t #t)在每个度量的开头和每一个人员中断后显示度量值(因此第一个参数是#f false)。如果我正确理解,这只能在分数所包含的部分中声明,而不能在分数本身中声明。所以我把它放进了topNotes。闻起来,用一个单独的变量来存储这样的分数修饰符会更好,但我不知道如何以一种明显而整洁的方式这样做。基本上,它就像一个符咒,结果看起来像一个符咒,但是代码本身可能需要一些严肃的清理。
发布于 2018-01-11 18:34:14
在LilyPond中有很多样板可以把所有的部件放在一起。在你的例子中,你用:
{ << \新员工+{ instrumentName =“钢琴”midiInstrument =“音响大”}{ \topNotes }\新员工\与{ instrumentName =“钢琴”midiInstrument =“声学大”}{\\底部笔记} >>…}}
…这并不完全正确。我建议:
global = {
\time 6/8
\key c \major
}
\score {
\new PianoStaff <<
\set PianoStaff.instrumentName = #"Piano"
\new Staff = "upper" {
\global
\clef treble
\rhNotes
}
\new Staff = "lower" {
\global
\clef bass
\lhNotes
}
>>
\layout {}
\midi {}
}这有三个后果:
\PianoStaff指令创建了一个卷曲大括号,将两个支柱结合在一起,表明它们将在单个乐器上演奏。请注意,无论如何,“声学大”是默认的MIDI乐器.,所以我没有费心指定它。global参数可以减少重复。在我看来,显示每一个条形码都是令人讨厌的过头:
覆盖Score.BarNumber.突破口能见度= ##(#f #t #t)
最好把分数降下来,这样你就可以把更多有用的数字放在那里,比如指进。
假设您确实想使用\override指令,最好将它放在我前面介绍的global变量中。
很好的做法是包括所有的条形检查,以帮助您捕捉节奏错误,并使代码更容易阅读:
g8 e d c d e | g e d c d16 e d e | g8 e g a e a | g e d c4. |假设这是整个片段,而不是一段摘录,则应该以双栏行结尾:
g8 e d c d e | g e d c d16 e d e | g4. a4. | <e c'>2. \bar "|."在相对模式下写音高是可以的。绝对模式将是一种痛苦。
https://codereview.stackexchange.com/questions/184857
复制相似问题