Re: Openlilylib edition engraver guide
Hi Urs, I had a moment of free time and converted it to (what I think) is Github-usable Markdown. It's attached to this email. There was a typo or two and I also took the liberty of fixing those. I tried to add headings, but the way it's written, they're nested pretty deep, so some more editing might be necessary, but long story short, I figured I'd just help out. Randy On Thu, Mar 14, 2019 at 1:51 AM Urs Liska wrote: > > Am 13.03.19 um 14:47 schrieb Andrew Bernard: > > Can we add Stefano Troncaro's excellent introductory material about the > edition engraver to the github wiki for the project? > > Yes. > > > I'll add my voice to the chorus singing the praises of this well written > tract (the article here: > https://lists.gnu.org/archive/html/lilypond-user/2018-01/msg00603.html) > > > Would you volunteer making the text Github-usable Markdown? > > Urs > > > > Andrew > > > ___ > lilypond-user mailing > listlilypond-user@gnu.orghttps://lists.gnu.org/mailman/listinfo/lilypond-user > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user > # My quick rundown of how to use OpenLilyLib's Edition Engraver Hello again everyone! In a recent thread I was asked to write a little bit depicting how I would have liked to learn about using the Edition Engraver. I share it here so that others can give their insights. Hopefully we can make a "quick start guide" kind of thing to help future users. I'll say it ended up being longer than I anticipated. I formatted it a little to improve readability. Here it goes: ## My quick rundown of how to use OpenLilyLib's Edition Engraver (OR I wish I could have read this instead of having to learn by poking example code with a stick) ## What is it? In a nutshell, the Edition Engraver provides a convenient way of storing a tweaks, overrides and other objects that can later be applied to some musical content. ## Why use it? To keep the "musical source" of a project free from tweaks, temporary overrides, and tagged material that needs to be filtered later. This serves to generate code that is clean, reusable and has clarity of purpose, meaning it's fast to read and understand. ## How is it used? In summary, by following this four logical steps: 1. Load the Edition Engraver into the project. 2. Create an edition (a container to store the edits) 3. Fill the edition with content. 4. Consist the contents of the edition to the musical contexts to which they apply. Each step explained: ### 1) Loading the Edition Engraver: Assuming OpenLilyLib is already installed on your working environment, include its core functionality: \include "oll-core/package.ily" Then, load the Edition Engraver itself: \loadPackage edition-engraver ### 2) Creating an edition Just use the `\addEdition` command. Like this: \addEdition edition-name ### 3) Filling the edition with content The most basic way to do this is by using the _\editionMod_ command. It is used as follows: \editionMod edition measure position context content Breaking it apart: * `edition` specifies in what edition the content is stored. * `measure` specifies in what measure of the music the content is to be placed. * `position` specifies where where exactly in that measure the content is to be placed. * `context` specifies in what context the content belongs. * `content` specifies, finally, what should be placed there. So, this means that \editionMod my-edition 5 0/4 Score \break will store in `my-edition` that a `\break` needs to be placed in the `Score` context, in measure `5` , specifically at `0/4` , which is its first beat. 3.1) About the position value The way I understand it is that this is the amount of musical time that is counted from the start of the given measure. A few useful examples: * `0/4` will not add anything, so it references the first beat of the measure. * `3/8` will count three 8th notes / quavers from the start of the measure. In 4/4 time this would reference the second half of the second beat. * `1/24` will count one 16th note / semiquaver of a 16th note triplet. If the measure starts with 16th note triplets, this will point to the second note of the measure. The fraction is expressed like this because there are 24 "tripleted 16th notes" in a whole note. 3.2) About referencing contexts Precise control can be achieved by giving IDs to contexts. This is done with the `\editionID` command: \new Staff \with { \editionID my-staff } { \new Voice { c4 d e f } } This ID can be used like this: \editionMod test 1 2/4 my-staff.Staff \accidentalStyle dodecaphonic \editionMod test 1 3/4 my-staff.Voice.A \override NoteHead.color = #red Notice tha
percent repeats (bug?)
\repeat percent is not as "smart" as I was hoping it would be. When dealing with repeats longer than two bars, there are two issues: 1. The percent symbol is not centered, but placed in the left-most measure; and 2. The slashes of the percent symbol do not reflect the number of measures being repeated. I grepped through /usr/share/lilypond looking for beat-slash, which from the internals reference seemed a promising place to look. There are two grobs defined in define-grobs.scm, one for RepeatSlash and one for DoubleRepeatSlash. Unfortunately I can't see how I might be able to add TripleRepeatSlash and QuadrupleRepeatSlash. Otherwise, I might just write them myself and manually add them to my score, but that's still far from preferable, of course. Preferably, \repeat would simply take the length of the music into consideration and adjust placement and the number of slashes accordingly. Is there a way that these two issues can be resolved? (Also, can this be considered a bug?) Here's a minimal example (with attached png) that demonstrates the issue: \version "2.19.82" \repeat percent 4 { \mark "perfect" c'2 d' | c'1 | } \repeat percent 4 { \mark "3-bar" c'2 d' | c' e' | g'1 | } \repeat percent 4 { \mark "4-bar" c'2 d' | c'1 | c' | c' | } Thanks, Randy ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: aligning variables with upbeats
Thanks, Pedro, this is some interesting code! There's definitely something for me to learn here. On Wed, Feb 13, 2019 at 4:13 AM Pedro Pessoa wrote: > Hello John, > I took this task as a way of learning a bit more about moments and > durations > (and also, I wanted to achieve this a while ago). It is certainly not a > very > robust or elegant solution, but seems to work for this particular case. > > %% \makeRestOfLenght \mus "rest/skip" upbeat %% > > \version "2.19.82" > partA = { c'2 b | R1*3 } > partB = { \partial 4 g4 | \bar "||" c'1 } > > #(define (make-dynamic-rest len event) >"The rest/skip body." >(make-music > event ; To choose if it is gonna be Skip or Rest > 'duration > ; intlog transforms the rational values used in Moments (the > denominator) into log values used in Durations. > ; 1 (whole)->0 > ; 2 (half)->1 > ; 4 (quarter)->2 ... etc > (ly:make-duration (ly:intlog2 len > > #(define (makeRestofLog num den opts) >"Logging function" >(display (format "~%>> \\makeRestOfLenght:~%~A ~As of value ~A will be > created:~%" num opts den))) > > makeRestOfLenght= > #(define-scheme-function (mus opts upbeat)(ly:music? string? ly:music?) >"Creates a series of rests/skips of the same length as the given music > minus an upbeat value. Opts are 'rest', 'skip'. Anything else calls > 'rest'." >(let* ((musLen (ly:music-length mus)); >(upBeatLen (ly:music-length upbeat)) >(musMinusUp (ly:moment-sub musLen upBeatLen)) >(den (ly:moment-main-denominator musMinusUp)) >(num (ly:moment-main-numerator musMinusUp)) >(event (cond >((string>= opts "skip") > 'SkipEvent) >((string>= opts "rest") > 'RestEvent) >(else > (set! opts "rest") > 'RestEvent) >)) >(rests '())) > (makeRestofLog num den opts) ; Didatic logging. > > ; Iterate over the number of rest needed (given by the numerator). > ; The value of the rest is given by the denominator. > (let loop ((i 0)) >(if (< i num) >(begin > (set! rests (append rests (list (make-dynamic-rest den > event > (loop (+ i 1) > (newline) > (make-music > 'SequentialMusic > 'elements > rests) > )) > > \score { > \new Staff << > \new Voice \partA > \new Voice { > % \makeRestOfLenght \partA "rest" 4 % To visualize rests. > \makeRestOfLenght \partA "skip" 4 > \partB > } > >> > } > > > > > > -- > Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: aligning variables with upbeats
> > but it would likely not be > easy to implement properly. > That's what I figured… It's okay, I'll try what Mats and Kieren have suggested with the tags, and if that turns out to be more work than it's worth, then I can always just manually pad the variables with rests, I guess. Thanks, Randy On Thu, Feb 7, 2019 at 11:52 PM David Kastrup wrote: > 智樂喬 writes: > > > I'd also like to avoid defining two variables, to keep things a little > > DRYer. > > > > What I imagine might be idea would be a function which works similarly to > > skip-of-length, but takes an argument to subtract a specified length from > > the variable. I imagined something like the following: > > > > #{skip-of-length (- (ly:length-of partA) (ly:make-moment 1/4))) \partB > > > > And then put that in a function to make it more compact and easy to use. > > It won't give you multi-measure rests padded with ordinary rests. It > might be a great addition to multi-measure rests if they self-padded > with ordinary rests for incomplete measures but it would likely not be > easy to implement properly. > > -- > David Kastrup > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: aligning variables with upbeats
> > Hope that helps! > Yes, it does. I have no idea what the edition-engraver is, but I'm curious to read more about it when I have time. Thanks! Randy On Thu, Feb 7, 2019 at 11:44 PM Kieren MacMillan < kieren_macmil...@sympatico.ca> wrote: > Hi Randy, > > > I'm looking for a clean, way to align music variables which begin with > partial measures. For example, > > > > \version "2.19.82" > > partA = { c'2 b | R1*3 } > > partB = { \partial 4 g4 | \bar "||" c'1 } > > \score { { \partA \partB } } > > This is one of the few situations where I would whole-heartedly recommend > using Lilypond’s \tag mechanism. (Most things that might seem to be good > candidates for \tags are, in my opinion, better handled via the > edition-engraver.) This is exactly how I keep different versions of songs > from my musicals (e.g., show version, medley version, standalone version, > etc.). > > %%% SNIPPET BEGINS %%% > partA = { > c'2 b | > \tag #'full { R1*3 } > \tag #'short { R1*2 r2 r4 } > } > > partB = { > \partial 4 g4 | \bar "||" c'1 > } > > \score { > { \keepWithTag #'full \partA } > } > > \score { > { \keepWithTag #'short \partA \partB } > } > %%% SNIPPET ENDS %%% > > Hope that helps! > Kieren. > > > Kieren MacMillan, composer > ‣ website: www.kierenmacmillan.info > ‣ email: i...@kierenmacmillan.info > > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: aligning variables with upbeats
> > As illustrated by the diverse responses you already recevied, the > question is what you want to achieve. > Yes… maybe I should think about that some more. Usually I spend more time looking at ways to "do it right" than actually just writing some music. It's a bad habit! > If this is a way of saving typing when typesetting music with recurring > material, you might be able to use \tag to handle slight variations, > such as shortening a measure that is to be followed by a pickup. > I'll look into that. It may be what I'm looking for. Thanks! Randy On Thu, Feb 7, 2019 at 11:34 PM Mats Bengtsson wrote: > > On 2019-02-07 15:08, 智樂喬 wrote: > > I'm sure I'm not the first person to ask this, but I'm looking for a > > clean, way to align music variables which begin with partial measures. > > For example, > > > > \version "2.19.82" > > partA = { c'2 b | R1*3 } > > partB = { \partial 4 g4 | \bar "||" c'1 } > > \score { { \partA \partB } } > > > > In reality, there would be multiple partBs and some of them would > > start with a pickup and some of them wouldn't. One think I can do is > > explicitly shorten the end of partA so that partB lines up, but it > > involves some mixing of content and structure. Is there a best > > practice for this situation? > > As illustrated by the diverse responses you already recevied, the > question is what you want to achieve. > > I recently typeset a Telemann suite with a number of "movements" to be > played attacca, which in the original print was typeset without any > separation between these movements. I then took the typesetting decision > to keep it that way and used a solution more or less identical to your > example above, with an additional \bar "||" \break between these parts. > Thanks to the improvements introduced in Lilypond 2.19, these mid-piece > \partials work smoothly. However, I could also have chosen other ways to > typeset the music. > > If this is a way of saving typing when typesetting music with recurring > material, you might be able to use \tag to handle slight variations, > such as shortening a measure that is to be followed by a pickup. Or > simply leave out the bar that varies, and insert it manually between the > music that's stored in variables. > > /Mats > > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: aligning variables with upbeats
> > *Valentin:* > If you really want to keep your variables separate, you’ll have to use > simultaneous music instead of sequential expressions : > That's what I was afraid of… {\oneVoice s1*15/4 \partB} > I'd like to avoid having to count bars/beats because it's kind of inefficient and makes using variables in this way a lot more clumsy and prone to error. *David:* > I'd rather just have two versions of partA, one before an upbeat and one > not. > I'd also like to avoid defining two variables, to keep things a little DRYer. What I imagine might be idea would be a function which works similarly to skip-of-length, but takes an argument to subtract a specified length from the variable. I imagined something like the following: #{skip-of-length (- (ly:length-of partA) (ly:make-moment 1/4))) \partB And then put that in a function to make it more compact and easy to use. Randy ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: aligning variables with upbeats
\version "2.19.82" partA = { c'2 b | R1*3 } partB = { \partial 4 g4 | \bar "||" c'1 } \score { { \partA \partB } } Yes, so partA is a full four bars, the last bar being a measure of rest. partB starts after partA, but partB contains a pickup note, which should actually be in the last beat of partA's rest. If you run the code above, you should see that the G in partB gets its own one-beat measure instead of what I explained. On Thu, Feb 7, 2019 at 10:53 PM Gianmaria Lari wrote: > > On Thu, 7 Feb 2019 at 15:24, 智樂喬 wrote: > >> I'm sure I'm not the first person to ask this, but I'm looking for a >> clean, way to align music variables which begin with partial measures. For >> example, >> >> \version "2.19.82" >> partA = { c'2 b | R1*3 } >> partB = { \partial 4 g4 | \bar "||" c'1 } >> \score { { \partA \partB } } >> >> In reality, there would be multiple partBs and some of them would start >> with a pickup and some of them wouldn't. One think I can do is explicitly >> shorten the end of partA so that partB lines up, but it involves some >> mixing of content and structure. Is there a best practice for this >> situation? >> > > I'm sorry, I don't understand what do you want to do. Could you try to > explain again what you need? > Thank you, g. > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: issue with \transpose and \relative
Ok, thanks for the clarification. That's something to keep in mind, although I've never used tags in my scores before. (Only made one score before, though, so…) I'll keep this in mind if I ever have any strange issues when I'm using it. Randy ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
aligning variables with upbeats
I'm sure I'm not the first person to ask this, but I'm looking for a clean, way to align music variables which begin with partial measures. For example, \version "2.19.82" partA = { c'2 b | R1*3 } partB = { \partial 4 g4 | \bar "||" c'1 } \score { { \partA \partB } } In reality, there would be multiple partBs and some of them would start with a pickup and some of them wouldn't. One think I can do is explicitly shorten the end of partA so that partB lines up, but it involves some mixing of content and structure. Is there a best practice for this situation? Thanks, Randy ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: issue with \transpose and \relative
Thanks a lot, David. It works as advertised. I do think I read about this somewhere in the manuals, but I couldn't find it. This uses really involved code to simulate something that does not > really map well to LilyPond's internals so it may interfere with other > tricky code. > I'm pretty sure that I'm not at the level of skill to be writing other tricky code, so no problem :-) For the benefit of anyone on the list who might find this useful, here's the simple function I'm using this in. It adds falling gliss lines *à la* sliding falls commonly notated in rock guitar music, and it's probably not a good implementation, but it works as I'd like it to: fall = #(define-music-function (input) (ly:music?) (make-relative (input) input #{ \afterGrace 16/16 << $input <>\glissando >> \transpose c g, { \once \omit Flag \once \override Stem.length = #0 \once \override NoteHead.font-size = #-50 \once \hideNotes $input } #})) Thanks, Randy ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user