Lilypond: Instrument part transpose with several key signatures - lilypond

For example, I have a very long clarinets part starts in Fis-dur and ends in G-dur written in concert pitch.
How can I apply transposition to them without causing weird key signatures at the beggining or at the end?
ClarinetI = \relative c' {\key fis \major
fis8 gis ais b cis cis cis4 |
\key g \major
g8 a b c d d d4
}
ClarinetII = \relative c' {\key fis \major
dis8 eis fis gis ais ais ais4|
\key g \major
e8 fis g a b b b4
}
\new Staff \with {instrumentName = "clarinets in concert"}<<
\partCombine \ClarinetI \ClarinetII
>>
\new Staff \with {instrumentName = "clarinets in B"}<<
\transpose bes c' \partCombine \ClarinetI \ClarinetII
>>
I want resulting part look like this:
Generally, as I'm exporting the score from Reaper midi — I can add some Python logic into the export process, but currently I'm inside the production and need to works with the exported parts as they are.
P.S. I've tested MuseScore against my example and...

As a temporary fix, I've wrapped Fis-dur part into enharmonical transpose statement. But I would like to see more reliable and complex solution.
ClarinetI = \transpose c c' { \transpose fis ges {\key fis \major
fis8 gis ais b cis' cis' cis'4 }|
\key g \major
g8 a b c' d' d' d'4
}
ClarinetII = \transpose c c' { \transpose fis ges {\key fis \major
dis8 eis fis gis ais ais ais4|}
\key g \major
e8 fis g a b b b4
}
\new Staff \with {instrumentName = "clarinets in concert"}<<
\partCombine \ClarinetI \ClarinetII
>>
\new Staff \with {instrumentName = "clarinets in B"}<<
\transpose bes c' \partCombine \ClarinetI \ClarinetII
>>

Related

Lilypond: Change color of notes below and above a certain pitch

While writing a Lilypond score for recorders (flutes), I wish I could automatically mark notes with pitches beyond the range of an instrument by changing its color.
The idea is that, for example, all absolute pitches below f and all pitches above g'' are colored red for the bass instrument. The same for tenor, alt and soprano instruments.
I found a helpful question on coloring notes, but there remains a piece of code I cannot write:
#(define (ambitus-notehead-alt grob)
( **code_i_cannot_write** )
#(define (ambitus-notehead-tenor grob)
( **code_i_cannot_write** )
#(define (ambitus-notehead-bass grob)
( **code_i_cannot_write** )
\score {
\new Staff \relative c' {
\override NoteHead #'color = #ambitus-notehead-alt
\music_altrecorder
}
\new Staff \relative c' {
\override NoteHead #'color = #ambitus-notehead-tenor
\music_tenorrecorder
}
\new Staff \relative c' {
\override NoteHead #'color = #ambitus-notehead-bass
\music_bassrecorder
}
}
Here is a function that does what you want:
\version "2.19.82"
#(define (colour-out-of-range grob)
(let* ((pch (ly:event-property (event-cause grob) 'pitch))
(semitones (ly:pitch-semitones pch)))
(cond ((< semitones 0) red)
((> semitones 24) red)
(else black))))
\score {
\new Staff \relative c' {
\override NoteHead.color = #colour-out-of-range
g8 a b c d e f g a b c d e f g a b c d e f g
}
}
Producing:
To customize it for your instrument's range, change the values of (< semitones 0) and (> semitones 24). The value 0 is the middle C (C4), and increments of 1 are equal to one semitone. So in the case above, the range is between C4-C6. You need to use negative values for pitches below middle C (e.g. -5 is G3).

LilyPond multiline lyrics

