Giter Site home page Giter Site logo

lyutil's Introduction

LyUtil

Here are some LilyPond extensions I have written.

ly-score

ly-score and its companion files make up a score/part generator that takes a lot of the boilerplate out of making orchestral scores. It has a few things common with the OrchestralLily project, but enforces some consistent rules about the folder and file structure used in your LilyPond project to make configuration simpler.

ly-score:process

The main entry point for ly-score is the function ly-score:process. It accepts quite a few arguments:

Required Arguments

  • prefix string: The prefix for all the output files. The score will be named ”prefix.pdf” and the parts will be named ”prefix-/instrument-name/{number}.pdf”
  • scorehead alist: An associative list of header attributes and values to use in the score’s header block. Values can be markup or strings.
  • parthead alist: Like scorehead, but applies to all the parts. Each part will also include a header element specifying the instrument (and number, if there is one specified). See below for information about how to customize an individual part’s header.
  • movements alist: An associative list of movements for the piece. The keys in the alist are strings that correspond to the folders where the music for each movement is stored. The values in the alist are alists of header attributes and values for each movement.
  • instruments list: A list specifying all of the instruments that play in the piece and how they are grouped. The list follows this simple grammar:

<instrument-specification> ::= (<context-name> <string> <intrument-group>+)

<instrument-group> ::= <instrument-specification> | <instrument>

<context-name> ::= ‘<lilypond context name> | ‘Parallel

<instrument> ::= <symbol> | (<symbol> . <datum>)> | (<symbol> . (<datum> . <datum>))

<lilypond context name> would be something like StaffGroup, PianoStaff, GrandStaff, and so on. ‘Parallel creates parallel staves with no added context.

The <string> in each <instrument-specification> is the name that will be given to the context it creates.

<instrument> has three forms:

  • The symbol by itself is just the key for an instrument, such as ‘violin, or ‘clarinet-in-b-flat.
  • The simple pair can be used when there are multiple parts on the instrument; eg. (violin . “I”) or (bassoon . 2). Any datum that can be formated meaningfully by Guile’s format method can be used.
  • The nested pair will combine two parts into one staff in the score, while generating two separate part files.

See the sample directory for a sample instrument specification.

Keyword Arguments

  • transpose? boolean: True if the score should be generated with transposing instruments in their key, false if it should be a C score.
  • include-parts? boolean: True if parts should be generated.
  • include-score? boolean: True if the score should be generated.
  • include-midi? boolean: True if a midi file of the score should be generated.
  • score-size number: The staff size in pts to use in the score. Defaults to 12
  • part-size number: The staff size in pts to use in the parts. Defaults to 24
  • score-paper Output_def: A \paper block to use for the score. Default is an empty paper block.
  • part-paper Output_def: Same as score-paper but for the parts.
  • score-layout Output_def: A \layout block to use for the score. Default is an empty layout block.
  • part-layout Output_def: Same as score-layout but for the parts.
  • frontmatter markuplist: A markup list that can be inserted in the score’s book before the score itself.
  • part-overrides alist: An alist of paper and layout blocks to use in specific parts. The keys in the alist are either a symbol that keys to a specific instrument, ie. ‘violin or ‘flute; or a pair such as ‘(violin . “I”). Don’t use specifiers for combined parts because parts are made for each part individually. The value is another alist, which can have up to two elements – one with key ‘paper whose value is a paper block, and one with key ‘layout whose value is a layout block. Below is an example.
