根据声音用不同颜色标记关键音符?
Mark key note in different colors according to voice?
我正在使用 4 部分声乐。我正在尝试使每个语音部分的关键音符具有不同的颜色。根据以前的答案和 lilypond 片段,我有这个代码:
%Association list of pitches to colors.
#(define color-mapping
(list
(cons (ly:make-pitch 0 6 FLAT) (x11-color 'blue))))
%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
(and
(= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
(= (ly:pitch-notename p1) (ly:pitch-notename p2))))
#(define (pitch-to-color pitch)
(let ((color (assoc pitch color-mapping pitch-equals?)))
(if color
(cdr color))))
#(define (color-notehead grob)
(pitch-to-color
(ly:event-property (event-cause grob) 'pitch)))
然后在每个声音中我都用它来称呼它:
\override NoteHead.color = #color-notehead
这使得乐谱中的每个 Bb 都变成蓝色,这是一个很好的开始。但我希望能够让 voiceOne 中的 Bb 为蓝色,voiceTwo 中为绿色等,以便我的歌手一眼就能看出他们何时发出主音。
笨拙的解决方案是制作 4 个不同版本的音乐,并且每个版本只用一种声音调用覆盖 NoteHead.color。并根据声音部分给每个歌手一个不同的版本。
是否有一种编码方法可以做到这一点,每个声音的特定音符颜色不同?
可能最简单的解决方案是为每个不同的语音定义不同的函数,并且在每个函数定义中您将使用不同的颜色。这是一个有两个声音的例子:
\version "2.19.53"
%Association list of pitches to colors.
#(define color-mapping-voice1
(list
(cons (ly:make-pitch 0 6 FLAT) (x11-color 'blue))))
#(define color-mapping-voice2
(list
(cons (ly:make-pitch 0 6 FLAT) (x11-color 'red))))
%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
(and
(= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
(= (ly:pitch-notename p1) (ly:pitch-notename p2))))
#(define (pitch-to-color-voice1 pitch)
(let ((color (assoc pitch color-mapping-voice1 pitch-equals?)))
(if color
(cdr color))))
#(define (pitch-to-color-voice2 pitch)
(let ((color (assoc pitch color-mapping-voice2 pitch-equals?)))
(if color
(cdr color))))
#(define (color-notehead-voice1 grob)
(pitch-to-color-voice1
(ly:event-property (event-cause grob) 'pitch)))
#(define (color-notehead-voice2 grob)
(pitch-to-color-voice2
(ly:event-property (event-cause grob) 'pitch)))
{
\new Staff <<
\new Voice{
\voiceOne
\override NoteHead.color = #color-notehead-voice1
bes' bes' d'' f''
}
\new Voice{
\voiceTwo
\override NoteHead.color = #color-notehead-voice2
bes d' f' bes'
}
>>
}
制作中:
我正在使用 4 部分声乐。我正在尝试使每个语音部分的关键音符具有不同的颜色。根据以前的答案和 lilypond 片段,我有这个代码:
%Association list of pitches to colors.
#(define color-mapping
(list
(cons (ly:make-pitch 0 6 FLAT) (x11-color 'blue))))
%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
(and
(= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
(= (ly:pitch-notename p1) (ly:pitch-notename p2))))
#(define (pitch-to-color pitch)
(let ((color (assoc pitch color-mapping pitch-equals?)))
(if color
(cdr color))))
#(define (color-notehead grob)
(pitch-to-color
(ly:event-property (event-cause grob) 'pitch)))
然后在每个声音中我都用它来称呼它:
\override NoteHead.color = #color-notehead
这使得乐谱中的每个 Bb 都变成蓝色,这是一个很好的开始。但我希望能够让 voiceOne 中的 Bb 为蓝色,voiceTwo 中为绿色等,以便我的歌手一眼就能看出他们何时发出主音。
笨拙的解决方案是制作 4 个不同版本的音乐,并且每个版本只用一种声音调用覆盖 NoteHead.color。并根据声音部分给每个歌手一个不同的版本。
是否有一种编码方法可以做到这一点,每个声音的特定音符颜色不同?
可能最简单的解决方案是为每个不同的语音定义不同的函数,并且在每个函数定义中您将使用不同的颜色。这是一个有两个声音的例子:
\version "2.19.53"
%Association list of pitches to colors.
#(define color-mapping-voice1
(list
(cons (ly:make-pitch 0 6 FLAT) (x11-color 'blue))))
#(define color-mapping-voice2
(list
(cons (ly:make-pitch 0 6 FLAT) (x11-color 'red))))
%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
(and
(= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
(= (ly:pitch-notename p1) (ly:pitch-notename p2))))
#(define (pitch-to-color-voice1 pitch)
(let ((color (assoc pitch color-mapping-voice1 pitch-equals?)))
(if color
(cdr color))))
#(define (pitch-to-color-voice2 pitch)
(let ((color (assoc pitch color-mapping-voice2 pitch-equals?)))
(if color
(cdr color))))
#(define (color-notehead-voice1 grob)
(pitch-to-color-voice1
(ly:event-property (event-cause grob) 'pitch)))
#(define (color-notehead-voice2 grob)
(pitch-to-color-voice2
(ly:event-property (event-cause grob) 'pitch)))
{
\new Staff <<
\new Voice{
\voiceOne
\override NoteHead.color = #color-notehead-voice1
bes' bes' d'' f''
}
\new Voice{
\voiceTwo
\override NoteHead.color = #color-notehead-voice2
bes d' f' bes'
}
>>
}
制作中: