2015-03-02 17:40 GMT+01:00 Michael Hendry <hendry.mich...@gmail.com>: > I’m an amateur jazz guitarist, and although I usually play from Realbook > leadsheets I occasionally need to produce my own. > > Typically, I want PDF output in three files, (Concert pitch, Bb and Eb), and > I would like to modularise this as much as possible. > > The .ly code which follows shows what I’m trying to do, but there are a > couple of problems I would like help with. > > 1. I’d like to define a variable (\BaseFileName) which is the name of the > song, and have this variable picked up for the title in the header, and when > I’m creating the three PDF files with the relevant instrument names appended. > > e.g. "Generic (guitar).pdf”, “Generic (trumpet).pdf” and “Generic (alto).pdf”. > > > 2. The LilyJazzText font uses small capitals instead of lower case letters, > so using “Eb” produces a capital E followed by a small capital B. On my Mac I > know how to produce a flat sign, and LilyPond will use the flat sign from > another font, but I’d like to be able to define a flat sign as a variable, > and append it to the piece markup when creating the books for trumpet and > alto. > > Thanks in advance, > > Michael Hendry > > > %%%%%%%%%%%% > > \version "2.18.0" > > \include "LilyJAZZ.ily" > \include "AccordsJazzDefs.ly" > > BaseFileName = "Generic" > FlatSign = "" > > \header { > title = \markup {\fontsize #3 \override #'(font-name . > "LilyJAZZText") "Generic" } > } > > TheHead = \relative c' { > \set Score.markFormatter = #format-mark-box-letters > \clef "treble" \key c \major \numericTimeSignature \time 4/4 > {c d e f} > > } > > TheChords = \chords { > c1 > } > > % I’d like the code from here on to be generic, and produce concert, Bb and > Eb versions from the variables defined above. > > \book { > > \bookOutputName "Generic (guitar)” % I WANT TO CONSTRUCT THIS STRING BY > APPENDING “ (guitar)” to BaseFileName > \new Score > << > \transpose c c {\TheChords} > \new Staff > \jazzOn \transpose c c {\TheHead} > >> > \header {piece = \markup {\fontsize #-1 \override #'(font-name . > "LilyJazzText") "Guitar"}} > } > > \book { > \bookOutputName "Generic (tpt)” % I WANT TO CONSTRUCT THIS STRING BY > APPENDING “ (tpt)” to BaseFileName > \new Score > << > \transpose c d' {\TheChords} > \new Staff > \jazzOn \transpose c d' {\TheHead} > >> > \header {piece = \markup {\fontsize #-1 \override #'(font-name . > "LilyJazzText") "Trumpet in Bb”}} % I WANT TO USE VARIABLE FOR FLAT SIGN > HERE... > } > > > \book { > \bookOutputName "Generic (alto)” % I WANT TO CONSTRUCT THIS STRING BY > APPENDING “ (alto)” to BaseFileName > \new Score > << > \transpose c a {\TheChords} > \new Staff \jazzOn \transpose c a {\TheHead} > >> > \header {piece = \markup {\fontsize #-1 \override #'(font-name . > "LilyJazzText") "Alto Sax in Eb”}} % …AND AGAIN HERE
How about the quite generic code below? nb %%uncomment \version "2.18.0" %% uncomment % %\include "LilyJAZZ.ily" %\include "AccordsJazzDefs.ly" % BaseFileName = "Generic" FlatSign = \markup { \hspace #0.1 \raise #0.4 \fontsize #-3 \flat } \header { title = \markup { \fontsize #3 \override #'(font-name . "LilyJAZZText") \BaseFileName } } TheHead = \relative c' { \set Score.markFormatter = #format-mark-box-letters \clef "treble" \key c \major \numericTimeSignature \time 4/4 c d e f } TheChords = \chords { c1 } #(define (scores instruments pitches) (map (lambda (p n) #{ \score { << \new ChordNames \transpose c $p \TheChords \new Staff %% uncomment: %\jazzOn \transpose c $p \TheHead >> \header { piece = \markup { \fontsize #-1 \override #'(font-name . "LilyJazzText") $n } } %% for testing: %\layout { \override ChordNames.ChordName.color = #red } } #}) (event-chord-pitches pitches) (map (lambda (i) (let ((instr (string-split i #\tab))) (if (string-null? (last instr)) #{ \markup $(car instr) #} #{ \markup \concat { $(car instr) \FlatSign } #}))) instruments))) writebooks = #(define-void-function (parser location instr-nms pitches) (list? ly:music?) (let* ((instrument-names (map (lambda (i) (car (string-split i #\tab))) instr-nms)) (file-names (map (lambda (i) (let ((instr (string-split i #\Space))) (format #f "~a (~a)" BaseFileName (string-downcase (car instr))))) instrument-names))) (for-each (lambda (score name) (let* ((my-new-book (ly:make-book $defaultpaper $defaultheader score))) (ly:score-set-header! score (ly:score-header score)) (ly:book-process my-new-book $defaultpaper $defaultlayout name))) (scores instr-nms pitches) file-names))) \writebooks #'( "Guitar\t" ;; \t is a hack to signalize not to print a flat-accidental "Trumpet in B" "Alto Sax in E" ) { c d' a } HTH, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user