Re: visualize-padding
Y > > All of my helper functions for overlaying stencils are really just > hacks; they might work for some grobs and fail for others. And when > things stop working, you just have to look for another hack. For > instance, if messing with the stencil for TupletBracket is not working, > perhaps you could use another grob to host the debug annotation. > TupletNumber might be more accepting of modification, which you should > be able to get via (ly:grob-object bracket-grob 'number). But be aware > that you might have to do things the other way around, working from > TupletNumber.after-line-breaking which would mean getting the bracket > from the number: (ly:grob-object number-grob 'bracket). > > > Your work is great. Finally all these properties are *clarified*, and they are very far from the obscure/missing/messed up documentation. We will have to talk again about this in the next days. (I did not think about the TupletNumber workaround. Thanks) Best, Paolo
Re: visualize-padding
On 2020-01-22 7:26 am, Paolo Prete wrote: The problem is associated with: https://lists.gnu.org/archive/html/lilypond-user/2020-01/msg00467.html Sorry if I insist again with this: is there a fix (or work-around) for it? The function is ***very*** useful, You can really see what happens with the discussed property, and you can really use therefore a ruler for fine tuning . I started to take a look at this, but got side-tracked. My work schedule is erratic at the best of days, plus I have been trying to get over a cold; so I am uncertain I will be able to dig in more deeply. My initial impression is that accessing certain properties out of sequence can cause problems. The NR includes a brief section on unpure-pure-containers mentioning how one must be careful when accessing properties relating to Y-axis concerns. Beam in particular is called out as something to avoid touching, and I imagine that TupletBracket cares about Beam. I also know there is internal caching of computed results at various stages of processing, so perhaps an unintended side-effect of these things is that it all goes awry when the normal pattern of access is interrupted. And since much of this work is done at the C++ level, it becomes difficult for Scheme code to influence effectively. All of my helper functions for overlaying stencils are really just hacks; they might work for some grobs and fail for others. And when things stop working, you just have to look for another hack. For instance, if messing with the stencil for TupletBracket is not working, perhaps you could use another grob to host the debug annotation. TupletNumber might be more accepting of modification, which you should be able to get via (ly:grob-object bracket-grob 'number). But be aware that you might have to do things the other way around, working from TupletNumber.after-line-breaking which would mean getting the bracket from the number: (ly:grob-object number-grob 'bracket). -- Aaron Hill
Re: HorizontalBracket's stencil
On Wed, Jan 22, 2020 at 8:47 PM Kieren MacMillan < kieren_macmil...@sympatico.ca> wrote: > Hi Rutger, > > > Cannot you fake it using a TupletBracket (\tuplet 1/1) and override the > TupletNumber.text? > > Absolutely — that’s a great solution. > > Hi Kieren and Rutger, Unfortunately I can't use this solution because I need to do the opposite: I have to fake a TupletBracket with a HorizontalBracket. I observed that TupletBracket is very buggy on cross-staff music. The padding properties are 1) blacklisted in the code itself or 2) lead to weird behavior (see this thread: https://lists.gnu.org/archive/html/lilypond-user/2020-01/msg00482.html ). And I observed that I don't have these issues with HorizontalBracket... The other (more flexible and configurable) solution is David Nalesnik’s > MeasureAttachedSpanner. > > Are you referring to this? http://lsr.di.unimi.it/LSR/Item?id=954 IIUC it only applies on a full measure, and not on a group of notes. Please correct me if I'm wrong. Best, P > Cheers, > Kieren. > > > Kieren MacMillan, composer (he/him/his) > ‣ website: www.kierenmacmillan.info > ‣ email: i...@kierenmacmillan.info > > >
Re: turning a markuplist into a chain of [individual] markups or strings
Hi David, > One element per note is tricky. How about making this a music > function instead that outputs lyrics? > > diffints = > #(define-music-function (mus) (ly:music?) > #{ \lyricmode { $@(map ...) } #}) For my current purposes, that’s perfect — thanks. My need (as originally stated) for a markup-list to be split is now more curiosity than necessity, so no need to spend more time on it unless you feel inspired. Thanks! Kieren. Kieren MacMillan, composer (he/him/his) ‣ website: www.kierenmacmillan.info ‣ email: i...@kierenmacmillan.info
Re: HorizontalBracket's stencil
Hi Rutger, > Cannot you fake it using a TupletBracket (\tuplet 1/1) and override the > TupletNumber.text? Absolutely — that’s a great solution. The other (more flexible and configurable) solution is David Nalesnik’s MeasureAttachedSpanner. Cheers, Kieren. Kieren MacMillan, composer (he/him/his) ‣ website: www.kierenmacmillan.info ‣ email: i...@kierenmacmillan.info
Re: HorizontalBracket's stencil
Cannot you fake it using a TupletBracket (\tuplet 1/1) and override the TupletNumber.text? Rutger On 1/22/20 8:14 PM, Paolo Prete wrote: Hello, is it possible to obtain a stencil, for a HorizontalBracket, similar to the TupletBracket one? Something like: some-text | | I see that there is a .bracket-flare property for the grob, but it's not enough for achieving this result. I wonder if at least I can copy the Scheme procedure for drawing the stencil from somewhere in the src of the project... thanks best, P
HorizontalBracket's stencil
Hello, is it possible to obtain a stencil, for a HorizontalBracket, similar to the TupletBracket one? Something like: some-text | | I see that there is a .bracket-flare property for the grob, but it's not enough for achieving this result. I wonder if at least I can copy the Scheme procedure for drawing the stencil from somewhere in the src of the project... thanks best, P
Re: turning a markuplist into a chain of [individual] markups or strings
David Kastrup writes: > Kieren MacMillan writes: > >> Hi David, >> >>> Uh, a markuplist typically _is_ a list of markups. Except when it isn't >>> (like when it is the result of calling a markup list command). But when >>> it isn't, you can only turn it into a list of stencils. >> >> Hmmm… So in my function >> >> #(define-markup-list-command (diffints layout props mus) (ly:music?) >>(interpret-markup-list layout props >> (map (lambda (d) (if (zero? d) "0" (format #f "~@d" d))) >>(let ((muspst (map ly:pitch-semitones (music-pitches mus >> (map - (cdr muspst) muspst) >> >> how can I output something where I can throw it into a Lyrics context and >> have it spaced out one element per note? > > Oh. One element per note is tricky. How about making this a music > function instead that outputs lyrics? > > diffints = > #(define-music-function (mus) (ly:music?) > #{ \lyricmode { $@(map ...) } #}) > > That's what I can suggest for now. But that request seems legitimate > enough that I'll see what it takes to make lyricmode accept a markup > list. You'd use it presumably as > > \markuplist [optional duration] Ah right. A markup list can be a markup list command, and the markup list command code is executed at typesetting time, based on current grob properties. The length of the markup list is not known before that point of time, so it is hard to produce a proper expression before that. In short, this is a lot more involved that it would appear at first sight. One would probably use a sequential expression with an elements-callback . -- David Kastrup
Re: turning a markuplist into a chain of [individual] markups or strings
Kieren MacMillan writes: > Hi David, > >> Uh, a markuplist typically _is_ a list of markups. Except when it isn't >> (like when it is the result of calling a markup list command). But when >> it isn't, you can only turn it into a list of stencils. > > Hmmm… So in my function > > #(define-markup-list-command (diffints layout props mus) (ly:music?) >(interpret-markup-list layout props > (map (lambda (d) (if (zero? d) "0" (format #f "~@d" d))) >(let ((muspst (map ly:pitch-semitones (music-pitches mus > (map - (cdr muspst) muspst) > > how can I output something where I can throw it into a Lyrics context and > have it spaced out one element per note? Oh. One element per note is tricky. How about making this a music function instead that outputs lyrics? diffints = #(define-music-function (mus) (ly:music?) #{ \lyricmode { $@(map ...) } #}) That's what I can suggest for now. But that request seems legitimate enough that I'll see what it takes to make lyricmode accept a markup list. You'd use it presumably as \markuplist [optional duration] But I have no idea what to do with things like hyphens at the end. Probably attach them to the last element. And the duration would likely be for all of the syllables? Or just the last? Not that it would be important since one would usually just use this in \lyricsto stuff where the syllable length gets overridden. -- David Kastrup
Re: [Scheme coding] turning a list into a markup/string
On Wed, Jan 22, 2020 at 8:26 AM Simon Albrecht wrote: > On 21.01.20 22:05, Kieren MacMillan wrote: > > I’m pretty sure I would have taken quite a while to find my way to > "make-simple-markup" > > > Note that > > (make-simple-markup "foo") > > is equivalent to > > (markup #:simple "foo") > > in other words it’s the spelled-out version of what’s usually accessed > through the markup macro in Scheme. > > HTH, Simon > And the Scheme functions are consistently named relative to the markup functions. make-concat-markup, make-column-markup, etc. DN > >
Re: Detecting double accidentals
Thank you David, that works perfectly. I would have probably never found this way, even if I understand what it does. Sorry for the late response, didn't expect an answer that fast. If anyone is interested in this project, the full code as well as a quick-and-dirty documentation is available as a gist on GitHub: https://gist.github.com/TheNothingMan/6f5daf540d55b4ad9138e3ff5d3ffbd0 Thank you, kind regards! Am Di., 21. Jan. 2020 um 21:50 Uhr schrieb David Kastrup : > SK writes: > > > Hello, > > > > I wrote a script for generating music theory worksheets for school. One > > feature is the generation of chords that should be named by the students. > > The way this function works is by simply transposing some predefined > chords > > to a new randomly generated root. To keep the difficulty controllable, I > > would like to filter out double accidentals in some cases, e.g. to not > > produce an augmented F# chord. > > Does anybody know about a way to check in scheme if music has double > > accidentals, or can think of another smart way of doing this? > > > > I would not want to define all possible chords manually, and I think that > > filtering out certain root notes is quite complex, too, if you just want > to > > avoid double accidentals. > > > > Kind regards! > > #(define (has-doubles mus) >(any (lambda (p) (not (< -1 (ly:pitch-alteration p) 1))) > (music-pitches mus))) > > #(display (map has-doubles > (list #{ c'4 d' e' fis' g' a' b' #} > #{ cisis'4 d' e' #}))) > > -- > David Kastrup >
visualize-padding (was: \offset Y-offset)
To Aaron (and any other helpful contributor): As you can see in the below snippet, the visualize-padding function you so kindly provided, doesn't work in some cases with TupletBracket. Here is a snippet where the bug occurs. The problem is associated with: https://lists.gnu.org/archive/html/lilypond-user/2020-01/msg00467.html Sorry if I insist again with this: is there a fix (or work-around) for it? The function is ***very*** useful, You can really see what happens with the discussed property, and you can really use therefore a ruler for fine tuning . Thanks for you help and your patience! % #(define color-good '(0.2 0.5 0.8)) #(define color-bad '(0.8 0.2 0.3)) #(define line-thickness 0.2) #(define whiteout-thickness 1.5) visualize-padding = #(define-music-function (grob-path color) (symbol-list? color?) (define (proc grob) (let* ((orig (ly:grob-property grob 'stencil)) (xex (ly:stencil-extent orig X)) (yex (ly:stencil-extent orig Y)) ;(yex (ly:make-unpure-pure-container ly:grob::stencil-height (lambda (grob start end) (ly:grob::stencil-height grob (dir (ly:grob-property grob 'direction)) (y (ly:grob-property grob 'padding))) (ly:grob-set-property! grob 'layer 1000) (ly:grob-set-property! grob 'stencil (grob-interpret-markup grob #{ \markup \overlay { \stencil #orig \with-dimensions-from \null \translate #(cons (interval-index xex 0) (interval-index yex (- dir))) \overlay { \with-color #color \override #'(style . outline) \override #`(thickness . ,whiteout-thickness) \whiteout \scale #(cons 1 (- dir)) \path #0.2 #`( (moveto 0 -2) (lineto 0 0) (moveto -0.5 -1) (lineto 0 0) (lineto 0.5 -1) (moveto -1 0) (lineto 1 0)) \with-color #color \override #'(style . outline) \override #`(thickness . ,whiteout-thickness) \whiteout \scale #(cons 1 dir) \translate #(cons 0 (- y)) \path #line-thickness #`( (moveto 0 -2) (lineto 0 0) (moveto -0.5 -1) (lineto 0 0) (lineto 0.5 -1) (moveto -1 0) (lineto 1 0)) } } #} #{ \override $grob-path .after-line-breaking = #proc #}) % upper = { { \visualize-padding TupletBracket #color-good \times 3/3 { c'''4*2/3-\fermata \change Staff = "lower" c'''4*2/3 g'''4*2/3 } c''' } } %end upper lower = { s4 s s} \score { \new PianoStaff << \new Staff = "upper" \upper \new Staff = "lower" \lower >> \layout { } \midi { } } %
Re: turning a markuplist into a chain of [individual] markups or strings
Hi David, > Uh, a markuplist typically _is_ a list of markups. Except when it isn't > (like when it is the result of calling a markup list command). But when > it isn't, you can only turn it into a list of stencils. Hmmm… So in my function #(define-markup-list-command (diffints layout props mus) (ly:music?) (interpret-markup-list layout props (map (lambda (d) (if (zero? d) "0" (format #f "~@d" d))) (let ((muspst (map ly:pitch-semitones (music-pitches mus (map - (cdr muspst) muspst) how can I output something where I can throw it into a Lyrics context and have it spaced out one element per note? Thanks, Kieren. Kieren MacMillan, composer (he/him/his) ‣ website: www.kierenmacmillan.info ‣ email: i...@kierenmacmillan.info
Re: [Scheme coding] turning a list into a markup/string
On 21.01.20 22:05, Kieren MacMillan wrote: I’m pretty sure I would have taken quite a while to find my way to "make-simple-markup" Note that (make-simple-markup "foo") is equivalent to (markup #:simple "foo") in other words it’s the spelled-out version of what’s usually accessed through the markup macro in Scheme. HTH, Simon
Re: [Scheme coding] turning a list into a markup/string
Hi David (N), > Exactly. Even though I took Mike's original more or less as-is and > just added a couple of things, I still got my fair share of errors. > With my memory I *always* end up looking up a few things. Well, that makes me feel a little better… Given the speed, complexity, and completeness of your [Scheme] responses, I’ve always just assumed you wave your hand, say something like “These aren’t the droids you’re looking for”, and it’s done! Onward and upward! Kieren. Kieren MacMillan, composer (he/him/his) ‣ website: www.kierenmacmillan.info ‣ email: i...@kierenmacmillan.info
Re: [Scheme coding] turning a list into a markup/string
On Wed, Jan 22, 2020 at 1:33 AM Urs Liska wrote: > > Am Dienstag, den 21.01.2020, 20:11 -0500 schrieb Kieren MacMillan: > > or the life of me, I can’t quite figure out where exactly such a > > construct would appear in the code. Everywhere I try throws > > [different] errors. =( > > I can promise you, it will be that way for a very long time. > But I can also promise you that at some point (and if you continue at > that pace that may be rather sooner than later) the errors will stop > scaring you and rather point you in the right direction. > > Remember when Mike coded the original function for you? He typed > something in to express an idea - and I think *every* such attempt > failed on first try. However, the error message made it immediately > clear to him where the mistake would be, he counted parenthesis and > directly fixed it. > Exactly. Even though I took Mike's original more or less as-is and just added a couple of things, I still got my fair share of errors. With my memory I *always* end up looking up a few things. The console messages help enormously. As does syntax highlighting. I'm awful at counting parentheses, and luckily I never have to do it. Best, David
Re: [Scheme coding] turning a list into a markup/string
Kieren MacMillan writes: > Hi David, > >> I'd use (lambda (d) (format "~@d" d)) here myself > > Good to learn that tool! > >> but it does differ in writing +0 (in case that's undesired). > > It is. > >> If one wants to avoid an unnecessary string-append, one can go >> (lambda (d) (let ((s number->string d)) >> (if (positive? s) (string-append "+" s) s))) > > I assume you’re missing a set of parentheses? Shouldn’t it rather be > > (lambda (d) (let ((s (number->string d))) > > ? Oops. Yes. -- David Kastrup
Re: [Scheme coding] turning a list into a markup/string
Hi Urs, > I can promise you, it will be that way for a very long time. Everyone on this list is so encouraging… ;) > But I can also promise you that at some point (and if you continue at > that pace that may be rather sooner than later) the errors will stop > scaring you and rather point you in the right direction. I’m starting to feel that shift already. > Remember when Mike coded the original function for you? He typed > something in to express an idea - and I think *every* such attempt > failed on first try. To be honest, he was typing and talking and coding so fast, I thought a wormhole had opened up in the space-time continuum. I blinked and he was done. ;) > I'm sure https://scheme-book.ursliska.de/scheme/expressions.html will > not give you any new information, but it may be worth reviewing it. The > topic was the "click" moment for me ... > Also, https://scheme-book.ursliska.de/scheme/concepts.html and > following/below might contain useful perspectives for you. I’m going to read (or at least skim) through the whole book, and get back to you with thoughts (as you requested some time ago; apologies for the delay). Thanks, Kieren. Kieren MacMillan, composer (he/him/his) ‣ website: www.kierenmacmillan.info ‣ email: i...@kierenmacmillan.info
Re: [Scheme coding] turning a list into a markup/string
Hi Aaron, > Instead of string-append and number->string, try (format #f "~@d" d). > > ~d formats an integer as a decimal value > @ includes "+" for positive values > > One caveat is it formats zero as "+0". > > Perhaps: (lambda (d) (if (zero? d) "0" (format #f "~@d" d))) That’s great — thanks! Kieren. Kieren MacMillan, composer (he/him/his) ‣ website: www.kierenmacmillan.info ‣ email: i...@kierenmacmillan.info
Re: [Scheme coding] turning a list into a markup/string
Hi David, > I'd use (lambda (d) (format "~@d" d)) here myself Good to learn that tool! > but it does differ in writing +0 (in case that's undesired). It is. > If one wants to avoid an unnecessary string-append, one can go > (lambda (d) (let ((s number->string d)) > (if (positive? s) (string-append "+" s) s))) I assume you’re missing a set of parentheses? Shouldn’t it rather be (lambda (d) (let ((s (number->string d))) ? Thanks, Kieren. Kieren MacMillan, composer (he/him/his) ‣ website: www.kierenmacmillan.info ‣ email: i...@kierenmacmillan.info
Re: turning a markuplist into a chain of [individual] markups or strings
Kieren MacMillan writes: > Hi all, > > Is there a way to turn a markuplist into individual markups or strings? > > I have a markuplist of lyrics > > (a b c) > > and I’d like to turn that into a chain of markups > >\lyricmode { \markup a \markup b \markup c } > > or strings > > \lyricmode { "a" "b" "c" } > > What function do I use? Uh, a markuplist typically _is_ a list of markups. Except when it isn't (like when it is the result of calling a markup list command). But when it isn't, you can only turn it into a list of stencils. -- David Kastrup
Re: [Scheme coding] turning a list into a markup/string
Kieren MacMillan writes: > HOLD THE PRESSES!! > > I think I have it: > > SNIPPET BEGINS > \version "2.19.83" > > some-music = { a'4 bes' b' aes' g' cis' d' ees' fis' f' e' c' } > > #(define-markup-list-command (diffints layout props mus) (ly:music?) >(interpret-markup-list layout props > (map (lambda (d) (string-append (if (positive? d) "+" "") > (number->string d))) >(let ((muspst (map ly:pitch-semitones (music-pitches mus > (map - (cdr muspst) muspst) > > \markup \line \with-color #red \diffints #some-music > \markup \line \with-color #red \diffints ##{ c' d' e' c' #} > SNIPPET ENDS > > Comments and code critique appreciated. I'd use (lambda (d) (format "~@d" d)) here myself but it does differ in writing +0 (in case that's undesired). If one wants to avoid an unnecessary string-append, one can go (lambda (d) (let ((s number->string d)) (if (positive? s) (string-append "+" s) s))) but of course that is not exactly saving space. -- David Kastrup
Re: [Scheme coding] turning a list into a markup/string
At 17:03 21/01/2020 -0500, Kieren MacMillan wrote: ... it seemed a wonderfully magical start out of the gate, but we were ultimately unable to take it to the goal-line. Also, I mixed my sporting metaphors in that sentence; oh well. That's nothing: a moment ago we had someone playing football whilst fishing up a mountain! Brian Barker