`((contrabass . ((paper . ,#{ \paper { \bigpartpap } #})))
  (timpani . ((paper . ,#{ \paper { \bigpartpap } #}) (layout . ,#{ \layout { \timpanilayout } #})))
  ((percussion . 1) . ((paper . ,#{ \paper { \bigpartpap } #})))
  ((percussion . 2) . ((paper . ,#{ \paper { \bigpartpap } #})))
  ((percussion . 3) . ((paper . ,#{ \paper { \bigpartpap } #}))))

File Structure

ly-score automatically creates all the subsidary folders and *.ly files needed to create the score. A file for each part will be created in a folder for each movement. Additionally, a file called “time_signature.ly” will be created in each folder. Use this file for score-global information like time signature changes and rehearsal marks. You do not need to assign the music expression in the file to any variable. Something like “\relative c’ { … music … }” is all you need.

Fonts

Some of the markup elements generated by ly-score use a \mainfont and \secondaryfont markup command. They are initially defined as no-ops, but the user can redefine them to use fonts of his or her own choosing to create a theme for the score and parts.

Tacet Staff

When a part has no music for a given movement, a tacet note will be included in the part.

Available Instruments

I’ve predefined a bunch of instruments in the file ly-score-instruments.ly. Basically, I create a LilyPond instrument-definition as documented here, and add some additional parameters in a second list. That way you could in theory do \instrumentSwitch to go from one instrument to another, though there are some issues to resolve with getting part numbers and transpositions to display properly. All the instruments that I needed for an orchestral piece I wrote are there, but there are plenty more that aren’t. You can add your own using those as a model. Note that LilyPond’s documentation for \instrumentSwitch specifies that the instrument names be strings, so that’s what I did, but ly-score expects you to refer to instruments with Scheme symbols.

Extending ly-score

As released here, ly-score can generate parts for piano-staff instruments, single-staff instruments, and drum-staff instruments. I’ve also included an extension for large time signatures on their own staff, as described in this snippet, in the file ly-score-time-sig.ly.

Tags

When ly-score creates a part, it will create it with the tag #’part, so if you want something in your piece that only occurs in a part and not in the score, use \tag #’part {…}. Likewise when ly-score creates a score, it does so with the tag #’score. \partBreak and \noPartBreak are defined for managing page (not system!) breaks in parts. But before you use those, check out Page_turn_engraver, which might do what you’re looking for already.

Cues

I also included a simplified method for including cues in your file. There’s no need to use \addQuote anywhere in your score; just use \quickCue instrument specifier duration or \quickClefCue instrument specifier clef duration anywhere you want. Cues are replaced with multi-measure rests in the score. Therefore, if a cue does not occupy a full bar, the user should surround it with \tag #’part {} and also include a \tag #’score {} block with properly formatted rests to avoid a full-bar rest showing up in the score where it shouldn’t. Instrument specifiers are either symbols or pairs as explained elsewhere.

Fluids

For really hardcore use cases, there are a few Guile fluids (dynamically-scoped variables) defined while the score and parts are evaluated. They can be accessed using the procedure fluid-ref.

ly-score:part-header

ly-score:part-header stores the module that is later used to generate a part’s header block, so if you want something in the part’s header that normally wouldn’t be there, add it to ly-score:part-header using the procedure module-define!. You can use layout overrides to create a custom header markup for a part as well.

current-folder

current-folder stores the name of the folder where code is being evaluated. This is mostly used internally by ly-score.

ignore-cues?

This fluid is set to #t when including files while evaluating cues (to avoid circular quotes and infinite loops) and when processing the score. It is also mostly for internal ly-score use.

stdlib.ly

This is just a pretentiously named grab-bag of handy little LilyPond extensions and shortcuts I’ve assembled. You may or may not find it useful. Most of them are self-explanatory, but do check out bottomBarNumbers if you’re doing an orchestra score and want a bar number engraved under every bar. It’s a pretty good solution to that problem, but will require you to put a transparent barline in the middle of every bar of your piece, which can wreak havoc with beaming. bottomBarSpacer is a quick way to create the necessary split bars. If there’s a way to consistently place a bar number in the middle of a measure without any bar line there, please let me know!

vibrato.ly

An experimental vibrato marking that can replace regular trills with the \vib function. See the file for more information.

lyutil's People

Contributors

ian-hulin avatar mwitmer avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ian-hulin jgarte

lyutil's Issues

Individual layouts for each \score

Right now you can specify a layout for the whole book, but not individual movements' \score {} blocks. \overrides and the like can go in the time_signature.ly file, but it would be cleaner to have context-modifying overrides in the main .ly file. It would also enable the use of paper variables like system-count that can also be added to layout blocks.

\on-the-fly function arguments within #:score-paper and #:part-paper

I'm using LilyPond 2.17.8, so this may be a Lily problem, but if I try to declare header/footer statements using \on-the-flay, the second argument is not recognized as a procedure.

E. g.
#:score-paper
#{
\paper {
evenFooterMarkup = \markup{
\fill-line{ \bold \fontsize #3 %\on-the-fly #not-first-page
\fromproperty #'page:page-number-string
\center-column {
\on-the-fly #first-page
\fromproperty #'header:publisher
\on-the-fly #last-page
\fromproperty #'header:tagline
}
\fromproperty #'header:title
}
}
}
#}
gives errors:
#}
Processing `/tmp/frescobaldi-YhhHG0/tmpbaJAyB/Coronation Anthem 1.ly'
Parsing...
/tmp/frescobaldi-YhhHG0/tmpbaJAyB/Coronation Anthem 1.ly:250:45: error: GUILE signaled an error for the expression beginning here
\on-the-fly #
first-page
/tmp/frescobaldi-YhhHG0/tmpbaJAyB/Coronation Anthem 1.ly:250:44: error: wrong type for argument 1. Expecting procedure, found #
\on-the-fly
#first-page
/tmp/frescobaldi-YhhHG0/tmpbaJAyB/Coronation Anthem 1.ly:79:1: error: GUILE signaled an error for the expression beginning here

