Lilypond处理穆索尔斯基乐谱PDF首小节丢失问题咨询
Lilypond 2.18.2:带休止符首小节消失问题的解决方法
我在处理穆索尔斯基《图画展览会》中「萨穆埃尔·戈登伯格与施缪尔」段落的移调时,碰到了Lilypond 2.18.2的一个bug:只要添加带音符的第二小节,开头带休止符的首小节就会从生成的PDF里消失。哪怕删掉所有装饰音,问题依然存在,初步怀疑是64分音符触发了这个问题。
可复现问题的原始代码如下:
\header { title = "Pictures at an Exhibition" subtitle = "Samuel Goldenberg und Schmuyle" composer = "M. Mussorgskii" instrument = "Trumpet Eb" } \version "2.18.2" #(set-global-staff-size 16) #(set-default-paper-size "a4") << \new Staff = ossia \with { \remove "Time_signature_engraver" } \new Staff \relative c' { \compressFullBarRests \clef treble \key es \major \time 4/4 \tempo "Andante" \partial 32 r32 | r1 r r r \mark\markup\box{"5"} | % 5 r1 r | \time 3/4 r2. | \time 4/4 r1 \mark\markup\box{"9"} | % 9 \tempo 4 = 66 \slashedGrace b''8 \tuplet 3/2 {b16\ff b b } b64\( c b16.\) \slashedGrace b8 \tuplet 3/2 {b16 b b } b64\( c b16.\) \slashedGrace ais8 \tuplet 3/2 {ais16 ais ais } ais64\( b ais16.\) \slashedGrace gis8 \tuplet 3/2 {gis16 gis gis } gis64\( ais gis16.\) | % \slashedGrace ais8 \tuplet 3/2 {ais16 ais ais } ais64\( b ais16.\) % \slashedGrace dis,8 \tuplet 3/2 {dis16 dis dis } dis64\( e dis16.\) % \slashedGrace dis8 \tuplet 3/2 {dis16 dis dis } dis64\( e dis16.\) % \slashedGrace dis8 \tuplet 3/2 {dis16 dis dis } dis64\( e dis16.\) | } >> \layout { \context { \RemoveEmptyStaffContext \override VerticalAxisGroup #'remove-first = ##t \override BarNumber #'padding = #3 \override RehearsalMark #'padding = #2 skipBars = ##t } }
问题根源
这个问题是Lilypond 2.18.2的老bug:\RemoveEmptyStaffContext结合skipBars = ##t时,会错误地把包含短休止符(比如32分休止)的小节判定为“空小节”并移除。加上\compressFullBarRests的压缩逻辑,进一步加剧了这个误判,尤其是当小节里出现64分音符这种极短时值的元素时。
解决方案
以下几种方法都能解决问题,根据你的排版需求选择:
方法1:调整空小节判定逻辑
注释掉\RemoveEmptyStaffContext,改用\hideEmptyStaves(它对非全空小节的判定更准确),同时关闭skipBars:
\layout { \context { \Staff \hideEmptyStaves \override VerticalAxisGroup #'remove-first = ##f \override BarNumber #'padding = #3 \override RehearsalMark #'padding = #2 % skipBars = ##t } }
方法2:强制保留首小节
如果必须保留RemoveEmptyStaffContext,可以给首小节加一个不可见的占位符,让Lilypond识别到小节非空:
\partial 32 { r32 \once \override Rest #'transparent = ##t r32 } |
方法3:修改休止符压缩设置
去掉\compressFullBarRests,避免它干扰小节的空值判定:
% \compressFullBarRests \clef treble \key es \major
修改后的完整代码示例
这里用方法1的调整,确保首小节正常显示,同时保留大部分排版设置:
\header { title = "图画展览会" subtitle = "萨穆埃尔·戈登伯格与施缪尔" composer = "M. 穆索尔斯基" instrument = "降E调小号" } \version "2.18.2" #(set-global-staff-size 16) #(set-default-paper-size "a4") << \new Staff = ossia \with { \remove "Time_signature_engraver" } \new Staff \relative c' { \clef treble \key es \major \time 4/4 \tempo "行板" \partial 32 r32 | r1 r r r \mark\markup\box{"5"} | % 5 r1 r | \time 3/4 r2. | \time 4/4 r1 \mark\markup\box{"9"} | % 9 \tempo 4 = 66 \slashedGrace b''8 \tuplet 3/2 {b16\ff b b } b64\( c b16.\) \slashedGrace b8 \tuplet 3/2 {b16 b b } b64\( c b16.\) \slashedGrace ais8 \tuplet 3/2 {ais16 ais ais } ais64\( b ais16.\) \slashedGrace gis8 \tuplet 3/2 {gis16 gis gis } gis64\( ais gis16.\) | \slashedGrace ais8 \tuplet 3/2 {ais16 ais ais } ais64\( b ais16.\) \slashedGrace dis,8 \tuplet 3/2 {dis16 dis dis } dis64\( e dis16.\) \slashedGrace dis8 \tuplet 3/2 {dis16 dis dis } dis64\( e dis16.\) \slashedGrace dis8 \tuplet 3/2 {dis16 dis dis } dis64\( e dis16.\) | } >> \layout { \context { \Staff \hideEmptyStaves \override VerticalAxisGroup #'remove-first = ##f \override BarNumber #'padding = #3 \override RehearsalMark #'padding = #2 } }
内容的提问来源于stack exchange,提问作者Koos Schut
相关产品推荐
相关产品推荐