Having this example LilyPond snippet, I'm getting two strange things.
\score{
<<
\new Voice = "voicea" \relative { g'4 a b c g a b c }
\new Lyrics \lyricmode {
{ a b c d }
<<
\new Lyrics \lyricsto "voicea" \lyricmode { e f g h }
\new Lyrics \lyricsto "voicea" \lyricmode { i j k l }
>>
}
\new Voice = "voiceb" \relative { g'4 a b c g a b c }
>>
}
The last two lyrics lines are placed under the both music lines. I want all lyrics to go in-between them.
By some reason, the lyrics don't line up correctly with the notes. The first quarter note in the second bar has no lyric.
Can you help me understand what is going on, and preferably come up with a solution.
Here is the document: http://lilybin.com/o6atu2/1
One Lyrics context makes one line of lyrics. If you want sequential lyrics, you need to put them into the same context. To target some notes in a voice, you can always create a named voice into another. This is what it looks like:
\score{
<<
\new Voice = "voicea" \relative {
g'4 a b c
\new Voice = "voiceb" { g a b c }
}
\new Lyrics
<<
\lyricsto "voicea" { \lyricmode { a b c d } }
\lyricsto "voiceb" { \lyricmode { e f g h } }
>>
\new Lyrics \lyricsto "voiceb" { \lyricmode { i j k l } }
\new Voice = "voicec" \relative { g'4 a b c g a b c }
>>
}
The lilybin document is here: http://lilybin.com/4vsiem/1
I don't use Lyrics and I can't tell you what's wrong exactly in your example.
But this is a simple working example:
\version "2.18.2"
<<
\new Voice \relative {
g'4 a b c g a b c
}
\addlyrics { a b c d e f g h } % 1st stanza
\addlyrics { _ _ _ _ i j k l } % 2nd stanza
\new Voice \relative {
g'4 a b c g a b c
}
>>

Align secondary lyrics to hidden Voice

I think I'm close, but can't quite seem to get two stanzas going with one aligned to a hidden voice - so that rhythmic variations can be approximated by the lyrics.
melody = \relative c' {
\clef treble
\key c \major
\time 4/4
c4 d e f | g f e d |
<<
\new Voice = "shown" {
\relative c' {
c4 d c d | e f g2
}
}
\new Voice = "hidden" {
\hide {
c'8 c d d c c d d | e f g2
}
}
>>
}
text = \lyricmode {
Here we have a | li -- tle si -- lly
<<
{
\set stanza = #"1. "
Si -- lly li -- tle | al -- pha -- bet
\new Lyrics {
\set associatedVoice = "hidden"
\set stanza = #"2. "
Si -- ly li -- tle fu -- nny soun -- ding |
Al -- pha -- bet song.
}
}
>>
}
\score {
<<
\new Voice = "one" { \melody }
\new Lyrics \lyricsto "one" \text
>>
\layout { }
\midi { }
}
The above shows both voices and neither of their "associated" (or not) lyrics.
You can use the NullVoice context as so:
\version "2.19.15"
\language "english"
\score {
\new Staff
<<
\new Voice = "displayedMusic" \relative c'' {
b8 c d \times 2/3 {c16 d c}
b8 a g a
bf c bf \times 2/3 {a16 bf a}
g8 f g a
bf f' e a,
d cs4.~
cs1
}
\new NullVoice = "hiddenMusic"
{
c4 d e f %\break
g a b8~ b c4 \break
d e f g a
}
\new Lyrics \lyricsto "hiddenMusic" {
Those words seem to be aligned to the hidden melody or are they?
}
>>
}
Which will result in :
Okay. From the lilypond mailinglist I learned:
First, you need to use \hideNotes, not \hide. Also the above structure doesn't quite work. It's usually easier to have all the lyrics contexts running from the start rather than starting them part way along - they'll get their position from the notes. Here's one way of doing it, although in this particular case the stanza number doesn't quite fit.
melody = \relative c' {
\clef treble
\key c \major
\time 4/4
c4 d e f | g f e d |
<<
\new Voice = "shown" {
\relative c' {
c4 d c d | e f g2
}
}
\new Voice = "hidden" {
\hideNotes { % !!
c'8 c d d c c d d | e f g2
}
}
>>
}
text = \lyricmode {
Here we have a | li -- tle si -- lly
}
wordsOne = \lyricmode {
\set stanza = #"1. "
Si -- lly li -- tle | al -- pha -- bet
}
wordsTwo = \lyricmode {
\set stanza = #"2. "
Si -- ly li -- tle fu -- nny soun -- ding |
Al -- pha -- bet song.
}
\score {
<<
\new Voice = "one" { \melody }
\new Lyrics \lyricsto "one" \text
\new Lyrics \lyricsto "shown" \wordsOne
\new Lyrics \lyricsto "hidden" \wordsTwo
>>
\layout { }
\midi { }
}

Lilypond: controlling clef and key signature visibility, aligning markup

