lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: context and lilypond


From: Stefan Thomas
Subject: Re: context and lilypond
Date: Sun, 20 Jan 2013 19:39:24 +0100

Dear Henning,
thanks for Your explanations, but I couldn't manage a working piece of code, untortunately.
As You suggested, I've saved Your code as t-lilyfilter.tex. In which folder shall I store it?
And where in the file should be the line "\usemodule[lilyfilter]"?
I've tried it with the following code:

\setupoutput[pdftex]
\setupbodyfont[plr,11pt]
\mainlanguage[de]
\language[de]
 \usemodule[lilyfilter]
\starttext
\title{Title}
This is some text
\startlilypond
\relative{c4 d e f g1 }
\stoplilypond
\stoptext

2013/1/20 Henning Hraban Ramm <address@hidden>

Am 2013-01-20 um 10:40 schrieb Stefan Thomas:

> Dear community,
> when I want to use lilypond within context (the latex alternative system), do I have to install the lilypond-module separately?
> Can give someone  a short example of code of a document with lilypond code?
> Does context cooperate with the latest stable version of lilypond?

Hi Stefan,
you don’t need the (deprecated) LilyPond module any more at all.

Use the filter module, as mentioned in http://wiki.contextgarden.net/LilyPond
(Anything below the section "Deprecation Warning" is invalid/unnecessary.)

You can save the following snippet as "t-lilyfilter.tex" and \usemodule[lilyfilter]

--- >8 ---

\startmodule[lilyfilter]

\def\readPDFfile#1{\externalfigure[#1]}

\usemodule[filter]
\defineexternalfilter[lilypond]
        [continue=yes,
        readcommand=\readPDFfile,
        directory=lilytemp/,
        output={\externalfilterbasefile.pdf},
        filtercommand={lilypond -dbackend=eps -dinclude-eps-fonts -dno-gs-load-fonts -o"lilytemp/\externalfilterbasefile" "\externalfilterinputfile"}]

\stopmodule

--- 8< ---

This is very simple, but enough for my needs. For more options, have a look at the documentation of t-filter.

Then, in your component (or single document) file, you say e.g.

--- >8 ---

\startlilypond
\include "lily_settings.ly"
global = {
        \clef treble
        \key a \major
        \time 4/4
}

oberstimme = \relative c'' {
        \repeat volta 2 {
                a2^\markup{1.} b4 a |
                gis2 a\fermata |
                cis^\markup{2.} d4 cis |
                b2 cis\fermata |
                a^\markup{3.} fis4 d |
                e2 a,\fermata
        }
}

text = \lyricmode {
        White sand and grey sand.
        Who’ll buy my grey sand?
        Who’ll buy my white sand?
}

\score {
        <<
                \context Staff = Oben <<
                        \global
                        \context Voice = "eins" \oberstimme
                >>
                \lyricsto "eins" \new Lyrics { \text }
        >>
        \layout { }
}
\stoplilypond

--- 8< ---

The old LilyPond module doesn’t allow for variable definitions (global = {}) within \start...\stoplilypond

There’s no further configuration, you keep all settings in an include file (here: lily_settings.ly).
My usual contains stuff like...

--- >8 ---

\version "2.14.0"
#(ly:set-option (quote no-point-and-click))
#(set-global-staff-size 14)

\paper {
        #(define dump-extents #t)
        indent = 0\mm
        ragged-bottom = ##t
        ragged-last-bottom = ##t
        print-page-number = ##f
        line-width = 120\mm
        oddFooterMarkup  = ##f
        oddHeaderMarkup  = ##f
        bookTitleMarkup  = ##f
        scoreTitleMarkup = ##f
}

#(define (conditional-string-downcase str condition)
  (if condition
      (string-downcase str)
      str))

#(define (pitch-alteration-semitones pitch)
 (inexact->exact (round (* (ly:pitch-alteration pitch) 2))))

#(define ((chord-name->german-markup-text-alteration
         B-instead-of-Bb) pitch lowercase?)
 "Return pitch markup for PITCH, using german note names.
If B-instead-of-Bb is set to #t, real german names are returned.
Otherwise, semi-german names (with Bb and below keeping the
british names).  Alterations are indicated with -es and -is
instead of the flat and sharp symbols."
 (let* ((name (ly:pitch-notename pitch))
        (alt-semitones  (pitch-alteration-semitones pitch))
        (n-a (if (member (cons name alt-semitones) `((6 . -1) (6 . -2)))
                 (cons 7 (+ (if B-instead-of-Bb 1 0) alt-semitones))
                 (cons name alt-semitones))))
   (make-line-markup
    (list
     (make-simple-markup
      (conditional-string-downcase
       (vector-ref #("C" "D" "E" "F" "G" "A" "H" "B") (car n-a))
      lowercase?))
     (let ((alteration (/ (cdr n-a) 2)))
       (cond
          ((= alteration FLAT) (make-simple-markup "es"))
          ((= alteration SHARP) (make-simple-markup "is"))
          (else empty-markup)))))))

smN = \override NoteHead #'font-size = #-3
smn = \once \override NoteHead #'font-size = #-3
nmN = \override NoteHead #'font-size = #0
opC = \once \override ChordNames.ChordName #'stencil = #addBrackets
cnh = \once \override NoteHead #'style = #'cross
ccJ = \set chordChanges = ##t
ccN = \set chordChanges = ##f

\layout {
        #(layout-set-staff-size 14) % resets fonts!
        #(define fonts (make-pango-font-tree "TeX Gyre Schola" "LMSans10" "LMTypewriter10 Regular" (/ 14 20)))
        \context { \Score
                %\dynamicUp % doesn’t work
                \remove "Bar_number_engraver"
                \override PaperColumn #'keep-inside-line = ##t
        }
        \context { \Staff
                \override TimeSignature #'style = #'numbered
        }
        \context { \ChordNames
                chordChanges = ##t
                chordNameLowercaseMinor = ##t
                chordRootNamer = #(chord-name->german-markup-text-alteration #t)
                majorSevenSymbol = \markup{ 7+ }
        }
}



--- 8< ---


HTH


Greetlings, Hraban
---
fiëé visuëlle
Henning Hraban Ramm
http://www.fiee.net
http://angerweit.tikon.ch/lieder/
https://www.cacert.org (I'm an assurer)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]