ian-hulin / LyUtil

Some utils for lilypond, including an automated score/part creator
0 stars 1 forks source link

+AUTHOR: Mark Witmer

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 [[http://wiki.kainhofer.com/lilypond/orchestrallily][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

::= ( +) ::= | ::= ' | 'Parallel ::= | ( . )> | ( . ( . )) would be something like StaffGroup, PianoStaff, GrandStaff, and so on. 'Parallel creates parallel staves with no added context. 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. 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. #+BEGIN_SRC Scheme `((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 } #})))) #+END_SRC *** 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 [[http://lilypond.org/doc/v2.16/Documentation/notation/writing-parts#instrument-names][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 [[http://lsr.dsi.unimi.it/LSR/Item?id=272][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 [[http://lilypond.org/doc/v2.16/Documentation/internals/page_005fturn_005fengraver][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!