My effort to create a document with six incipits from different pieces is
running into a couple of problems. Can anyone help? I am pasting my code
below (I've reduced the example somewhat for the purposes of asking the question).
Problem 1: How can I hide the clefs and key signatures from the ends of the
lines? The commands in \score are not behaving as I thought they would based
on the documentation.
Problem 2: How can I align the text markup to the start of the lines? I want
"No. 1" etc. left-aligned to the very start of the staff.
Extra query: Does anyone know why using \partial breaks the beaming in the
measure preceding the partial measure? Is there a general fix for this?
(Short of hard-coding the proper beaming with [ ].)
Any assistance gratefully received!
=========================
\version "2.16.2"
notes = {
\bar""\mark\markup\normalsize{No. 1}
\clef bass
\time 6/8
\key g \major
\partial 8 \once \stemUp d=8 |
g( d e) e( c d) |
\partial 8*5 d g d b g
\bar""
\break
\mark\markup\normalsize{No. 2}
\clef bass
\time 3/8
\key d \minor
\partial 8 a=8 |
d,4 bes'8 |
\partial 4 cis,4
\bar""
\break
\mark\markup\normalsize{No. 3}
\clef bass
\time 3/8
\key c \major
\partial 8 g=8 |
c8 c,16( d e f) |
\partial 4 g8( a)
\bar""
\break
\mark\markup\normalsize{No. 4}
\clef bass
\time 12/8
\key es \major
\partial 8 es8 |
es( d es) bes( c d) es( d es) g( f g) |
\break
\mark\markup\normalsize{No. 5}
\clef bass
\time 3/8
%\key c \minor
\partial 8 g=8 |
es8. f16 d8 |
\partial 16*3 es8.
\bar""
\break
\mark\markup\normalsize{No. 6}
\clef alto
\time 6/8
\key d \major
\partial 8 a='8 |
<< { d,4. e8 fis g |\noBreak
fis d a' \stemDown a16( g fis g) a8 \stemUp |\noBreak
d, a d e fis g |\noBreak } \\
{ fis,4. a8 s s |
d, s8*5 |
fis8 s s a s s | } \\
{ s2. |
a8 s8*5 |
s2. | } >>
fis'8 d a d,4
}
\score {
\relative c <<
\new Staff \notes
\override Score.TextScript #'font-family = #'sans
\override Score.RehearsalMark #'font-family = #'sans
\override Staff.Clef #'break-visibility = #begin-of-line-visible
\override Staff.Clef #'explicitClefVisibility = #begin-of-line-visible
\override Staff.TimeSignature #'break-visibility = #begin-of-line-
visible
\override Staff.KeySignature #'break-visibility = #begin-of-line-visible
\override Staff.KeySignature #'explicitKeySignatureVisibility = #begin-
of-line-visible
\override Staff.KeyCancellation #'break-visibility = #all-invisible
\override Staff.KeyCancellation #'explicitKeySignatureVisibility = #all-
invisible
>>
\layout {
}
}
\paper {
paper-height = 250\pt%7in=504pt max.
line-width = 432\pt
paper-width = 432\pt
left-margin = 0\pt
top-margin = 0\pt
bottom-margin = 0\pt
indent = 0
head-separation = 0\pt
page-top-space = 0\pt
after-title-space = 0\pt
before-title-space = 0\pt
between-system-padding = 0\pt
between-system-space = 0\pt
between-title-space = 0\pt
foot-separation = 0\pt
ragged-bottom = ##f
ragged-right = ##t
}
\book {
#(set-global-staff-size 13)
}
\header {
tagline = ""%removed
title = ""
}
Here is the solution to both of your questions:
1) I compiled your code above and the cautionary clefs are already hidden for me. The time signature problems will be solved by using \set Staff.explicitKeySignatureVisibility = #begin-of-line-visible.
2) To solve this, you can align the \mark\markup texts with clefs, then shift it by an horizontal amount.
Simply replace your \score for this one:
\score {
\relative c <<
\new Staff \notes
\override Score.RehearsalMark.break-align-symbols = #'(clef) %this will put the \mark\markup texts above the clefs
\override Score.Clef.break-align-anchor-alignment = #0.3 % %this controls its horizontal displacement. In my test, 0.3 was the ideal value to have the No. x exactly at the beginning of each system
\override Score.TextScript #'font-family = #'sans
\override Score.RehearsalMark #'font-family = #'sans
\override Staff.Clef #'break-visibility = #begin-of-line-visible
\override Staff.Clef #'explicitClefVisibility = #begin-of-line-visible
\override Staff.TimeSignature #'break-visibility = #begin-of-line-visible
\set Staff.explicitKeySignatureVisibility = #begin-of-line-visible % this will do the job with the time signatures
\override Staff.KeyCancellation #'break-visibility = #all-invisible
\override Staff.KeyCancellation #'explicitKeySignatureVisibility = #all-invisible
>>
\layout {
}
}
About your extra question: I found the following quotation in an old documentation of LilyPond (v2.12):
The \partial command is intended to be used only at the beginning of a
piece. If you use it after the beginning, some odd warnings may occur.
Maybe this is the reason you are encountering these problems with beaming. I would suggest some workaround, as using invisible rests (entered as sn, where n is the duration). One other possibility for the beaming problem is to control the beaming manually. It is annoying, but it gets the job done :) Ex: replace the musical content of your No. 1, which is:
\partial 8 \once \stemUp d=8 |
g( d e) e([ c d)] |
\partial 8*5 d g d b g
for:
\partial 8 \once \stemUp d=8 |
g( d e) e([ c d)] |
\partial 8*5 d[ g d] b[ g]
I hope this helps.
So the problem here is that you have one single instrumental staff that is being broken down into 6 pieces, and this causes all sorts of problems with clefs, pickup bars, key signatures. Although the workaround I posted above works well (besides for the clefs), the ideal thing is to have to consider each one of your six examples as a small score. Then you can ask LilyPond to print one below each other. Here is a minimal example:
A = {c'4 d' e' f'}
B = {\clef bass c2 g c1}
C = {e'4 d' cis' fis' | e' d' cis' }
\score {\new Staff \A}
\score {\new Staff \B}
\markup {This text will be added between the scores...}
\score {\new Staff \C}
Which results in:
Note how the last bar of C has only 3 quarter notes and thus is left opened, without any \bar "" command. Also, all problems with clefs, key signatures and pickup bars are vanished now.
And here is your code reworked. I think now it works quite well:
\version "2.16.2"
A = {
\bar""\mark\markup\normalsize{No. 1}
\clef bass
\time 6/8
\key g \major
\partial 8 \once \stemUp d=8 |
g( d e) e( c d) |
d g d b g
}
B = {
\mark\markup\normalsize{No. 2}
\clef bass
\time 3/8
\key d \minor
\partial 8 a'8 |
d,4 bes'8 |
cis,4
}
C = {
\mark\markup\normalsize{No. 3}
\clef bass
\time 3/8
\key c \major
\partial 8 g'8 |
c8 c,16( d e f) |
g8( a)
}
D = {
\mark\markup\normalsize{No. 4}
\clef bass
\time 12/8
\key es \major
\partial 8 es8 |
es( d es) bes( c d) es( d es) g( f g) |
}
E = {
\mark\markup\normalsize{No. 5}
\clef bass
\time 3/8
%\key c \minor
\partial 8 g'8 |
es8. f16 d8 |
es8.
}
F = {
\mark\markup\normalsize{No. 6}
\clef alto
\time 6/8
\key d \major
\partial 8 a''8 |
<< { d,4. e8 fis g |\noBreak
fis d a' \stemDown a16( g fis g) a8 \stemUp |\noBreak
d, a d e fis g |\noBreak } \\
{ fis,4. a8 s s |
d, s8*5 |
fis8 s s a s s | } \\
{ s2. |
a8 s8*5 |
s2. | } >>
fis'8 d a d,4
}
\score {
\relative c <<
\new Staff \A
\override Score.RehearsalMark.break-align-symbols = #'(clef) %this will put the \mark\markup texts above the clefs
\override Score.Clef.break-align-anchor-alignment = #0.3 % %this controls its horizontal displacement. In my test, 0.3 was the ideal value to have the No. x exactly at the beginning of each system
\override Score.TextScript #'font-family = #'sans
\override Score.RehearsalMark #'font-family = #'sans
>>
\layout { }
}
\score {
\relative c <<
\new Staff \B
\override Score.RehearsalMark.break-align-symbols = #'(clef) %this will put the \mark\markup texts above the clefs
\override Score.Clef.break-align-anchor-alignment = #0.3 % %this controls its horizontal displacement. In my test, 0.3 was the ideal value to have the No. x exactly at the beginning of each system
\override Score.TextScript #'font-family = #'sans
\override Score.RehearsalMark #'font-family = #'sans
>>
\layout { }
}
\score {
\relative c <<
\new Staff \C
\override Score.RehearsalMark.break-align-symbols = #'(clef) %this will put the \mark\markup texts above the clefs
\override Score.Clef.break-align-anchor-alignment = #0.3 % %this controls its horizontal displacement. In my test, 0.3 was the ideal value to have the No. x exactly at the beginning of each system
\override Score.TextScript #'font-family = #'sans
\override Score.RehearsalMark #'font-family = #'sans
>>
\layout { }
}
\score {
\relative c <<
\new Staff \D
\override Score.RehearsalMark.break-align-symbols = #'(clef) %this will put the \mark\markup texts above the clefs
\override Score.Clef.break-align-anchor-alignment = #0.3 % %this controls its horizontal displacement. In my test, 0.3 was the ideal value to have the No. x exactly at the beginning of each system
\override Score.TextScript #'font-family = #'sans
\override Score.RehearsalMark #'font-family = #'sans
>>
\layout { }
}
\score {
\relative c <<
\new Staff \E
\override Score.RehearsalMark.break-align-symbols = #'(clef) %this will put the \mark\markup texts above the clefs
\override Score.Clef.break-align-anchor-alignment = #0.3 % %this controls its horizontal displacement. In my test, 0.3 was the ideal value to have the No. x exactly at the beginning of each system
\override Score.TextScript #'font-family = #'sans
\override Score.RehearsalMark #'font-family = #'sans
>>
\layout { }
}
\score {
\relative c <<
\new Staff \F
\override Score.RehearsalMark.break-align-symbols = #'(clef) %this will put the \mark\markup texts above the clefs
\override Score.Clef.break-align-anchor-alignment = #0.3 % %this controls its horizontal displacement. In my test, 0.3 was the ideal value to have the No. x exactly at the beginning of each system
\override Score.TextScript #'font-family = #'sans
\override Score.RehearsalMark #'font-family = #'sans
>>
\layout { }
}
\paper {
paper-height = 250\pt%7in=504pt max.
line-width = 432\pt
paper-width = 432\pt
left-margin = 0\pt
top-margin = 0\pt
bottom-margin = 0\pt
indent = 0
head-separation = 0\pt
page-top-space = 0\pt
after-title-space = 0\pt
before-title-space = 0\pt
between-system-padding = 0\pt
between-system-space = 0\pt
between-title-space = 0\pt
foot-separation = 0\pt
ragged-bottom = ##f
ragged-right = ##t
}
\book {
#(set-global-staff-size 13)
}
\header {
tagline = ""%removed
title = ""
}
Producing:

Lilypond: Customize bar lines, recursively, automatically?

I'm working on Carnatic music scores that involve complex time signatures, that will require modified bar lines
Pattern for barlines for: 8/4
beats: 1 2 3 4 (dashed bar here) 5, 6 (Dotted Bar) 7, 8 (double bar)
Here's one bar of actual score
g16( f) d8 ees( ees) d16( c d8) bes16[( d c bes \bar "dashed"
a g]) a[( bes c] d[ c d]) \bar ":"
g8( f16) ees8( d16 c d) \bar "||"
Is there a way to automate these barlines?
Give this a try. It's not fully automated in that you need to have an "invisible" voice allocated to specify the barlines, and you need to keep track of how many measures this form of barring needs to extend and specify an appropriate unfold value. The "s", if you don't already know, is an invisible spacer, with duration like a rest.
\version "2.13.19"
fooBar = { s1 \bar "dashed" s2 \bar ":" s2 \bar "||" }
\new Staff <<
\new Voice = "theMusic" \relative c'' {
% bar 1
g16( f) d8 ees( ees) d16( c d8) bes16[( d c bes
a g]) a[( bes c] d[ c d])
g8( f16) ees8( d16 c d)
% bar 2
g16( f) d8 ees( ees) d16( c d8) bes16[( d c bes
a g]) a[( bes c] d[ c d])
g8( f16) ees8( d16 c d)
}
\new Voice = "theBarLines" { \repeat unfold 2 \fooBar }
>>