(ly-score:process
Unbound variable: first-page
Wrong type argument in position 1: (# . #f)
fatal error: failed files: "/tmp/frescobaldi-YhhHG0/tmpbaJAyB/Coronation Anthem 1.ly"
Exited with return code 1.

#:transpose? #t, #:include-midi? #t and playback

:transpose? #t produces correct visual output, but if combined with #:include-midi? #t it produces audio output playing at concert pitch in the written key. In the orchestralliy scores you had to add a \transposition statement to the settings variable for the instrument as well as \transpose statements to the music to get it to play back right if the original music is at concert pitch ( the SectionViola* variables used below for example).. E. g. for atto clarinet in Eb

ZadokIClAltSettings = \transposition es

ZadokIClAltNotes = \relative c' {
\transpose ef c' {
\SectionStartViola
\SectionIntroTwoViola
\SectionChorusViola
}
}

ZadokIClAltMusic = <<
\ZadokIMarks
{ \ZadokIClAltKey
\ZadokISettings
\ClAltSettings
\ZadokIClAltNotes
}

I can't seem to fix it if I add \transposition statements in the composition, here's a simple transposing example attached.

Here's a transposition sample:
\version "2.16.0"

\include "ly-score.ly"
\include "ly-score-instruments.ly"
\include "ly-score-time-sig.ly"

(ly-score:process

"sample-with-transpose"
((title "Sample")) ((title "Sample Part"))
`(("parts" ((piece "Movement 1"))))
'(StaffGroup "Main Score"
alto-saxophone
(violin . I))
#:transpose? #t
#:include-midi? #t
#:include-score? #t
#:include-parts? #t
#:score-layout #{
#})

The resulting midi comes out sounding bi-tonal even if the violini and altosaxophone use the same notes.

Cheers,
Ian Hulin

How do you use LyUtil to get \partcombine on scores but separated music in parts?

I've just started trying out using LyUtil on a project I've written using Orchestrallily so I can compare them.
This bit in the ReadMe implies that this is possible

The in each is the name that will be given to the context it creates.

has three forms:

The symbol by itself is just the key for an instrument, such as ‘violin, or ‘clarinet-in-b-flat.
The simple pair can be used when there are multiple parts on the instrument; eg. (violin . “I”) or >(bassoon . 2). Any datum that can be formated meaningfully by Guile’s format method can be used.
The nested pair will combine two parts into one staff in the score, while generating two separate >part files."

However there's no new context keyword like Parallel to handle a part-combined staff in the code.
Is there a work-round you can code in the individual /.ly file, please?

Cheers,
Ian Hulin

Movement order in score and parts

Hi Mark,
I'm converting a three-movement piece to use LyUtil.

Here's the relevant clause from my project source file

(ly-score:process

"Zadok"
; Score header properties
((title "Zadok the Priest")) ; Part header properties ((title "Zadok the Priest"))
; Movements
;
`(("Zadok" ((piece "1. Chorus - Zadok the Priest")))
("Rejoice" ((piece "2. Chorus - And All the People Rejoiced")))
("GSK" ((piece "3. Chorus - God Save The King")))
)
....
)
In the score the \score blocks appear in reverse order. In the individual part .pdf tiles the are ordered correctly.

Cheers,
Ian Hulin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.