Showing posts with label LilyPond. Show all posts
Showing posts with label LilyPond. Show all posts

Saturday, August 13, 2011

LilyPond remove empty staves

In recent versions of LilyPond \RemoveEmptyStaffContext has been changed to ...

\layout {
\context {
\Staff
\RemoveEmptyStaves
% To use the setting globally, uncomment the following line:
% \override VerticalAxisGroup #'remove-first = ##t
}
}

... though it remains to be seen whether \RemoveEmptyStaffContext is deprecated or not.

Thursday, May 12, 2011

Accidentally creating a new context

Consider the following layout block:

\layout {
\context {
\type "Engraver_group"
\consists "Time_signature_engraver"
\consists "Axis_group_engraver"
\name "TimeSig"
\override TimeSignature #'font-size = #3
\override TimeSignature #'break-align-symbol = ##f
\override TimeSignature #'X-offset =
#ly:self-alignment-interface::x-aligned-on-self
\override TimeSignature #'self-alignment-X = #CENTER
\override TimeSignature #'after-line-breaking =
#shift-right-at-line-begin
}
\context {
\Score
\accepts TimeSig
}
\context {
\Staff
\remove "Time_signature_engraver"
}
}

The layout comes from the LilyPond snippet repository and allows for time signatures above staves:

\new Score <<
\new TimeSig {
\time 2/4 s2
\time 3/4 s2.
}
\new StaffGroup <<
\new Staff { c'4 c'4 c'4 c'4 c'4 }
\new Staff { c'4 c'4 c'4 c'4 c'4 }
>>
>>


But this can get messed up:

\new Score <<
\new TimeSig {
#(set-accidental-style 'forget)
\time 2/4 s2
\time 3/4 s2.
}
\new StaffGroup <<
\new Staff { c'4 c'4 c'4 c'4 c'4 }
\new Staff { c'4 c'4 c'4 c'4 c'4 }
>>
>>


The accidental style setting causes an unwanted new staff to be instantiated.

Make sure to keep Scheme commands out of nonsemantic contexts to avoid this behavior.

Friday, December 18, 2009

Bar line thickness

Adjusting LilyPond bar line thickness does nothing.

\new Staff {
c'1
c'1
c'1
\override Staff.BarLine #'color = #red
\override Staff.BarLine #'thickness = #0.5
c'1
}



Adjusting bar line hair-thickness does the trick.

\new Staff {
c'1
c'1
c'1
\override Staff.BarLine #'color = #red
\override Staff.BarLine #'hair-thickness = #0.5
c'1
}

Monday, June 29, 2009

Red, boxed markup




\version "2.13.2"

\new Staff {
\set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
c'4
\override TextScript #'staff-padding = #4
\override TextScript #'self-alignment-X = #left
c'4 ^ \markup \with-color #red \override #'(box-padding . 1.0)
\box \hcenter-in #3 \line { 2 / 3 }
c'4
c'4
\bar "||"
}

Sunday, June 28, 2009

The right version of LilyPond for OS X

There's been some craziness regarding the correct version of LilyPond for OS X users for sometime. The LilyPond download page ...

http://lilypond.org/web/install/

... lists three different situations:

  • MacOS X 10.5 (Leopard)
  • MacOS X (Intel) 10.4
  • MacOS X (G3, G4, G5) 10.3 and newer

I find all three of these a touch confusing. So here's what works for me.

I have a MacOS X (Intel) 10.4 iMac at home. And, happily, clicking on the corresponding link on the LilyPond download page always works. The only confusing bit, however, is that you if you inspect downloaded executable in the Finder (using cmd-I for 'info'), the info box that the Finder shows you will say that the application is 'Application (PowerPC)'.



I *think* this is just a mistake. But I've never been certain. Anyway, the point is that the MacOS X (Intel) 10.4 link on the LilyPond download site does indeed work, even if the binary is mislabelled.

The situation with my MacBook running Leopard is more complicated. I have never once followed the MacOS X (Leopard) 10.5 link on the LilyPond download page. The link takes you away from the LilyPond site and has a bunch of instructions that have never made much sense to me. Happily, though, what does work for me is to download from the MacOS (G3, G4, G5 Macs) 10.3 and newer link on the LilyPond download page.

Now this is highly counterintuitive. It seems like downloading a binary for the old, old type of Mac hardware would be exactly the wrong thing to do for a MacBook made of the (almost) newest type of Mac hardware. But this does in fact work.

I think the one caveat here is that I never use the LilyPond GUI and always call LilyPond from the commandline. I think that running the LilyPond GUI on my MacBook with the old G3 version of the binary would probably fail.

convert-ly and multiple versions of Python

The LilyPond convert-ly script lives here under a standard OS X install of LilyPond:

/Applications/LilyPond.app/Contents/Resources/bin/convert-ly

The script is written in Python but starts with the following directive to the shell:

#!/usr/bin/python

If you have multiple versions of Python installed on your system, convert-ly may find an old version of Python and be unable to start. Fix this by changing the first line of convert-ly to this:

#!/usr/bin/env python

Wednesday, June 24, 2009

TextSpanner alignment, TextScript alignment



The 2, 3 and 4 in the image all center directly above the first chord in the measures they govern.

The 2 and 3 are LilyPond TextScript grobs. The 4 is the left text of a LilyPond TextSpanner grob.

Center alignment for TextScript and TextSpanne grobs differ.

To (horizontally) center a TextScript relative to the note to which it refers, use \once \override TextScript #'self-alignment-X = #center together with \once \override TextScript #'X-offset = #center. This pair of settings is easy enough to stumble across in the LilyPond docs.

To horizontally center the left text of a TextSpanner, use \once \override TextSpanner #'bound-details #'left #'text = \markup { \halign #0 "FOO" } together with \once \override TextSpanner #'bound-details #'left #'attach-dir = #center. The 'attach-dir is easy enough to find, but knowing to use \halign *internal to the markup* takes some real doing.

Sunday, December 14, 2008

Basic Scheme in LilyPond input files

Perhaps the simplest LilyPond file looks like this.

\new Staff { c'4 }

The LilyPond input file looks like its own language with backslash-prefixed commands similar to LaTeX. But LilyPond input is in fact Scheme. Pure Scheme commands prefixed with # mix freely in LilyPond input. The following examples mix LilyPond and pure Scheme together.

Example 1.

#(print "hello!")
\new Staff { c'4 }


Example 2.

#(define foo "FOO")
#(print foo)
\new Staff { c'4 }


Example 3.

#(define bar 7)
#(print (number->string bar))
\new Staff { c'4 }


Other examples are possible. Best of all will be functions to print out LilyPond context names or grob settings during interpretation.

Tuesday, September 23, 2008

Using FontForge to convert LilyPond .pfb to .otf

A number of the fonts in the LilyPond /fonts directory are .pfb instead of .otf. FontForge can convert these .pfb LilyPond fonts to .otf.

  • Go to sourceforge.
  • download package
  • unzip
  • run package
  • make sure X11 server is installed on machine; came preinstalled on MacBook under OS 10.5.4
  • install package
  • double click X11 server to start
  • double-click FontForge application icon to start
  • use FontForge's UI to browse to /Applications/LilyPond.app/Contents/Resources/share/lilypond/current/fonts/type1
  • go here to figure out how to use fontforge's UI to convert
  • for each .pfb: navigate to file, click OK to open, file > generate fonts > as .otf > click save
  • click 'OK' if FontForge says there are problems

Wednesday, August 27, 2008

OTF versions of the LilyPond custom fonts

LilyPond uses custom fonts, primarily of the Feta and Emmentaler families. These custom fonts draw noteheads, accidentals, tuplet numbers, time signatures and curly braces. LilyPond also uses New Century Schoolbook for default letting in titles and credits.

LilyPond stores font information here:

/Applications/LilyPond.app/Contents/Resources/share/lilypond/current/fonts

LilyPond does not appear to install these custom fonts in the usual places in the filesystem such that other applications, like Illustrator and InDesign, can find them.

The LilyPond /fonts folder contains three subfolders: /otf, /svg and /type1.

If you use Apple's FontBook application to load the custom LilyPond fonts, those fonts in /otf will load perfectly. But the fonts in /svg and /type1 will not load at all.

The fonts in /svg duplicate the fonts in /otf and so probably aren't necessary under any circumstances to load with FontBook.

The fonts in /type1 are unique and, therefore, probably are necessary. The fonts end in .pfa and FontBook will not recognize them. The solution is to download FontForge and use FontForge to convert these .pfa fonts to .otf fonts. The FontForge UI requires the X11 client, which was available in the Utilities subfolder in my Applications folder without recourse to install discs for the MacBook. Double-click to start the X11 server before double-clicking to start FontForge. Then use FontForge to Open each .pfa by hand, and then Generate each .pfa as an .oft. Generate is apparently FontForge's term for convert or save-as. The process is tedious but works.

The resulting 33 new .otf fonts load correctly under FontBook.

I would publish the zipped file of the complete set of all 46 custom LilyPond fonts as .otf here, but I can't figure out how to get Blogger to let me upload a nonimage, nonvideo file.

Tuesday, August 19, 2008

Importing LilyPond output into Adobe Illustrator

Take the simplest possible test.ly LilyPond file ...

\version "2.11.50"
\new Staff { c'4 }

... and render test.pdf as PDF output. Two different ways of 'moving' test.pdf into LilyPond.

Dragging test.pdf onto the Illustrator icon on the dock causes Illustrator to open test.pdf as a pdf for pdf editing. This isn't a successful way of working. Illustrator complains about missing fonts ...



... and then displays the pdf incorrectly ...



... which is bad.

Placing test.pdf into an existing Illustrator file using File > Place works ...



... which is good.

So it would appear that the way to get LilyPond output into Illustrator is to render a PDF from LilyPond and then place the PDF into Illustrator.

However, this is with Illustrator 11.0.0 from the very first release of Creative Suite a couple of years back. When Eryn places test.pdf in her more modern version of Illustrator, missing font problems result and, for example, dynamics appear in Arial.

So the conclusion appears to be that placing LilyPond PDFs works only under certain versions of illustrator. Which is frustrating.

There is a third way of moving LilyPond output into Illustrator. This third way involves the UNIX utility ps2ps for clean up. The ps2ps utility runs against an existing postscript or pdf file. So it's possible to run ps2ps against test.pdf and generate test-clean.pdf as output. From here again we can either drag or place test-clean.pdf onto or in Illustrator. And here the results differ from those above.

Dragging test-clean.pdf onto the Illustartor icon to edit as PDF does not cause Illustrator to complain about missing fonts but does cause Illustrator to display time signatures and dynamics with a slight degree of jagginess visible at high magnification.



Placing test-clean.pdf into an existing Illustrator file does not work. Illustrator complains the test-clean.pdf is not in a format that can place.




CONCLUSIONS:

1. Placing LilyPond PDF output works perfectly in Illustrator 11.0.0 under OS 10.5.4; placing LilyPond PDF output causing missing font problems under more modern versions of Illustrator under OS 10.4 something.

2. Running ps2ps on LilyPond PDF output enables Illustrator 11.0.0 under OS 10.5.4 and also more modern versions of Illustrator under 10.4 something to open LilyPond PDF output directly from the dock but with high magnification jaggies; on the other hand, running ps2ps on LilyPond PDF output causes both of these versions of Illustrator to be unable to place LilyPond PDF output.


ONE LAST OBSERVATION:

3. LilyPond PDF output that I place perfectly in Illustrator 11.0.0 under OS 10.5.4 does not open correctly under more modern versions of Illustrator under OS 10.4 something. In other words, my LilyPond AI files open incorrectly on Eryn's machine. Interestingly, Eryn's machine finds all fonts correctly but displaces a good many noteheads down to such a degree that they are musically incorrect.



LAST CONCLUSION:

4. Placed files are perfect on my machine but open incorrectly on Eryn's machine. So we're going with the ps2ps method of production on my machine so that the files open correctly on Eryn's machine and, hopefully, at the printers.

Monday, June 2, 2008

Minimum LilyPond glissando lengths

From Matt on the list two weeks ago:

\override Glissando #'springs-and-rods = #ly:spanner::set-spacing-rods
\override Glissando #'minimum-length = #4

The code is a mystery but potentially useful for the spacing of a variety of objects. Will require tests.

Thursday, May 22, 2008

LilyPond baseline alignment

Baseline alignment of TextSpanner text takes some work in LilyPond.



The primary tricks to get that bit there are the \transparent and \combine markup commands, together with faking the right ascender- and descender-heights with an "f". All parts of that come from Markus, and thank God because I spent a good amount of time on the problem this weekend and only got partway there.

After grace positioning in LilyPond

LilyPond renders after grace notes well in a variety of metric positions.



\layout { indent = #0
ragged-right = ##t
}

\new Staff \with {
\remove Time_signature_engraver
} {
\set Score.proportionalNotationDuration = #(ly:make-moment 1 32)
\override Score.SpacingSpanner #'uniform-stretching = ##t
\override Score.SpacingSpanner #'strict-note-spacing = ##t
\override Score.SpacingSpanner #'strict-grace-spacing = ##t
\override Stem #'direction = #down
\afterGrace c'8 [ { c'32 [ c'32 c'32 c'32 ] } c'8 c'8 c'8 ]
c'8 [ \afterGrace c'8 { c'32 [ c'32 c'32 c'32 ] } c'8 c'8 ]
c'8 [ c'8 \afterGrace c'8 { c'32 [ c'32 c'32 c'32 ] } c'8 ]
c'8 [ c'8 c'8 \afterGrace c'8 ] { c'32 [ c'32 c'32 c'32 ] }
}

Time signatures and strict note spacing in LilyPond

Time signatures and strict note spacing in LiyPond disagree.



Time signatures with strict note spacing turned on. The bracket underextends and the time signature and noteheads overlap.




Time signatures with strict note spacing turned off. The bracket extends correctly and neither the time signaure nore noteheads overlap.

LilyPond whistle tones

Create whistle tones in LilyPond with small values to NoteHead #'font-size.



<<
{
\override Stem #'direction = #down
\override Stem #'transparent = ##t
\override NoteHead #'font-size = #-3
\override Accidental #'font-size = #-3
\override Script #'font-size = #-4
\override Script #'padding = #0.5
\override Script #'extra-offset = #'(-0.1 . 0)
s64
fs'''64 \flageolet
...
e''''64 \flageolet
\revert Stem #'transparent
\revert NoteHead #'font-size
\revert Accidental #'font-size
\revert Script #'font-size
\revert Script #'padding
}
\\
{
\override Beam #'font-size = #-3
\override NoteHead #'font-size = #-3
\once \override Script #'direction = #up
\once \override Script #'font-size = #-4
\once \override Script #'padding = #0.5
<
d'''
\tweak #'duration-log #1
d'
>64 [ \flageolet
\override NoteHead #'transparent = ##t
\override NoteHead #'no-ledgers = ##t
c'64
...
c'64 ]
\revert NoteHead #'transparent
\revert Beam #'font-size
}
>>

Two separate voices allow the harmonics and reference voice to stem independently.

Spacing LilyPond trill spanners

Consecutive LilyPond trill spanners overlap at the same vertical position. The spanner package in 2.11 fixes this with independent control of left and right padding.



\new Staff {
\override TrillSpanner #'bound-details #'right #'padding = #2
c'4 \startTrillSpan
c'4 \stopTrillSpan \startTrillSpan
\revert TrillSpanner #'bound-details #'right
c'4 \stopTrillSpan \startTrillSpan
c'4 \stopTrillSpan
}

Centering LilyPond page numbers

LilyPond page numbers print in lower left and right corners by default. Printing LilyPond page numbers somewhere other than in these default locations requires some additions to the \paper block.

Specify LilyPond page numbers explicitly with the \on-the-fly #print-page-number-check-first and \fromproperty #'page:page-number-string incantations.

\paper {
print-page-number = ##t
print-first-page-number = ##t
oddHeaderMarkup = \markup \fill-line { " " }
evenHeaderMarkup = \markup \fill-line { " " }
oddFooterMarkup = \markup { \fill-line {
\bold \fontsize #3 \on-the-fly #print-page-number-check-first
\fromproperty #'page:page-number-string } }
evenFooterMarkup = \markup { \fill-line {
\bold \fontsize #3 \on-the-fly #print-page-number-check-first
\fromproperty #'page:page-number-string } }
}

Centering occurs thanks to \fill-line.

A stem-centered triangle notehead in LilyPond

How do we get a stem-centered triangle notehead in LilyPond?

Max implemented an answer last year reusing the triangle- or do-shaped notehead from the shape notes series. Here's the first example.



To me the example shows two different series of notes. The first four notes show a type of "inward-pointing" orientation while the last four notes show a type of "outward-pointing" orientation.

Later Max sent even more examples.



These are perfect. The outward-pointing triangles in measure two will handle both Sciarrino's lip- and tongue-pizzicati and also the "play the highest pitch, whatever that is" symbol in Penderecki. The inward-pointing triangles in measure three are amazingly odd and so visually distinct, at the same time. To what use will they go? Maybe ingressive air or some type of reversed bowing or playing. There's definitely something decidedly "reversed" about these shapes.

A good accent notehead in LilyPond

A couple of weeks ago Max took up the challenge of making a good accent-shaped notehead. I first mailed the list back in April last year and then Jamie brought the request up again in February. Max did some pretty amazing stuff. He got the stems to center horizontally on the glyph, both up and down. And he and Jamie convinced me that a calligraphic version of glyph with thicker lower edge actually worked better than versions that were completely symmetric across the x-axis. Here are some of different variations we tried. Max cooked all these up and Jamie and I kept going through the different combinations.





And here's the final version. The trick wound up being that the calligraphic glyph had to rise just above center to make the vertical spacing work right.




This work patched into 2.11.22. And so now we have the right glyph for a tongue-ram.