Re: How to pass a fraction as a parameter for a Scheme function

2020-06-09 Thread Aaron Hill

On 2020-06-09 12:43 pm, Paolo Prete wrote:

Hello,

I don't understand how to use a fraction as a parameter for a scheme
function. More specifically, this gives me an error:



proportionalNotationDur = #(define-music-function (parser location 
frac)

(scheme?)  #{ \set
Score.proportionalNotationDuration = #(ly:make-moment frac) #})
{
  \proportionalNotationDur 1/16
  c' c' c' c'
}




You should use the fraction? type predicate if you want to accept 1/16 
for input.  The resulting value is a pair with the numerator as the car 
and the denominator as the cdr.


Alternately, you can use the rational? type predicate so the value is 
numeric.  However, you will then need to use Scheme syntax for the 
input: #1/16 instead of 1/16.



-- Aaron Hill



Re: Regexp Functions

2020-06-08 Thread Aaron Hill

On 2020-06-08 12:47 pm, Caio Barros wrote:

Hello!

Em seg., 8 de jun. de 2020 às 08:37, Freeman Gilmore <
freeman.gilm...@gmail.com> escreveu:


If the string is   "A ... B ... " , using Regexp Functions is it
possible, if 'A' matches [-] then 'B' would be replaced by "C"?'A'
is first in the string.  Position of B is not constant.and may not be
there.



Can you provide a little more context of what you are trying to do and 
what
this has to to with lilypond? What tools are you using to find and 
replace

strings using regex?


LilyPond -> Guile -> (use-modules (ice-9 regex))

Or I could be making the wrong assumption here.  ¯\_(ツ)_/¯


(display
  (regexp-substitute/global #f
(make-regexp "(^A.*)B" regexp/newline)
(string-join '("A ... B ..." "D ... B ..."
   "A ... E ..." "A ... B ...")
 "\n" 'suffix)
'pre 1 "C" 'post))



A ... C ...
D ... B ...
A ... E ...
A ... C ...


The key here is to use a capturing group for the portion of the string 
before "B" that you need to preserve in the substitution.



-- Aaron Hill



Re: Regexp Functions

2020-06-09 Thread Aaron Hill

On 2020-06-09 9:25 am, Michael Gerdau wrote:

[sent this earlier and forgot to include the list...]


That definition helps. I use the Guile manual, the section Regular
Expressions is miss leading about what is there.I only went there
because Arron Hill told me about it And the introduction states "A
full description of regular expressions and their syntax is beyond the
scope of this manual"; and the URL goes nowhere.   And I would guess
knowing what to read elsewhere that is consistent with the guile
version Lilypond uses may be a probleblen.   I am open to a good ron
cryptic reference?


I personally really like the perlre manpage. It is THE reference for
all Perl Regular Expressions from which many other current regexp
engines are derived.


Just be aware that Guile uses GNU's version of POSIX extended regular 
expressions (ERE), which is significantly more limited than 
Perl-compatible regular expressions (PCRE).


GNU adds some features beyond the core POSIX standard, such as 
shorthands for word characters (\w) and whitespace (\s).  But it omits 
the one for digits (\d) that is included in PCRE.  Instead, one must use 
either /[0-9]/ or /[[:digit:]]/, the latter being an example of a POSIX 
character class.


GNU ERE includes support for the {,n} quantifier that matches an item 
between zero and n times; however, quantifiers in POSIX ERE are always 
greedy, whereas PCRE supports lazy and possessive variants.


POSIX ERE permits only basic unnamed capturing groups, although GNU ERE 
does add support for backreferences: /.(.)(.)\2\1/ will match 'xyzzy'.  
However, PCRE additionally handles non-capturing groups, named groups, 
and many forms of lookarounds and conditionals.



-- Aaron Hill



Re: How to pass a fraction as a parameter for a Scheme function

2020-06-12 Thread Aaron Hill

On 2020-06-10 10:28 am, Paolo Prete wrote:

... I have been misled by the term "rational". In fact, in the italian
language the term "rational" (---> razionale)  means an irreducible
fraction of two coprime integers, while in the english language it 
means a

number that can be expressed as the quotient or fraction p/q of two
integers.
For example, "2/4" is not rational in italian, but it is rational in
english. Then I did not even consider that predicate.
I suggest the italian maintainer of the translation to keep note of 
this

ambiguity.


I would not be so hasty.

A rational value and a fraction are two related but distinct things.  A 
fraction is the thing that consists of a numerator and a denominator, 
whereas the rational value is the ratio between the two components of 
the fraction.  So to say "2/4 is rational in English" is potentially 
misleading.  Regardless of native tongue, 2/4 is specifically a fraction 
that simply has a rational value of 1:2.  2/4 is not the rational value, 
1:2 is.  2/4 may be reduced to 1/2 which shares the same ratio, so we 
would say we have two fractions but only one rational value.


Connecting the above to Scheme, fraction? and rational? are distinct 
type predicates.  A fraction? is simply a pair of numbers--the car 
holding the numerator, the cdr holding the denominator.  On the other 
hand, a rational? refers to one of the primitive numeric types.  Of most 
importance, a rational? will be reduced whereas a fraction? will 
preserve the original numerator and denominator.


Going back to the original question regarding fractions, my suggested 
use of rational? would *not* be useful if you need to preserve the 
original numerator and denominator.  Otherwise, things like 4/4 and 2/2 
would look identical to the function.  In fact, the function would 
simply see the integer 1 as input for #4/4.  If all that was needed was 
to specify a duration, then it might not matter since four quarters is 
the same as two halves.  However then, David's suggestion of using 
ly:duration? would make much more sense.



-- Aaron Hill



Re: Absolute font-size for TextScript

2020-06-02 Thread Aaron Hill

On 2020-06-02 2:00 pm, Paolo Prete wrote:

On Tue, Jun 2, 2020 at 8:57 PM Kieren MacMillan <
kieren_macmil...@sympatico.ca> wrote:


Hi Paolo,

> is it possible to set an absolute font-size for *all* the TextScript
objects?


As is tradition, I am almost certainly over-engineering here.  However, 
would the following approach be of any use:



\version "2.20.0"

transformText =
#(define-music-function
  (grob-path proc)
  ((key-list? 'TextScript) procedure?)
  #{ \override $grob-path . before-line-breaking =
   #(grob-transformer 'before-line-breaking
 (lambda (grob orig)
   (ly:grob-set-property! grob 'text
 (proc (ly:grob-property grob 'text) #})

boxIt = #(lambda (text) (markup #:box text))
flipIt = #(lambda (text) (markup #:rotate 180 text))
sizeIt =
#(define-scheme-function (size) (number?)
  (lambda (text) (markup #:abs-fontsize size text)))

\layout {
  \context {
\Staff
\transformText \sizeIt #8
  }
}

\score {
  \new Staff { b'2.^"Lorem" \once \transformText \boxIt b'4_"ipsum" }
  \layout { #(layout-set-staff-size 8) }
}
\score {
  \new Staff { b'2.^"Lorem" b'4_"ipsum" }
  \layout { #(layout-set-staff-size 13) }
}
\score {
  \new Staff { \once \transformText \flipIt b'2.^"Lorem" b'4_"ipsum" }
  \layout { #(layout-set-staff-size 21) }
}



-- Aaron Hill

Re: Combining multiple markups into a single, word-wrappable one?

2020-07-28 Thread Aaron Hill

On 2020-07-28 10:15 am, David Kastrup wrote:

Aaron Hill  writes:


Feels like a hack, but would this help?


\version "2.20.0"

loremIpsum = \markuplist {
  \bold { Lorem ipsum } dolor sit amet,
  \italic consectetur adipiscing elit.
}

\markup {
  \override #'(line-width . 40)
  \wordwrap { $@loremIpsum $@loremIpsum $@loremIpsum }
}



Why $@loremIpsum rather than \loremIpsum ?


Because it does not work:


GNU LilyPond 2.20.0
Processing `markuplist.ly'
Parsing...
markuplist.ly:11:39: error: not a markup
  \wordwrap { \loremIpsum \loremIpsum
  \loremIpsum }
/usr/local/lilypond/usr/share/lilypond/current/scm/lily.scm:1093:21: In 
procedure reverse! in expression (ly:parse-file file-name):
/usr/local/lilypond/usr/share/lilypond/current/scm/lily.scm:1093:21: 
Wrong type argument in position 1: ("" (#props arg)> "Lorem") "elit." "adipiscing" (#(layout props arg)> "consectetur") "amet," "sit" "dolor" (#bold-markup (layout props arg)> "ipsum") . #-7#)




-- Aaron Hill



Re: Combining multiple markups into a single, word-wrappable one?

2020-07-27 Thread Aaron Hill

On 2020-07-27 7:58 pm, Mike Stickles wrote:

In the weekly service files I'm generating for my church, near the end
is the text for a dismissal prayer. This prayer pretty much always has
the same beginning and ending text, but a section in the middle varies
from service to service. I've been trying (without success) to encode
these in variables so I can have the beginning and ending pre-coded in
my template, and just have the middle part in the include file for
that service.

In other words, I'm trying to turn something like this:

\markup {
    \column { \override #'(line-width . 92) {
        \wordwrap {
            This is the beginning of the rather long dismissal prayer,
which would be in the first variable;
            followed here by the service-specific part which goes in
the include file;
            and then this part, which would be in the second variable,
goes at the end to complete the prayer.
        }
    } }
}

Into something like this:

PrayerBeginning = \markup { This is the beginning of the rather long
dismissal prayer, which would be in the first variable; }
PrayerEnding = \markup { and then this part, which would be in the
second variable, goes at the end to complete the prayer. }
TodaysMiddle = \markup { followed here by the service-specific part
which goes in the include file; }

\markup {
    \column { \override #'(line-width . 92) {
        \wordwrap {
            \PrayerBeginning
            \TodaysMiddle
            \PrayerEnding
        }
    } }
}

And have it still print as a single, word-wrapped paragraph.
Unfortunately, this (and every variation I've tried that will actually
compile) treats each variable as if the text it represents were
enclosed in double-quotes as a single string.

Does anyone know if this is even possible, and if so, how would I do 
it?


Feels like a hack, but would this help?


\version "2.20.0"

loremIpsum = \markuplist {
  \bold { Lorem ipsum } dolor sit amet,
  \italic consectetur adipiscing elit.
}

\markup {
  \override #'(line-width . 40)
  \wordwrap { $@loremIpsum $@loremIpsum $@loremIpsum }
}



-- Aaron Hill

Re: Arguments before functions

2020-07-19 Thread Aaron Hill

On 2020-07-19 11:16 am, Fr. Samuel Springuel wrote:
Is there a way for a music function to operate on the note that 
precedes it?


Rather than try to work around the plumbing of LilyPond, might I suggest 
the following:



\version "2.20.0"

noteTemplate =
#(define-scheme-function
  (reference-note) (ly:music?)
  (define-music-function
(pitch) (ly:pitch?)
(let ((note (ly:music-deep-copy reference-note)))
  (ly:music-set-property! note 'pitch pitch)
  note)))

middle = \noteTemplate 2^"*"
final = \noteTemplate 2.--

\fixed c' { \cadenzaOn a4 g \middle b g8[ f] g4_( \final c') \bar "|" }
\fixed c' { \cadenzaOn g4 f8[ d] e4 \middle e g4 a \final g \bar "|" }


This approach allows you to create a template of sorts for individual 
notes.  Above is an example usage to aid with pointing, supporting the 
middle of a phrase and the final tone.



-- Aaron Hill

Re: Tie position with sharps

2020-07-23 Thread Aaron Hill

On 2020-07-23 4:38 pm, Aaron Hill wrote:

On 2020-07-23 3:14 pm, Lukas-Fabian Moser wrote:

Hi,

consider:

\version "2.21.0"

\relative {
  g'1~ \break
  g^"normal tie"
}

\relative {
  ges'1~ \break
  ges^"low tie"
}

\relative {
  gis'1~ \break
  gis^"low tie"
}

I understand why the tie at the beginning of the second system of each
example has to sit a little bit lower if there is an accidental in the
way; but isn't the tie position in the third example (with sharp) a
trifle _too_ far down?


Attached is an image that compares the distance relative to the tie.
You can see the flat sits a little more snugly.

It would seem the tie is preferring to vertically align to staff
lines/positions.  After manually overlaying the ties in my image
editor, the staff lines are perfectly overlapping as well, albeit one
staff space lower.

The sharp extends low enough forcing the tie down an entire staff
space.  But this results in a slightly larger gap, because there is
slightly less than a staff space difference between the flat and
sharp's lower extent.


Now with the correct attachment.  (I *hate* email... no ability to edit 
without making noise.)



-- Aaron Hill

Re: Tie position with sharps

2020-07-23 Thread Aaron Hill

On 2020-07-23 3:14 pm, Lukas-Fabian Moser wrote:

Hi,

consider:

\version "2.21.0"

\relative {
  g'1~ \break
  g^"normal tie"
}

\relative {
  ges'1~ \break
  ges^"low tie"
}

\relative {
  gis'1~ \break
  gis^"low tie"
}

I understand why the tie at the beginning of the second system of each
example has to sit a little bit lower if there is an accidental in the
way; but isn't the tie position in the third example (with sharp) a
trifle _too_ far down?


Attached is an image that compares the distance relative to the tie.  
You can see the flat sits a little more snugly.


It would seem the tie is preferring to vertically align to staff 
lines/positions.  After manually overlaying the ties in my image editor, 
the staff lines are perfectly overlapping as well, albeit one staff 
space lower.


The sharp extends low enough forcing the tie down an entire staff space. 
 But this results in a slightly larger gap, because there is slightly 
less than a staff space difference between the flat and sharp's lower 
extent.



-- Aaron Hill

Re: detecting the start and end of a polyphonic passage from scheme

2020-07-01 Thread Aaron Hill

On 2020-07-01 2:07 am, Maurits Lamers wrote:

Follow up question: is there a way to know the "parent" of the voices
as they are defined in the code?
In the following example, I would like to determine that voice "two"
splits off from voice "one" without relying on the context-id.
(ly:context-parent ctx) gives me the staff, not the "parent voice"...

[...]


If I am not mistaken, Voices do not form a hierarchy with each other.  
The parent context will always be some form of Staff.  Consider:



\version "2.20.0"

\new Voice = outer { e'8 g' \new Voice = inner { a'2 } b'4 }


LilyPond syntax might make it appear as if one Voice is "inside" 
another, but that is an illusion.  In reality, the two voices are in 
parallel with each other.  The inlining of the inner Voice here only 
serves to keep the outer Voice alive.


Here is an alternate way to view the above:


\version "2.20.0"

{
  \new Voice = outer { e'8 g' }
  <<
\context Voice = outer { s2 }
\new Voice = inner { a'2 }
  >>
  \context Voice = outer { b'4 }
}


Hopefully it is more clear that the two Voices are siblings, not 
parent-child.



-- Aaron Hill



Re: Including only definitions from a Lilypond file

2020-08-14 Thread Aaron Hill

On 2020-08-14 4:48 am, David Kastrup wrote:

All of the elements in a score are routed through hooks you can
redefine.  So you can just redefine your various hooks to do nothing 
and

then include the file.


Would something like this work?


\version "2.20.0"

#(begin
  (use-modules (ice-9 regex))
  (let* ((symbols
   (map (lambda (m) (string->symbol (match:substring m 1)))
(list-matches "define ([a-z-]+-handler)"
  (ly:gulp-file "declarations-init.ly"
 (procs (map primitive-eval symbols))
 (null-proc (lambda args #f)))
(ly:parser-define! 'disableHandlers
  (define-void-function () ()
(for-each
  (lambda (sym) (primitive-eval `(set! ,sym ,null-proc)))
  symbols)))
(ly:parser-define! 'restoreHandlers
  (define-void-function () ()
(for-each
  (lambda (sym proc) (primitive-eval `(set! ,sym ,proc)))
  symbols procs)

assert =
#(define-void-function
  (expr)
  (scheme?)
  (or (primitive-eval expr)
  (ly:error "Assertion failed: ~s" expr)))

\disableHandlers

foo = { f'4 4 2 }
\assert #'(defined? 'foo)

\markup "Hidden"
{ \foo }
\assert #'(eq? 0 (length toplevel-scores))

\restoreHandlers

\markup "Visible"
{ \foo }
\assert #'(eq? 2 (length toplevel-scores))



-- Aaron Hill



Re: Lyrics as verses or in system?

2021-01-11 Thread Aaron Hill

On 2021-01-11 7:30 pm, Peter Chubb wrote:

Hi,
  When I'm typesetting hymns, I'd like to be able to enter lyrics once
  only, so that they are between the staves of a system for the choir,
  and below a single melody line for the congregation.

  Is there an easy way to join syllables and strip durations,
  underscores, hyphens, and extenders from a lyricmode block to create
  a markup block?


See LSR #744 [1].

[1]: http://lsr.di.unimi.it/LSR/Item?id=744


-- Aaron Hill



Re: keyAlterationOrder

2020-12-28 Thread Aaron Hill
I know that the alist cannot be read with assoc, at least in its 
simple

form.

Why not?

assoc would read the first key of a given value none of the others keys 
of

the same value would be read in the chain.


It is at best a stretch to call this property an association list to 
begin with.  An alist is a list of key-value pairs; but this property is 
a list of step-alteration pairs with no associative semantics.  To use 
this list, you need only filter it to the items you are interested in, 
and the resulting list will have the items in the desired order.  
Consider this contrived example:



\version "2.20.0"

\new Voice {
  \applyContext
  #(lambda (context)
(let ((keyAlterationOrder
   (ly:context-property context 'keyAlterationOrder))
  (pitches #{ \fixed c' { cis dis ees fis gis aes bes } #}))
 (set! pitches (map (lambda (pitch)
 (cons (ly:pitch-steps pitch)
   (ly:pitch-alteration pitch)))
(music-pitches pitches)))
 (format #t "\n  Unordered: ~s" pitches)
 (format #t "\nOrdered: ~s"
  (filter
   (lambda (elem) (member elem pitches))
   keyAlterationOrder
}


Parsing...
Interpreting music...
  Unordered: ((0 . 1/2) (1 . 1/2) (2 . -1/2) (3 . 1/2) (4 . 1/2) (5 . 
-1/2) (6 . -1/2))
Ordered: ((6 . -1/2) (2 . -1/2) (5 . -1/2) (3 . 1/2) (0 . 1/2) (4 . 
1/2) (1 . 1/2))



Converted from (step . alteration) back to pitch, the final order is: Bb 
Eb Ab F# C# G# D#.  This should make sense given the standard convention 
of how flats and sharps are arranged.




One question though,   Does the key signature affect the midi output?


Yes, Key_performer generates a key signature meta event (FF 59).


-- Aaron Hill



Re: \with-dimensions partially

2020-12-26 Thread Aaron Hill

On 2020-12-26 1:12 pm, Fr. Samuel Springuel wrote:

Is there a way to set the horizontal dimensions of a markup to 0 while
leaving the vertical dimensions alone?

I’ve got the following as a start, but it zeros both X and Y
dimensions.  Ideally I’d like the second argument to be computed
automatically:

Cantor = \markup \with-dimensions #'(0 . 0) #'(0 . 0) {\italic 
Cantors:}


Just need to define some custom markup functions.  Consider these 
potential options:



\version "2.20.0"

#(define-markup-command
  (with-dimension layout props axis interval markup)
  (number? number-pair? markup?)
  (let* ((sten (interpret-markup layout props markup))
 (xex (ly:stencil-extent sten X))
 (yex (ly:stencil-extent sten Y)))
   (ly:make-stencil
(ly:stencil-expr sten)
(if (eq? X axis) interval xex)
(if (eq? Y axis) interval yex

#(define-markup-command
  (with-relative-dimensions layout props x-interval y-interval markup)
  (number-pair? number-pair? markup?)
  (define (interval-reindex interval indices)
   (cons
(interval-index interval (car indices))
(interval-index interval (cdr indices
  (let* ((sten (interpret-markup layout props markup))
 (xex (ly:stencil-extent sten X))
 (yex (ly:stencil-extent sten Y)))
   (ly:make-stencil
(ly:stencil-expr sten)
(interval-reindex xex x-interval)
(interval-reindex yex y-interval

\markup {
  Lorem
  \circle \with-dimension #X #'(-1.5 . 1) \center-align !
  \circle \with-dimension #Y #'(-1 . 1.5) \vcenter !
  ipsum
  dolor
  \box \with-relative-dimensions #'(-1.5 . 1.5) #'(-0.5 . 0.5) sit
  amet.
}


\with-dimension is like \with-dimensions but you specify which axis you 
want to modify.


\with-relative-dimensions is like \with-dimensions but the two intervals 
are computed relative to the extents of the markup, recalling that 
LEFT=DOWN=-1, CENTER=0, RIGHT=UP=1.  And of course you can use any 
values in-between or outside those as desired.



-- Aaron Hill

Re: Staff space size

2021-01-06 Thread Aaron Hill

On 2021-01-06 6:41 pm, Andrew Bernard wrote:

If staff height is 20 points, then what is the staff space size? Maybe
I am overthinking this but suddenly I thought there may be some factor
of including or not including the staff lines in the measurement. It
is not immediately apparent to me where staff space is defined in the
NR.

Somebody help out my overworked brain!

All the best to all for 2021.


If you are open to looking at the code, see 
layout-set-absolute-staff-size-in-module in paper.scm.


The default staff size is indeed 20pt.  For a standard 5-live staff 
symbol, the staff height is 4 staff spaces.  As such, a staff space is 
then by default 5pt.  Note that this is not the actual space between ink 
rather it is the distance between staff lines *on center*.  The actual 
whitespace measurement would then be the staff space less the staff line 
thickness.


Line thickness is computed based on a linear interpolation.  From a 
comment in feta-params.mf, the line thickness measured from reference 
scores was generally 0.5pt irrespective of staff size; however, it was 
determined that smaller staff sizes in LilyPond should use a little less 
ink.  For the default staff space of 5pt, then line thickness is exactly 
0.5pt.  However, as staff space drops to 4.125pt, line thickness should 
only reduce to 0.47pt.



-- Aaron Hill



Re: LilyPond to Scheme to Lilypond and variadic function

2020-11-26 Thread Aaron Hill

(Adding mailing list for visibility...)

On 2020-11-26 5:27 pm, Daniel Tomas wrote:

We are trying to pass from LilyPond code a list of smaller lists, which
contains musical data to a function func1 which will also use many 
LilyPond
code and send musical elements also to another function func2 which 
also
will return musical data. I hope this sentence make more clear what i 
mean.
Until now i only receive information about Scheme, but i think there 
are 2

things to keep in mind :
a) How to call it from LilyPond code ?


While this is not the entire solution, it is important to know that you 
can use sequential music within simultaneous music to get lists of lists 
of music.  Here's an example focusing just on pitches:



\version "2.20.0"

#(define (simultaneous-music? arg)
  (and (ly:music? arg) (music-is-of-type? arg 'simultaneous-music)))

music-to-lists-of-pitches =
#(define-void-function
  (lists-of-pitches)
  (simultaneous-music?)
  (set! lists-of-pitches
   (map music-pitches
(extract-typed-music lists-of-pitches 'sequential-music)))
  (format #t "~{\n pitches: ~{~s~^ ~}~}" lists-of-pitches))

\music-to-lists-of-pitches
  << { d ees fis } \relative { g, g, a' a' } \fixed c' { b r c' } >>


Parsing...
 pitches: # # #
 pitches: # # # #
 pitches: # #
Success: compilation successfully completed


What is nice here is that you can take advantage of commands like 
\relative and \fixed.




b) I suppose we need to use *define-music-function *because we need to
write more musical sentences and LilyPond need to have information 
about

musical sheets contexts in order to process returned music.
define-music-function
contains 2 more variables, and i think there will need that.


Yes, define-music-function would be appropriate if it is your intention 
to return music from the procedure to be used within the wider context.  
But you can technically use any regular procedure to return musical 
information:



\version "2.20.0"

#(define (foo a b c)
  (make-music 'NoteEvent
   'pitch (ly:make-pitch a b)
   'duration (ly:make-duration c)))

#(define (baz a b) (ly:make-duration a b))

{ a'2 #(foo 0 6 2) g'4 | a'2 b' $(baz 2 1) g'8 }



I already have some clues about this points : If we send a list in form 
of
Scheme, LilyPond will not confuse with posterior elements. Now, i am 
not

very clear about how to write it from LilyPond, like that : ?
#(func1 (ls1 ls2 ls3 ... lsn))
?
But each ls(i) contains also musical information like 'd4'. How to 
write

them from within Scheme, like this : ?
#(func1 ( (#{ d4 #}  3 4) (#{ e4 #} 2 3 ...)))
?
I only guess i write it wrong, but you have some clues about how to 
write

it ?


You would need to use the list procedure to create a list in such 
syntax, or you could use quoting/quasi-quoting:



\version "2.20.0"

#(define (print-pitches lists-of-pitches)
  (format #t "~{\n pitches: ~{~s~^ ~}~}" lists-of-pitches))

#(print-pitches
  (list (list #{ d #} #{ ees #} #{ fis #})
(list #{ g, #} #{ a' #})))
#(print-pitches
  `((,#{ d #} ,#{ ees #} ,#{ fis #})
(,#{ g, #} ,#{ a' #})))


Parsing...
 pitches: # # #
 pitches: # #
 pitches: # # #
 pitches: # #
Success: compilation successfully completed


But this option is less ideal as the #{ #} syntax would quickly become 
cumbersome.


The challenge is being able to use LilyPond music syntax and mixing in 
arbitrary data.  Here is potentially one way to do that:



\version "2.20.0"

#(define (define-music-descriptions new-descriptions)
  ;; Logic borrowed from define-music-types.scm
  (set! new-descriptions
   (map
(lambda (x)
 (set-object-property! (car x)
  'music-description (cdr (assq 'description (cdr x
 (let ((lst (cdr x)))
  (set! lst (assoc-set! lst 'name (car x)))
  (set! lst (assq-remove! lst 'description))
  (hashq-set! music-name-to-property-table (car x) lst)
  (cons (car x) lst)))
new-descriptions))
  (set! music-descriptions
(sort (append music-descriptions new-descriptions) alist, duration=#
 [data] value=3
 [note] pitch=#, duration=#
 [data] value="foo"
 [note] pitch=#, duration=#
Success: compilation successfully completed



-- Aaron Hill



Re: Line spacing (leading) of verses in a hymn

2020-11-27 Thread Aaron Hill

On 2020-11-27 1:32 pm, Matthew Fong wrote:

After some searching on the Internet, and looking at the LyricsText
engraver, I was not able to find
anything; VerticalAxisGroup.nonstaff-relatedstaff-spacing.padding
definitely was not it.


VerticalAxisGroup definitely is it.  You are just using the wrong 
spacing parameter.  Lyrics are a "nonstaff" item, so you need to adjust 
nonstaff-nonstaff-spacing.  Also, you do not want padding, as that is 
the distance between ink.  You need basic-distance, which for Lyrics is 
measured from baseline to baseline.



\version "2.20.0"

\score {
  <<
\new Staff \new Voice = melody { b'8 8 g'4 a'2 }
\new Lyrics \lyricsto melody { Lo -- rem ip -- sum }
\new Lyrics \lyricsto melody { Lo -- rem ip -- sum }
  >>
  \layout {
\context {
  \Lyrics
  \override LyricText.font-size =
% Default font-size is 11pt.  Scale to 10pt.
#(magnification->font-size 10/11)
  \override VerticalAxisGroup.nonstaff-nonstaff-spacing =
% Default staff space is 5pt.  Scale to 12pt.
#'((basic-distance . 12/5) (minimum-distance . 0)
   (padding . 0) (stretchability . 0))
}
  }
}



-- Aaron Hill



Re: Line spacing (leading) of verses in a hymn

2020-11-27 Thread Aaron Hill

On 2020-11-27 2:56 pm, Matthew Fong wrote:

Hello Aaron,

Ah, I didn't dig deeply enough!
https://lilypond.org/doc/v2.20/Documentation/notation/flexible-vertical-spacing-within-systems#within_002dsystem-spacing-properties
https://lilypond.org/doc/v2.20/Documentation/notation/flexible-vertical-spacing-within-systems#spacing-of-non_002dstaff-lines

Your example and the documentation are in perfect accord. And I played
around with it. However, when I plug it into my LilyPond file, it
*compresses* considerably (!) Please see attached picture. I put all my
Lyrics settings into your example and it still works as expected.


That would be my mistake.  I forgot to also set minimum-distance so that 
it does not compress.  My example works only because there is no 
pressure to reduce spacing.


Use the same value for basic-distance and minimum-distance, and it 
should work.



-- Aaron Hill



Re: Line spacing (leading) of verses in a hymn

2020-11-27 Thread Aaron Hill

On 2020-11-27 4:28 pm, Matthew Fong wrote:

Hello Aaron,

With respect to the scale factor of 5 that you are using. Is that 
depending

on staff size?

I'm using #(layout-set-staff-size 18) at the moment.


Yes, my comment mentioned the default staff space as 5pt.  That is a 
20pt staff size divided by 4 based on the standard 5-line staff symbol.


If you know you have a fixed staff size of 18pt, you could just 
calculate the distance by hand.  24/9 should be it, unless I flubbed my 
math.  But if you don't feel like doing any manual computation...



  \override VerticalAxisGroup.nonstaff-nonstaff-spacing =
#(lambda (grob)
  (define (pt n)
(* n (ly:output-def-lookup (ly:grob-layout grob) 'pt)))
  `((basic-distance . ,(pt 12))
(minimum-distance . ,(pt 12))
(padding . 0) (stretchability . 0)))



-- Aaron Hill



Re: LilyPond to Scheme to Lilypond and variadic function

2020-11-25 Thread Aaron Hill

On 2020-11-25 3:27 pm, Daniel Tomas wrote:
(First question is : is it better to answer before or after what we 
have

written before ?)


This is the classic topic of top-posting vs. bottom-posting.  Some folks 
like myself prefer bottom-posting (or what I think is better called 
inline-posting), as we can keep our replies located closely to the 
original quoted context.  For instance, your first question here can be 
better addressed if I reply directly below it.  With top-posting, I 
would need to carefully restate any questions to ensure readers can 
follow the discussion.  When there are multiple questions or issues to 
discuss, top-posting can result in a large body of text that may be 
harder to consume.


Top-posting can make sense as it lets you put important information 
first.  However, care must be taken not to allow the bottom of the email 
to grow unbounded by the continual requoting of old content.  Some mail 
clients hide this quoted material from the user so you may think you are 
only posting a few sentences, but in reality your email contains the 
entire thread.  Ultimately, it is a good practice to trim unnecessary 
quoted material, regardless of whether you post above it or below.



I try to use optional arguments, but may be it would not be possible 
from

within LilyPond code call this function. I give that example :
[...]
Now i give definition of MTKeyExp :
*MTKeyExp *=  #(define-music-function
(parser location name mainNote textBelowMain cyclic . rest)
(string? ly:music? string? boolean? ly:music? number? 
number?)

(let-optional rest ((note1 d'4) (num1 2) (den1 1))
[...]


That is not the proper way to do optional arguments for LilyPond 
functions.  Additionally, optional arguments have restrictions based on 
how the parser works.  Consider:



\version "2.20.0"

foo =
#(define-void-function
  (first second)
  ((boolean? #f) ;; Optional arguments are specified by joining
 ;; the type predicate with an expression to be
 ;; used as the default value.
   number?)  ;; The final argument must be a required one.
  (format #t "\n (foo ~s ~s)" first second))

\foo 12
\foo ##t 34

baz =
#(define-void-function
  (first second third)
  ((number? #f) ;; The default value need not match the type
;; predicate of the argument; however, just be
;; aware such usage could be confusing to folks
;; who may review the procedure.
   (number? 0)  ;; Two optional arguments in sequence may have
;; the same type predicate; but, know that the
;; parser will assign values left-to-right.
;; In this case, the user will be unable to
;; specify the second argument without also
;; passing a value for the first.
   string?)
  (format #t "\n (baz ~s ~s ~s)" first second third))

\baz alpha
\baz 12 bravo
\baz 34 56 charlie


Parsing...
 (foo #f 12)
 (foo #t 34)
 (baz #f 0 "alpha")
 (baz 12 0 "bravo")
 (baz 34 56 "charlie")
Success: compilation successfully completed


NOTE: I cannot really speak to the rest of your queries, as I do not 
understand the problem space you are working in.  But I am hopeful the 
above may help you refactor your function into a form that could work.



-- Aaron Hill



Re: square brackets around rehearsal marks 2.21.81

2020-12-05 Thread Aaron Hill

On 2020-12-05 10:30 am, Paul Scott wrote:

Is there a way to put square brackets around a rehearsal mark (bar
number if relevant)?


bracketify-stencil should do what you need.  Here's a wrapper for it:



\version "2.20.0"

bracketify =
#(define-music-function
  (grob-path axis thick protrusion padding)
  (key-list? number? number? number? number?)
  #{ \override $grob-path . stencil =
   #(grob-transformer 'stencil
 (lambda (grob orig)
 (bracketify-stencil orig
  axis thick protrusion padding))) #})

{
  \bracketify Score.RehearsalMark #Y 0.1 0.3 0.5
  \mark \default b'4 4 2 4 2. 1
  \temporary \bracketify NoteHead #X 0.2 0.5 0.3
  \mark \default b'4 4 2 4 2. 1
  \revert NoteHead.stencil
  \mark \default b'4 4 2 4 2. 1
}



-- Aaron Hill

Re: LilyPond to Scheme to Lilypond and variadic function

2020-11-24 Thread Aaron Hill

On 2020-11-24 3:00 pm, Daniel Tomas wrote:
I am working on a Microtonal key for LilyPond, but I need help to 
construct

a function which I will try to simplify here. I have some questions :
1) In Scheme can be possible to write a function which is variadic with 
a

point :
( function (arg1 arg2 . m )  ( ... ))
And here  m contains not only one parameter passed. m1, m2, ...
I have not found in any place information about how to access m, is it 
a

list ? But in this case, we can directly use a list like
(function (arg1 arg2 ls) ( ... ))


m is a list, although there are helpers for destructuring it.  This is 
documented in the Guile manual [1].


[1]: https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/


\version "2.20.0"

#(define (func first second . rest)
  (let-optional rest ((third 'default) (fourth 'default))
   (format #t "\n -- func --")
   (format #t "\n required args: first=~s, second=~s" first second)
   (format #t "\n destructured args: third=~s, fourth=~s" third fourth)
   (format #t "\n   additional args: rest=~s" rest)))

#(func 'a 'b)
#(func 'c 'd 'e)
#(func 'f 'g 'h 'i 'j)


Parsing...
 -- func --
 required args: first=a, second=b
 destructured args: third=default, fourth=default
   additional args: rest=()
 -- func --
 required args: first=c, second=d
 destructured args: third=e, fourth=default
   additional args: rest=()
 -- func --
 required args: first=f, second=g
 destructured args: third=h, fourth=i
   additional args: rest=(j)
Success: compilation successfully completed


The advantage of (lambda args) over (lambda (args)) is that the list is 
implicit.  Callers can invoke the procedure more naturally.  Imagine if 
one had to say (+ (list 1 2 3)) instead of simply (+ 1 2 3).




2) Now i need to do this with music information like :
Function =  #(define-music-function
(parser location cyclic  ls)
(boolean? list?)
 #{
  ...
How call to another function which arguments are musical elements and 2
numbers passed n times by  ?
 ...
 #}
 )

Function need to be called with unfixed number N of arguments :
\Function #t c4 2 3 d 2 5 e 4 1 f2 1 1 ... musicN nN1 nN2
Please , somebody can help me ?


The above cannot be done as LilyPond's scheme functions cannot handle 
such open-ended arity.  The only variability is optional arguments, and 
even then there are some restrictions due to how the parser works.


To provide arbitrary numbers of things, you must use a list of some 
form.



\version "2.20.0"

foo =
#(define-void-function (args) (list?) (format #t "\n args=~s" args))

\foo #'(this is a literal scheme list)
\foo 3,1,4,1,5,9,2,6 % ..a list of natural numbers
\foo This.Is.A.Symbol.List

baz =
#(define-void-function (prop args) (symbol? ly:music?)
  (set! args (map (lambda (m) (ly:music-property m prop))
  (extract-typed-music args 'rhythmic-event)))
  (format #t "\n args=~s" args))

\baz pitch { c d e f }
\baz duration { 1 2. 4 }
\baz text \lyricmode { Here are some words. }


Parsing...
 args=(this is a literal scheme list)
 args=(3 1 4 1 5 9 2 6)
 args=(This Is A Symbol List)
 args=(# # # #)
 args=(# # #)
 args=("Here" "are" "some" "words.")
Success: compilation successfully completed


With \foo, we are leveraging some of LilyPond's syntactic elements that 
ultimately resolve to a list.  There are limitations on what types of 
data can appear, but it is certainly an option to consider.


\baz demonstrates working with music as a container for data.  This 
option is ideal when inputting a variable number of musical things as it 
largely resembles other LilyPond syntax.



-- Aaron Hill



Re: bend before, increase disctance to accidental

2020-12-04 Thread Aaron Hill

On 2020-12-04 7:10 am, Stefan Thomas wrote:

Dear Thomas,
thanks for Your reply!
Unfortunately the code doesn't work for me, I get the error message:


Processing `/tmp/lyp/wrappers/bendbefore.ly'

Parsing...

Interpreting music...

Preprocessing graphical objects...

Finding the ideal number of pages...

Fitting music on 1 page...

Drawing systems...

Layout output to `/tmp/lilypond-TlFzo5'...: In 
expression

(rmoveto 12.500042 -2.5 ...):

: Unbound variable: rmoveto


Is Your code written for 2.20.0?


Newer than that, as it fails with 2.20.0.  There was a change to stencil 
expressions that removed an extra level of quoting.  For 2.20.0 and 
earlier, you'll need to add that back in:



  (exp (list 'path thickness
 `(quote
   (rmoveto
 ,(- left-x self-x) ,(- delta-y)
 rcurveto
 ,(/ dx 3) 0
 ,dx ,(* 0.66 delta-y)
 ,dx ,delta-y)



-- Aaron Hill



Re: Syntax error encountered while engraving a successfully updated Mutopia ly file

2020-11-29 Thread Aaron Hill

On 2020-11-29 12:03 pm, Kenneth Wolcott wrote:

Hi;

  I downloaded a Mutopia Greensleves ly source and successfully
converted it to 2.20.0 but get the following error when engraving:

././updated_greensleeves.ly:68:22: error: syntax error, unexpected
SCM_TOKEN, expecting ',' or '.' or '='
  top-markup-spacing
 #'padding = #10

The output from convert was only the version numbers.

Please tell me how to fix this.

The engraving did succeed as there were pdf and midi files produced.

The paper section, below, is where the error occurs:

\paper {
  first-page-number = 2
  print-first-page-number = ##t
  top-markup-spacing #'padding = #10
  markup-system-spacing #'padding = #7
  system-system-spacing #'basic-distance = #14
}


convert-ly knows how to fix this:


  \override Thing #'property #'sub-property = #'value
% ...to...
  \override Thing.property.sub-property = #'value


It does not however seem to correct:


  variable #'key = #'value
% ...to...
  variable.key = #'value



-- Aaron Hill



Re: drum-staff metronome click + bell ?

2020-12-12 Thread Aaron Hill

On 2020-12-12 12:52 pm, Silas S. Brown wrote:

Hi, I'm trying to add a metronome 'click track' to a MIDI
that is to be played on a Casio CDP-130 which has a limited
range of instruments (it cannot do woodblock for example).

The General MIDI percussion standard maps "metronome click"
and "metronome bell" to key numbers 33 and 34 in channel 10,
but Lilypond's \drums does not seem to have any note commands
to produce these key numbers.  I can do: \drums { trim4 cl cl cl }
to use muted triangle and claves (which are available on the
CDP, as it uses them for button-press sounds), but this doesn't
sound as good as the CDP's built-in metronome sound which
uses key numbers 33 and 34.



\version "2.20.0"

% Define new pitch names.
drumPitchNames.metronomeclick = #'metronomeclick
drumPitchNames.metronomebell = #'metronomebell

% Define shorthands for the pitch names.
drumPitchNames.mc = #'metronomeclick
drumPitchNames.mb = #'metronomebell

% Associate a pitch with the name.
midiDrumPitches.metronomeclick = ##{ a,, #}
midiDrumPitches.metronomebell = ##{ ais,, #}

% Regenerate the hash table.
\midi { \context { \Score
  drumPitchTable = #(alist->hash-table midiDrumPitches)
} }

\score {
  \drums { \repeat unfold 8 { mb4 mc mc mc } }
  \midi { \tempo 4 = 90 }
}



-- Aaron Hill



Re: Stencil rubber

2020-12-12 Thread Aaron Hill

On 2020-12-12 1:18 pm, Jean Abou Samra wrote:

Hi,

Is there a way to restrict the drawing of a stencil to certain parts?

For example, suppose that I want to join the letters A and B in a
custom letter that is half an A in the left half and half a B in the
right half. How can I do that in a markup?

I can add a white box to hide part of the A, getting half an A. I can
do the same for B. But if I \combine the two, the white half of the B
get printed over the A...


This only works for PostScript output at the moment, but here's a 
potential way to do this:



\version "2.20.0"

#(define-markup-command
  (clip layout props rel-xex rel-yex args)
  (number-pair? number-pair? markup?)
  (let* ((sten (interpret-markup layout props args))
 (orig-xex (ly:stencil-extent sten X))
 (orig-yex (ly:stencil-extent sten Y))
 (clip-xex (cons (interval-index orig-xex (car rel-xex))
 (interval-index orig-xex (cdr rel-xex
 (clip-yex (cons (interval-index orig-yex (car rel-yex))
 (interval-index orig-yex (cdr rel-yex
 (expr (ly:stencil-expr sten)))
(ly:make-stencil
  `(combine-stencil
(embedded-ps
,(ly:format
  "gsave currentpoint ~a ~a vector_add ~a ~a rectclip"
  (car clip-xex) (car clip-yex)
  (interval-length clip-xex)
  (interval-length clip-yex)))
(delay-stencil-evaluation ,(delay expr))
(embedded-ps "grestore"))
  clip-xex clip-yex)))

markupA = \markup \huge \circle \italic "A"
markupB = \markup \huge \box \bold "B"

\markup \pad-around #0.5 {
  \markupA
  \put-adjacent #X #RIGHT
\with-color #red \clip #'(-1 . 0) #'(-1 . 1) \markupA
\with-color #blue \clip #'(0 . 1) #'(-1 . 1) \markupA
  \put-adjacent #Y #DOWN
\with-color #red \clip #'(-1 . 0.75) #'(-0.25 . 1) \markupA
\with-color #blue \clip #'(-0.75 . 1) #'(-1 . -0.25) \markupA
  \put-adjacent #X #RIGHT
\with-color #red \clip #'(-1 . 0) #'(-1 . 1) \markupB
\with-color #blue \clip #'(0 . 1) #'(-1 . 1) \markupB
  \put-adjacent #Y #DOWN
\with-color #red \clip #'(-0.75 . 1) #'(0.33 . 1) \markupB
\with-color #blue \clip #'(-1 . 0.75) #'(-1 . 0.33) \markupB
  \markupB
}


The arguments for \clip assume relative coordinates (e.g. LEFT/DOWN = 
-1, CENTER = 0, RIGHT/UP = 1).  This seemed easier to work with than 
absolute extents.



-- Aaron Hill

Re: Determine Length of a markup

2020-12-10 Thread Aaron Hill

On 2020-12-10 3:35 pm, Valentin Petzel wrote:

Hello,

I’m trying to calculate the width of a InstrumentName markup to 
automatically
set the indent. Some time ago I somewhat managed to do an 
interpretMarkup by

looking up layout and parser, but I cannot remember, how I did it.

So maybe someone of you guys has a decent way of doing this?


This seems to work:


\version "2.20.0"

measureMarkup =
#(define-scheme-function
  (axis text)
  ((number? X) markup?)
  (let* ((layout (ly:parser-lookup '$defaultpaper))
 (props (ly:output-def-lookup layout 'text-font-defaults))
 (sten (interpret-markup layout (list props) text)))
(* (interval-length (ly:stencil-extent sten axis))
   (ly:output-def-lookup layout 'staff-space

foo = \markup \box \pad-x #2 \italic "Lorem ipsum"
\paper { indent = \measureMarkup \foo }
\new Staff \with { instrumentName = \foo }
{ \repeat unfold 16 { b'4 4 2 } \bar "|." }



-- Aaron Hill



Re: Dynamic text vertical positioning issue

2020-12-21 Thread Aaron Hill

On 2020-12-20 9:35 pm, Ahanu Banerjee wrote:
In the following example, dynamic text does not vertically reposition 
when
"+" marking (i.e., left-hand pizzicato) is given vertical offset. 
Please

advise if I have missed an obvious solution. Thanks!

\version "2.20.0"
{
  % dynamic text has wrong vertical position:
  \stemDown e'-\tweak extra-offset #'(0.3 . 1.5) _+ \p
  % expected behaviour:
  e'_1\p
}


extra-offset is what it says: "extra".  Its effect happens *after* all 
other layout logic is performed.


You instead need to adjust the X-offset and Y-offset properties:


\version "2.20.0"
{
  \stemDown
  e' -\offset X-offset #0.3
 -\offset Y-offset #1.5
 _+ \p
  e' _1 \p
}



-- Aaron Hill



Re: \tuplet 2/3

2020-12-15 Thread Aaron Hill

On 2020-12-15 2:09 pm, bobr...@centrum.is wrote:

I need to print half-note duplets in 3/4 time.  '\tuplet 2/3' does not
work.  The code below *does* work.  My question is; is this the
"right" way to do this?

Thanks,

David

\version "2.20.0"

\score {
  \relative c' {
\time 3/4
\once\override TupletNumber.text = \markup{ "2" }
\tuplet 4/3 {c2 c}
  }
}


\tuplet 2/3 would mean every two notes of a particular duration should 
last as long as three notes of that duration.  But three half notes 
would be two full measures in 3/4 time.  So, \tuplet 4/3 would be 
correct if you intend for two half notes to "fill" a 3/4 measure.  
Consider:



\version "2.20.0"

{ \time 3/4
  | b'4. b' % two dotted quarters
  | b'2*3/4 b'  % half notes scaled by 3/4
  | \times 3/4 { b'2 b'  }  % same, but using \times
  | \tuplet 4/3 { b'2 b' }  % same, but using \tuplet
}


\tuplet and \times differ only on the order of numerator/denominator.


-- Aaron Hill



Re: \bar "" as discretionary break point without affecting spacing

2020-12-21 Thread Aaron Hill

On 2020-12-21 4:25 am, Daniel Tobias Johansen Langhoff wrote:

Hi!

I have some unmetered music in which I want to put discretionary line
breaks at the end of verse lines. Currently I am using \bar "". This
however, affects the spacing, most notably the position of the breath
marks. Is there any way to achieve this without spacing issues?

lineEnd = { \breathe \bar "" }

\score {
  \relative f' {
\key f \major
\omit Score.TimeSignature
\cadenzaOn
f4 a2 bes4 c2 bes4 a2 g4 a2 \lineEnd
a4 a2 g4 bes4( a) g4 f2( e4) f2 \lineEnd
f4 a2 bes4 c2 bes4 a2 g4 a2 \lineEnd
  }
}


Does this help?


\version "2.20.0"

lineEnd = {
  \once \override BreathingSign.space-alist =
  #(grob-transformer 'space-alist
(lambda (grob orig)
 (assoc-set! orig 'staff-bar '(minimum-space . 0
  \breathe
  \bar ""
}

\score {
  \relative f' {
\key f \major
\omit Score.TimeSignature
\cadenzaOn
f4 a2 bes4 c2 bes4 a2 g4 a2 \lineEnd
a4 a2 g4 bes4( a) g4 f2( e4) f2 \lineEnd
f4 a2 bes4 c2 bes4 a2 g4 a2 \lineEnd
  }
}



-- Aaron Hill



Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-12-11 Thread Aaron Hill

On 2020-12-11 10:43 am, Matthew Fong wrote:

Hello everyone,

Resurrecting an old thread. I've been trying my hand in Scheme 
programming,

via small examples on the project I'm working on.

I wanted to extend the variable list to this function Harm wrote, to 
take
an extra boolean variable, which is pretty trivial. The boolean is 
meant to
change the color of the text depending if it's true or false. But I am 
not
clear on how to define the color using the boolean. The trivial way to 
do
it is adding a conditional under the first if, and duplicate all the 
code

except the color. Is there a proper Scheme-ish way to do this?
(Admittingly, I have not caught on to Scheme just yet -- my brain tends 
to

work with Python)

print-if-defined =
#(define-void-function (sym text) (symbol? markup?)
  (if (defined? sym)
  (add-text #{ \markup \with-color #'(0.8 0.2 0.2) #text #})))

symA = "Something"

\print-if-defined #'symB "Text"
\print-if-defined #'symA "Text"


Unless I am missing something from your specific use case, you should 
only need to nest another (if ...) expression in place of the actual 
color:



print-if-defined =
#(define-void-function (foo sym text) ((boolean? #f) symbol? markup?)
  (if (defined? sym)
  (add-text #{ \markup \with-color
#(if foo '(0.8 0.2 0.2) '(0.2 0.8 0.2))
#text #})))

symA = "Something"

\print-if-defined #'symB "Text" % hidden
\print-if-defined #'symA "Text" % shown, green
\print-if-defined ##t #'symA "Text" % shown, red



-- Aaron Hill



Re: Autochange with Staves named other than "up" and "down"

2020-12-20 Thread Aaron Hill

On 2020-12-19 3:14 pm, Pine, Zachary V wrote:

Hello Community,

I'm writing a piano piece across three staves. Sometimes I would like
to use autochange to engrave material on the top two staves, other
times across the bottom two. I know autochange works by default on
staves named "up" and "down".

Is there any way to override the names of the staves autochange looks
for? Perhaps there is another solution I'm not seeing other than
manually inputting \change Staff everytime.


Here is one approach, although I cannot be certain it covers all edge 
cases:



\version "2.20.0"

#(define (symbol-pair? arg)
  (and (pair? arg) (symbol? (car arg)) (symbol? (cdr arg
#(define (symbol-pair-list? arg)
  (and (list? arg) (every symbol-pair? arg)))

replaceContextChanges =
#(define-music-function
  (replacements music)
  (symbol-pair-list? ly:music?)
  (define (proc music)
   (if (music-is-of-type? music 'context-specification)
(ly:music-set-property! music 'context-id
 (let* ((id (ly:music-property music 'context-id))
(sym (string->symbol id)))
  (if (eq? "" id) id ; Sometimes context-id is an empty string.
   (symbol->string (ly:assoc-get sym replacements sym))
   (if (music-is-of-type? music 'auto-change-instruction)
(ly:music-set-property! music 'context-change-list
 (map (lambda (p) (let ((mom (car p)) (sym (cdr p)))
   (cons mom (ly:assoc-get sym replacements sym
  (ly:music-property music 'context-change-list
   music)
  #{ \musicMap #proc #music #})

<< \new Staff = upper { \clef treble s1*3 }
   \new Staff = middle { \clef alto s1*3 }
   \new Staff = lower { \clef bass
\replaceContextChanges #'((down . lower) (up . middle))
\autochange { a4 b d' e' }
\replaceContextChanges #'((down . middle) (up . upper))
\autochange { a4 b d' e' }
\replaceContextChanges #'((down . upper) (up . lower))
    \autochange { a4 b d' e' }
   } >>



-- Aaron Hill

Re: explicit duration within \lyricsto

2020-11-09 Thread Aaron Hill

On 2020-11-09 9:38 am, Yotam Medini יותם מדיני wrote:

Is there a way within a \lyricsto section
to 'temporary' override the voice alignment
and set syllables with explicit duration values ?


I do not know about mixing manual and automatic durations, but you can 
temporarily switch the associatedVoice so lyrics align to the rhythm of 
a different context:



\version "2.20.0"

<< \new Staff <<
 \new Voice = primary { b'4 4 8 8 4 | 8 8 4 4 4 }
 \new NullVoice = secondary { b'4 4 2 | 4. 8 2 } >>
   \new Lyrics \lyricsto primary { \set stanza = "primary"
 a b c d e f g h i j }
   \new Lyrics \lyricsto secondary { \set stanza = "secondary"
 k l m n o p }
   \new Lyrics \lyricsto primary { \set stanza = "mixed"
 a \set associatedVoice = secondary b m n
 \unset associatedVoice o i j } >>


Above I show using a NullVoice so the notes do not appear though you can 
still attach lyrics to them for timing.


NOTE: As documented in the Notation Reference, changing associatedVoice 
must occur one syllable early to have the desired effect.



-- Aaron Hill



Re: explicit duration within \lyricsto

2020-11-10 Thread Aaron Hill

(Re-adding mailing list for visibility...)

On 2020-11-10 12:35 am, Christ van Willegen wrote:

Hi Aaron,

Op ma 9 nov. 2020 23:39 schreef Aaron Hill:

Above I show using a NullVoice so the notes do not appear though you 
can

still attach lyrics to them for timing.

NOTE: As documented in the Notation Reference, changing 
associatedVoice

must occur one syllable early to have the desired effect.



Still, it would be very nice (TM) to be able to write "a lyric with
embedded4 lyrics8 lengths" within them.

Perhaps a feature request?


Technically, every lyric event has a duration whether or not you specify 
one.  If unspecified, the default duration is used similar to how you 
can specify a note event with just a pitch alone.  Something like the 
Lyric_combine_music_iterator would be unable to know when a duration is 
meant to be obeyed or not, as lyrics events with or without an explicit 
duration are indistinguishable.


Perhaps a property could be introduced that temporarily disables 
automatic alignment, similar to how melismata can be ignored:



\lyricsto melody {
  some words that fol -- low the mel -- o -- dy
  \set ignoreVoice = ##t
  these4 syl8 -- la8 -- bles4 do not2
  \unset ignoreVoice
  back to a -- lign -- ing with the voice
}


I don't have a build environment setup, so I cannot easily tinker with 
the C++.  But I wonder if this would work:


 lyric-combine-music-iterator.cc
  lyrics_found_ = true;
  if (to_boolean (lyrics_context_->get_property ("ignoreVoice"))) {
Moment m = lyric_iter_->pending_moment ();
lyric_iter_->process (m);
return;
  }
  if (!music_context_)
return;


But I do not understand the iterator system well enough, so that could 
be utter gibberish.



-- Aaron Hill



Re: Tremolos between two whole notes with LilyPond 2.20.0 and newer

2020-11-08 Thread Aaron Hill

On 2020-11-08 1:52 am, Kuredant Kuredant wrote:

Hello,

I've been using the solution mentioned in
https://lists.gnu.org/archive/html/lilypond-user/2012-02/msg00253.html 
to
adjust the orientation of the tremolo beams between two whole notes, 
like

in this example: http://lilybin.com/vzv8uv/1

This works very well with LilyPond 2.18.2 and 2.19.48, but it no longer
works with the latest stable and development versions (2.20.0 and 
2.21.7):

the beam stays horizontal.

convert-ly only tells me to remove "parser" and "location" from
"define-music-function", which doesn't improve the result, and I 
couldn't
find anything in the release notes related to Beam.gap, 
Beam.extra-offset

or Beam.stencil.

Does somehave have a solution working with newer Lilypond versions?


Not certain why the original fails, but here is an updated version that 
seems to work:



\version "2.20.0"

% From 
https://lists.gnu.org/archive/html/lilypond-user/2012-02/msg00253.html

% Updated for 2.20.0 and newer.
tweakWholeNoteTremolo =
#(define-music-function (y-offsets) (pair?)
  "Change the whole note tremolo orientation (default is horizontal)"
  #{ \once {
\override Beam.gap = #1.3
\override Beam.extra-offset = #(cons 0 (car y-offsets))
\override Beam.positions =
#(grob-transformer 'positions (lambda (grob orig)
  (cons (car orig) (+ (cdr orig) (cdr y-offsets)
  } #})

\relative c' {
  \tweakWholeNoteTremolo #'(-4.4 . 3.3)
  \repeat tremolo 16 { c32 c' }
}


NOTE: While y¹off-y²off is a valid symbol in Scheme, I renamed it to 
something pure ASCII.


Also NOTE: This code is no longer backwards compatible due to the use of 
grob-transformer.



-- Aaron Hill



Re: Problem positioning TextSpanner

2020-11-11 Thread Aaron Hill

On 2020-11-11 4:06 am, Victor Olaya wrote:
I am trying to create a text spanner that groups several notes, in such 
a
way that the end of the spanner falls exactly on the last note, so 
another
one can start right after that and convey the idea the note also 
belongs to

that other group.

An image might help to clarify it. I want to do something like this:

https://www.maqamworld.com/es/maqam/rast.php

I haven't found a way of doing it, and the \startTextSpan \stopTextSpan
syntax doesn't seem to allow a note to be part of two spans.


This is where providing an example of what you have tried would be 
useful.


A note is allowed to be the end of one span and the beginning of 
another:



\version "2.20.0"

{ b'2 \startTextSpan 4 4 \stopTextSpan \startTextSpan | 4 2. 
\stopTextSpan }




-- Aaron Hill



Re: Questions about using Scheme with Lilypond

2020-11-15 Thread Aaron Hill

On 2020-11-15 12:03 pm, Tom Brennan wrote:
I'd like to create a function that would allow me to create a 
`bookpart`

from a list of arguments. E.g.,

[...]

Is this kind of thing possible?


Yes-ish, see my post [1] last month about "returning" books and book 
parts.


[1]: 
https://lists.gnu.org/archive/html/lilypond-user/2020-10/msg00406.html



2. Applying variadic arguments (i.e., "splat"). E.g., in Clojure, you 
can

do something like this:

[...]

but you can't just throw a list in right there, right? It would need to 
be
expanded, in the `apply` sense. I assume Guile has macros, like 
Clojure,
but I don't know how to use them yet. Would that path lead me to 
success

here, though?


Guile does support macros, although these are not needed for procedures 
of variable arity.  Consider:



\version "2.20.0"

#(define (foo . args) (format #t "\nargs=~s" args))
#(foo 1 2)
#(foo 'a 'b 'c)

#((lambda args (format #t "\nargs=~s" args)) 3 'd)



Parsing...
args=(1 2)
args=(a b c)
args=(3 d)


The problem you are hitting is that music functions must have fixed 
arity.  There is limited support for optional arguments, but the parser 
ultimately needs to know how much input will be consumed by a function.  
Otherwise, you could invoke a music function and potentially read to the 
end of the file.


To work around this limitation, you can leverage existing constructs 
that contain variable numbers of things.  Consider a function that needs 
to accept one or more pitches.  You could instead accept ly:music? so 
multiple pitches are specified within curly braces (i.e. sequential 
music).  The music-pitches procedure will handle extracting the pitches 
from the provided music:



\version "2.20.0"

baz = #(define-void-function (pitches) (ly:music?)
  (format #t "\npitches=~s" (music-pitches pitches)))
\baz a
\baz { b d f }



Parsing...
pitches=(#)
pitches=(# # #)



-- Aaron Hill



Re: Lining up continuo figures

2020-11-16 Thread Aaron Hill

On 2020-11-16 1:23 pm, Jon Arnold wrote:

Wow thanks!

Why does this affect the vertical alignment differently?


I am not an authority as I did not write the code in question, but here 
is how I see the logic of it.


Normally, bass figures would go below the staff, so 
BassFigureAlignmentPlacement.staff-padding gets you a starting vertical 
reference away from the bottom.  Then because figures are stacked 
downward, they layout in a natural fashion moving away from the staff.  
All it generally good here, unless there are staff elements that extend 
below the staff symbol itself in which case an entire stack of figures 
may be pushed further away.


When figures are positioned above the staff, the stacking direction is 
by default still downward.  This makes some sense as it ensures the 
order of figures in the input is still top-down on the page.  The 
problem is that same staff-padding value sets the initial vertical 
reference to be by default only a staff space away from the top.  But 
now each figure is placed *below* this reference point, which will 
almost certainly cause a collision.  As such, the entire stack is pushed 
upward to avoid this.  In some cases, the final vertical alignment 
between neighboring figures may seem to align, but likely it will be 
ragged.


Switching the stacking direction upward allows the figures to move away 
from the staff so the starting vertical reference can be maintained.  
This results in more consistent bottom alignment, though it requires the 
figures to be input a bottom-up order.



-- Aaron Hill



Re: Lining up continuo figures

2020-11-16 Thread Aaron Hill

On 2020-11-16 12:21 pm, Jon Arnold wrote:

Hi Kevin-

Thanks for responding. I only want the 8 on the 2nd figure ([8 4 2]) to
appear- I do not want it on the rest of them.

If I comment that out as you suggest, the figures after the first are 
lower

than the first, which looks bad to me.

I've attached an image of what I want it to look like, which was 
achieved

by adding invisible figures above and is not an ideal situation in the
context of the larger score.


Just change the stacking direction and specify the figures in reverse 
order:



\version "2.20.0"

\new Staff <<
  { \time 2/1 \clef bass a1. d2 }
  \figuremode {
\override Staff.BassFigureAlignment.stacking-dir = #UP
<[3 5]>4 <[2 4 8]> <[3 5]> <[4 6]> <[3 5]>2
  }






-- Aaron Hill



Re: Questions about using Scheme with Lilypond

2020-11-16 Thread Aaron Hill

On 2020-11-16 10:28 am, Tom Brennan wrote:
Re: arity, the (admittedly unclear) question wasn't whether or not 
scheme
supports multi-arity, but whether you can "splat" any list (doesn't 
have to

be from args), into a block of lilypond code, i.e.,


The list splicing operators [1] are likely what you need to use:

[1]: 
http://lilypond.org/doc/v2.21/Documentation/extending-big-page.html#importing-scheme-in-lilypond



\version "2.20.0"

foo = #(music-pitches #{ b' g' a' #})
{ g'4. #@(map (lambda (p) #{ $p 8 #}) foo) b'4 $@(reverse foo) 2 }
%% \_/ \_/
{ g'4. b'8 g'8 a'8 b'4 a' g' b'2 }


While the above deals with a list of pitches, here is another example 
involving scores:



\version "2.20.0"

baz = #(list #{ \score { { b'1 } } #}
 #{ \score { { g'4 a'2. } } #}
 #{ \score { { b'4. g'8 a'2 } } #})
\bookpart { $@baz }

#(define (score->markup score)
  #{ \markup \score { #score \layout { indent = 0 } } #})
\markup { Lorem ipsum #@(map score->markup baz) dolor sit amet. }



-- Aaron Hill



Re: Double coda sign

2020-11-16 Thread Aaron Hill

On 2020-11-16 8:39 am, Werner Arnhold wrote:

I would like to have a pair of coda glyphs in a score at top and bottom
of the staves like in the example attatched.

[...]


Seems LSR 10 [1] would be appropriate.

[1]: http://lsr.di.unimi.it/LSR/Item?id=10

The idea is that the lowest Staff also \consists the Mark_engraver but 
with a downward direction.



-- Aaron Hill



Re: Different dynamic 1st and 2nd time in a repeat.

2020-11-17 Thread Aaron Hill

On 2020-11-17 4:42 pm, Ritchie Fraser wrote:

Hi Mark,

This wasn't quite what I was looking for, but thank you for your 
suggestion.


Knute was spot on what I was looking for.

  \repeat volta 2 {
    d'2.( -\markup { \dynamic "p - f" } |
    c4. bf) |
  }


If you do this sort of thing often enough, perhaps this wrapper function 
may be useful:



\version "2.20.0"

#(define (dynamic-event? arg)
  (and (ly:music? arg)
   (music-is-of-type? arg 'dynamic-event)))

dynamicPair =
#(define-music-function
  (first second)
  (dynamic-event? dynamic-event?)
  #{ %% Use DynamicText alignment for TextScript
 -\tweak parent-alignment-X #CENTER
 -\tweak self-alignment-X #CENTER
 -\markup \concat {
   \dynamic #(ly:music-property first 'text)
   \pad-x #0.25 \char ##x2013 %% En Dash
   \dynamic #(ly:music-property second 'text)
 } #})

%% Can use \dynamicPair directly in music or to define
%% commonly-used dynamics.  Supports make-dynamic-script.

mp-ff = \dynamicPair \mp \ff
{ b'4 _\mp-ff ^\dynamicPair \sp #(make-dynamic-script "zzz") }



-- Aaron Hill

Re: Partially formatting syllables in lyrics

2020-11-21 Thread Aaron Hill

On 2020-11-21 8:44 am, Fr. Samuel Springuel wrote:

How can I apply italics to part of a syllable in the lyrics context?
When I use the method I usually use to apply italics, it automatically
creates a new syllable:

#(ly:set-option 'relative-includes #t)
\version "2.20.0"

\new Staff
<<
\new Voice = "mel" { c' c' }
\new Lyrics \lyricsto "mel" { \lyricmode { hat\override
Lyrics.LyricText.font-shape = #'italic (s) \revert
Lyrics.LyricText.font-shape show } }




Use \markup for the entire syllable:


\version "2.20.0"

{ a'4 b'2 }
\addlyrics {
  \markup { \bold a \italic b }
  \markup { \box c \circle d }
}



-- Aaron Hill



Re: Multi-measure rests with alternating time signatures

2020-11-21 Thread Aaron Hill

On 2020-11-21 7:14 am, Kieren MacMillan wrote:

Hi Phil,

I don’t think that solves the OP’s problem, as I understand it to be…
I think the OP wants a compressed visual representation of a whole
bunch of 4/4+3/4 two-measure chunks, without actually seeing them
written out.

Of course, I might be wrong!  =)


Compound meter, perhaps?


\version "2.20.0"

\compressMMRests <<
  \new Staff {
\compoundMeter #'(4 3 4)
\repeat unfold 2
{ a'4 4 b'2 a'4 b'2 }
R4*7*14
  }
  \new Staff {
R4*7*14
\repeat unfold 2
{ b'2 2 a'4 4 4 }
  }






-- Aaron Hill

Re: Sending around contexts

2020-11-22 Thread Aaron Hill

On 2020-11-22 12:14 pm, Kieren MacMillan wrote:

Any thoughts on why this snippet throws an error?


The context is not being kept alive long enough.  Change s1 to at least 
s1*4:



\new Dynamics \new Container = "piano_dynamics" s1*4



-- Aaron Hill



Re: Chord glissTweak padding

2020-11-02 Thread Aaron Hill

On 2020-11-02 11:48 am, Dimitris Marinakis wrote:
Is it possible to modify this tweak to include padding (left & right) 
for

the individual gliss lines?

[...]


\glissTweak needs to be able to handle using 
ly:grob-set-nested-property!:



glissTweak =
#(define-music-function
  (parser location lst) (pair?)
  (define (proc grob)
(let ((gliss-count (ly:grob-property grob 'glissando-index)))
  (for-each
   (lambda (x)
 (let ((gliss-nmbr (car x))
   (property-value-alist (cdr x)))
   (if (eq? gliss-nmbr gliss-count)
   (for-each
(lambda (y)
  (let ((prop (car y)) (val (cdr y)))
(or (list? prop) (set! prop (list prop)))
(ly:grob-set-nested-property! grob prop val)))
property-value-alist
   lst)))
  #{ \once \override Glissando.after-line-breaking = #proc
 <>\glissando #})


Then you can do something like this:


\glissTweak
  #`((0 . ((style . dashed-line)
  ((bound-details right padding) . 2)
  ((bound-details right arrow) . #t)
  (normalized-endpoints . (0 . -2.1
 (1 . ((stencil . #f)))
 (2 . ((stencil . #f)))
 (3 . ((stencil . #f)))
 (4 . ((style . dashed-line)
   ((bound-details left padding) . 2)
   ((bound-details left arrow) . #t)
   (normalized-endpoints . (0 . -1.5)
2^"\"some other tweaks\""




-- Aaron Hill



Re: Chord glissTweak padding

2020-11-02 Thread Aaron Hill

On 2020-11-02 12:18 pm, Aaron Hill wrote:

  #{ \once \override Glissando.after-line-breaking = #proc
 <>\glissando #})


You can even simplify that expression using \tweak:

  #{ <>-\tweak after-line-breaking #proc \glissando #}

Not sure if \tweak is cheaper than \once \override.


-- Aaron Hill



Re: Chord glissTweak padding

2020-11-02 Thread Aaron Hill

On 2020-11-02 12:18 pm, Aaron Hill wrote:
\glissTweak needs to be able to handle using 
ly:grob-set-nested-property!:



glissTweak =
#(define-music-function
  (parser location lst) (pair?)
  (define (proc grob)
(let ((gliss-count (ly:grob-property grob 'glissando-index)))
  (for-each
   (lambda (x)
 (let ((gliss-nmbr (car x))
   (property-value-alist (cdr x)))
   (if (eq? gliss-nmbr gliss-count)
   (for-each
(lambda (y)
  (let ((prop (car y)) (val (cdr y)))
(or (list? prop) (set! prop (list prop)))
(ly:grob-set-nested-property! grob prop val)))
property-value-alist
   lst)))
  #{ \once \override Glissando.after-line-breaking = #proc
 <>\glissando #})



Hmm... that could be cleaned up to remove the outer loop:


glissTweak =
#(define-music-function
  (parser location lst) (pair?)
  (define (proc grob)
(let ((gliss-idx (ly:grob-property grob 'glissando-index)))
  (for-each
   (lambda (y)
 (let ((prop (car y)) (val (cdr y)))
   (or (list? prop) (set! prop (list prop)))
   (ly:grob-set-nested-property! grob prop val)))
   (ly:assoc-get gliss-idx lst '()
  #{ \once \override Glissando.after-line-breaking = #proc
 <>\glissando #})
%%%%


-- Aaron Hill



Re: first tuplet in nested tuplet displays as parent tuplet

2020-11-03 Thread Aaron Hill

On 2020-11-03 9:47 am, 98123981293 1293812397123 wrote:

Hi list,

Any idea why, when compiling this code, the first nested triplet 
displays

with the custom bracket of tuplet on the top level? I would like the
bracket of the first nested tuplet to just display as a normal triplet. 
I
was not able to find this addressed in the archive, but please point me 
to

relevant documentation if this has already been covered.

Thank you,
Kyle

\version "2.21.2"
\score {
  <<
\new Staff {
\time 3/4
\set subdivideBeams = ##t
\set strictBeatBeaming = ##t
\override TupletBracket.bracket-visibility = ##t
  \once \override TupletNumber.text =
  #(tuplet-number::append-note-wrapper
  
(tuplet-number::non-default-tuplet-fraction-text

7 6) (ly:make-duration 3 0))
\times 6/7 {
 \times 2/3 { e8([ f8 e8]}
 \times 2/3 {f8 e8 f8)}
<< f4 {s16 s16 s8} >>
 \times 2/3 {e8[e16~]}
  }
|
}
  >>
}


\once \override will affect the entire timestep.  \tweak is your friend:


\version "2.21.80"
{
  \time 3/4
  \tweak text
#(tuplet-number::append-note-wrapper
  tuplet-number::calc-fraction-text
  #{ 8 #})
  \tuplet 7/6 {
\tuplet 3/2 4 { e8[ f e] f8[ e f] }
<< f4 { s16 s16 s8 } >>
\tuplet 3/2 { e8 16 }
  }
}


Also shown is using \tuplet as an alternative to \times.


-- Aaron Hill



Re: \note within \markup

2020-11-03 Thread Aaron Hill

On 2020-11-03 11:07 am, Noah Landis wrote:

Hi list!

I have separated block of text using \markup that looks something like
this:

\markup {
"To play" \note #"8" #1 "stop the."
}

But I can't figure out how to make two 8th notes (staccato) connected
by a beam using this \note command?

I need it to look like this:

c8[\staccato c8]\staccato

If this is not possible with \note within \markup, any work-around
would be appreciated. Thank you in advance.


LSR 1029 [1] will make this very easy to achieve.

[1]: http://lsr.di.unimi.it/LSR/Item?id=1029


-- Aaron Hill



Re: LSR 1119 Force clef change in alternatives

2020-10-30 Thread Aaron Hill

On 2020-10-30 2:19 pm, Thomas Morley wrote:

To the author (Pierre?) of
lsr.di.unimi.it/LSR/Item?u=1=1119

Many thanks for your snippet, though, please add a description to it. 
;)


Would this work better to avoid the hidden note showing up in MIDI?


  \grace s4
  \once \override Staff.Clef.extra-spacing-width = #'(-1 . 0)
  \clef bass


Seeing as the grace note affects spacing, I added a suitable spacing 
modifier.




-- Aaron Hill



Re: \unfoldRepeats

2020-11-01 Thread Aaron Hill

On 2020-11-01 2:25 pm, David Rogers wrote:

Aaron Hill  writes:


On 2020-10-29 2:35 pm, David Kastrup wrote:

David Nalesnik  writes:


Hi Andrew,
On Wed, Oct 28, 2020 at 5:03 PM Andrew Bernard 
 wrote:

Hi David,
But it would be great in the future to have more and better MIDI
support. I no longer regard it as a small feature on the side, but
something I really need. For now, I will stick to outputting my New
Complexity School scores - which Dorico has trouble with! :-)


I think an important step in the process would be to make the MIDI
backend somehow accessible from Scheme.  Then the power users would 
be

all over it.

Indeed.  And a unifying concept covering both grobs and MIDI objects
(mobs?) might even pave a way to iterative generation of time-based
MusicXML (xobs?) or Braille (bobs?) or other renditions of the 
musical

content.


Mobs... 樂

Could we get LilyPond to output a Minecraft world populated with 
appropriate redstone and noteblocks?


Somehow I’m now imagining a Lilypond Toys Output Module that builds
(literally!) a representation of my score out of Lego, Meccano,
Tinkertoys, Slinky, popsicle sticks, pipe cleaners, etc, choosing the
materials by some kind of algorithm. And any elements of a score that
involve extra Scheme code or tweaks, it will build from papier-mâché.
Consider it an alternative definition of “object-oriented”. :)


And now I am thinking of Pipe Dream from Animusic or that marble music 
machine by Wintergaten.



-- Aaron Hill



Re: Installing Lilypond 2.21.80

2020-11-01 Thread Aaron Hill

On 2020-11-01 3:41 pm, Ralph Palmer wrote:

Hi -

I would like to install LilyPond 2.21.80, but I don't know how. I have
successfully installed earlier versions, but I don't remember how, and 
I

can't find instructions.

I'm running Ubuntu 20.4.01 under Linux (duh - but I don't know how to 
find

the Linux version).

I'm slightly familiar with working with the Terminal, but not fluent.

I downloaded  and tried running 
,

but I'm not sure what the destination should be. I'm not even positive
that's the file I should be working with. Not ?

Can anyone point me to installation instructions in the Notation 
Reference,

or give me some specifics?


The installation instructions can be found here [1] where you would 
obtain the stable release.  (Perhaps a helpful link could be added on 
the development/unstable pages.)


[1]: http://lilypond.org/unix.html


-- Aaron Hill



Re: Installing Lilypond 2.21.80

2020-11-01 Thread Aaron Hill

On 2020-11-01 5:26 pm, Ralph Palmer wrote:
On Sun, Nov 1, 2020 at 7:31 PM Aaron Hill  
wrote:



On 2020-11-01 3:58 pm, Aaron Hill wrote:
> On 2020-11-01 3:41 pm, Ralph Palmer wrote:
>> Hi -
>>
>> I would like to install LilyPond 2.21.80, but I don't know how. I have
>> successfully installed earlier versions, but I don't remember how, and
>> I
>> can't find instructions.
>
> The installation instructions can be found here [1] where you would
> obtain the stable release.  (Perhaps a helpful link could be added on
> the development/unstable pages.)
>
> [1]: http://lilypond.org/unix.html

Never mind.  There *is* a link to the stable download page in the big
friendly box above the download links.


-- Aaron Hill



Thanks, Aaron, but I specifically asked about 2.21.80 because of Phil
Holmes' request for users to use the "stable release candidate", or
2.21.80. I'm currently running 2.20.0. I could not find adequate
instructions for installing the unstable version.


That's the point.  It's all the same.  There's no unique instructions 
for stable vs. unstable.  Follow the stable instructions, but download 
the unstable .sh script.



-- Aaron Hill



Re: Installing Lilypond 2.21.80

2020-11-01 Thread Aaron Hill

On 2020-11-01 3:58 pm, Aaron Hill wrote:

On 2020-11-01 3:41 pm, Ralph Palmer wrote:

Hi -

I would like to install LilyPond 2.21.80, but I don't know how. I have
successfully installed earlier versions, but I don't remember how, and 
I

can't find instructions.

I'm running Ubuntu 20.4.01 under Linux (duh - but I don't know how to 
find

the Linux version).

I'm slightly familiar with working with the Terminal, but not fluent.

I downloaded  and tried running 
,

but I'm not sure what the destination should be. I'm not even positive
that's the file I should be working with. Not ?

Can anyone point me to installation instructions in the Notation 
Reference,

or give me some specifics?


The installation instructions can be found here [1] where you would
obtain the stable release.  (Perhaps a helpful link could be added on
the development/unstable pages.)

[1]: http://lilypond.org/unix.html


Never mind.  There *is* a link to the stable download page in the big 
friendly box above the download links.



-- Aaron Hill



Re: restating clef and StaffGroup brace after \startStaff

2020-10-21 Thread Aaron Hill

On 2020-10-21 9:21 am, Gilberto Agostinho wrote:

Hello,

Does anyone know if it would be possible to restate a staff's clef and
a StaffGroup's brace after the \startStaff command? I am again trying
to create a diagram showing non-consecutive measures side by side. I
am able to set the bar numbers of these measures to arbitrary values
as I wish, but I think the second measure would look better with clefs
and braces similarly to the first. Does anyone have any ideas how to
tackle this?

[...]

Producing: 
https://i.postimg.cc/ydXVn8HM/Screenshot-from-2020-10-21-17-19-13.png


A perhaps easier option is to use \markup \score:


\version "2.19.82"

A.2 = { c'2 d'2 }
A.13 = { e'2 f'2 }
B.2 = { c'1 }
B.13 = { c'1 }

AB.2 = \new StaffGroup << \A.2 \B.2 >>
AB.13 = \new StaffGroup << \A.13 \B.13 >>

initialBarNumber =
#(define-music-function
  (number) (number?)
  #{ \once \override Score.BarNumber.break-visibility = #all-visible
 \set Score.currentBarNumber = #number
 \bar "" #})

\markup {
  \score { { \initialBarNumber 2 \AB.2 } }
  \score { { \initialBarNumber 13 \AB.13 } }
}



-- Aaron Hill



FretBoards require X11 color names

2020-11-04 Thread Aaron Hill
Possibly silly question, but why are colors forced to be X11 in fret 
diagrams?


When you recolor a NoteHead for instance, you just use the literal color 
value:



\version "2.20.0"
{
  \tweak color #'red b'4 % symbol is invalid, defaults to 
black

  \tweak color #red  b'4 % color value stored in variable
  \tweak color #'(0.9 0.5 0.2)   b'4 % custom color as an RGB list
  \tweak color #(x11-color 'tan) b'4 % looking up X11 color
}


You cannot do this with fret diagrams, as the internal logic assumes 
colors are X11 names only.


Not being able to specify a literal color feels inconsistent and 
arbitrarily restrictive.



-- Aaron Hill



Re: \unfoldRepeats

2020-10-29 Thread Aaron Hill

On 2020-10-29 2:35 pm, David Kastrup wrote:

David Nalesnik  writes:


Hi Andrew,

On Wed, Oct 28, 2020 at 5:03 PM Andrew Bernard 
 wrote:


Hi David,

But it would be great in the future to have more and better MIDI
support. I no longer regard it as a small feature on the side, but
something I really need. For now, I will stick to outputting my New
Complexity School scores - which Dorico has trouble with! :-)



I think an important step in the process would be to make the MIDI
backend somehow accessible from Scheme.  Then the power users would be
all over it.


Indeed.  And a unifying concept covering both grobs and MIDI objects
(mobs?) might even pave a way to iterative generation of time-based
MusicXML (xobs?) or Braille (bobs?) or other renditions of the musical
content.


Mobs... 樂

Could we get LilyPond to output a Minecraft world populated with 
appropriate redstone and noteblocks?



-- Aaron Hill



Re: Questions From a New User

2020-10-29 Thread Aaron Hill

On 2020-10-29 6:25 pm, Jenny Suchan wrote:

My name is Jenny Suchan, and I just joined this list yesterday. I am a
totally blind musician seriously pursuing a career in music
composition. After looking into several different score-writing
software, I am now studying LilyPond to see how I could use it to
produce music scores. My friend Damien, another totally blind musician
who I have been working with and who made me aware of this software,
is copied on this message.


Welcome to the Pond.

The topic of LilyPond and Braille has come up before, so you are 
certainly not alone.  I would recommend reviewing information in the 
archives [1].


[1]: 
https://lists.gnu.org/archive/cgi-bin/namazu.cgi?query=braille=Search%21=lilypond-user=20=normal=score




We have been making our way through the Learning Manual and are
struggling with the concepts underlying the construction of chords,
multiple parts, and multiple voices. For example, it isn't clear to us
how information within less-than and greater-than signs and that
within brackets relate to each other. Also, the manual states that
tied notes share the same pitch, so how can two chords be tied
together if only one note is sustained between them? Any additional
tutorials or one-on-one help that anyone can offer would be greatly
appreciated.


Curly braces are used principally to denote sequential music, with 
events following one after another.  Angle brackets are generally for 
simultaneous music, with events occurring at the same time.  In 
particular, single angle brackets are for chords; double angle brackets 
are for grouping together voices or staves of music.


Ties between chords will only apply to notes that are in common.  
Consider a tie between a D minor chord and a D major chord.  The third 
is the only thing that changes, so ties would exist between just the D's 
and A's.  By placing the tilde outside the chord, you will instruct 
LilyPond to automatically tie any notes shared between the two chords.  
If you only want to tie specific notes, you may use the tilde inside the 
angle brackets after each individual note name.


The following snippet demonstrates both usage patterns.  The first 
measure is precisely the D minor to D major example I mentioned.  The 
second measure involves an G major to C major where the common G note is 
tied within the chord construct.


 BEGIN SNIPPET
\version "2.20.0"

\fixed d' {
  | 2 ~ 
  | 2 
}
 END SNIPPET



Also, is there a way-or a potential way-that LilyPond code can be
converted to MusicXML? It would be very helpful for me to be able to
translate my scores into Braille music, and we both could benefit from
audio feedback regarding our scores.


MIDI output from LilyPond is usually the way one would be able to listen 
to their score.


While MusicXML can be converted *to* LilyPond, the reverse is not 
possible to my knowledge.  There is an open issue [2] filed requesting a 
MusicXML backend to LilyPond, which would enable it to output that 
format.


[2]: https://gitlab.com/lilypond/lilypond/-/issues/665


-- Aaron Hill



Re: Why does -dbackend=svg -dcrop remove system-system-spacing?

2021-01-08 Thread Aaron Hill

On 2021-01-08 3:01 pm, David Wright wrote:

To answer your question—why not use the -dcrop option—I think
we are in agreement that:

$ lilypond-2.21.80-1.linux-64/bin/lilypond --svg -dcrop Bača.ly

will produce the tightly packed:

E   ┌──┐
│▒▒│
│▒▒│
│▒▒│
└──┘

which is what you implied you didn't want (by saying "Is this
supposed to happen?" and "Seems like cropping should be …").


This is clearly something that needs to be documented more clearly, but 
also we may need to reconsider what -dcrop *should* be doing rather than 
what is currently does.


It seems reasonable for folks to expect -dcrop to simply remove the 
empty margin space, which is why there is confusion that inter-system 
spacing is affected.  What -dcrop seems to actually do is reduce each 
system to its reported extents, packing the results together while 
ignoring the paper spacing variables.  Is this a bug or not, is an 
unanswered question.  The documentation makes no comment about reduced 
spacing, only that margins are to be ignored.


At this time, if you just want to remove the outer margins, then you 
should not be using -dcrop.  Rather, you should be manually removing the 
margins themselves within the \paper section.  Basically, make the 
virtual paper match precisely what you need, obviating the need to use 
-dcrop.



-- Aaron Hill



Re: print italian NoteNames context in Uppercase

2021-01-15 Thread Aaron Hill

On 2021-01-15 1:32 pm, Davide Bonetti wrote:

Hi everybody.

I'm trying to find a way to print italian note names in uppercase.

\new NoteNames {
  \set printNotesLanguage = "italiano"
  c d e
  }

prints:

do re mi

I wish to have:

Do Re Mi


Here's an option:


\version "2.22.0"

#(let ((orig-proc note-name->string))
  (set! note-name->string
   (lambda args (string-capitalize (apply orig-proc args)

\new NoteNames {
  c dis ees
  \set printNotesLanguage = italiano
  c dis ees
}



-- Aaron Hill



Re: color of a single name chord

2021-01-15 Thread Aaron Hill

On 2021-01-15 3:34 am, achar wrote:

Thanks a lot, but it doesn't work.

I don't know why.



If \tweak does not work, you can always fall back to \once \override:


\version "2.18.2"

\new ChordNames
\chordmode {
  c \once \override ChordName.color = #red d e
}



-- Aaron Hill



Re: arranger.ly and lilypond 2.21+: error with the \note markup command

2021-01-15 Thread Aaron Hill

On 2021-01-15 4:10 pm, Thomas Morley wrote:

Am Fr., 15. Jan. 2021 um 23:26 Uhr schrieb Stefano Troncaro
:


Hi everyone,

I started learning to use the spectacular arranger.ly library that was 
mentioned in the list a while ago.


While most of it works great, I found that internally it sometimes 
uses the \note markup command, that changed between versions: in 2.20 
it requires an argument of type string, while from 2.21 onwards it 
requires an argument of type duration. This causes an error and makes 
it so that files that use arranger.ly do not compile on Lilypond 2.21 
onwards.


I'm sure it'd be easy to patch. Is there an easy way to transform 
strings into durations?


Iiuc, how about:

%% from define-markup-commands
#(use-modules (ice-9 regex))

#(define-public log2
  (let ((divisor (log 2)))
(lambda (z) (inexact->exact (/ (log z) divisor)

#(define (parse-simple-duration duration-string)
  "Parse the `duration-string', e.g. ''4..'' or ''breve.'',
and return a (log dots) list."
  (let ((match (regexp-exec (make-regexp 
"(breve|longa|maxima|[0-9]+)(\\.*)")

duration-string)))
(if (and match (string=? duration-string (match:substring match 
0)))

(let ((len (match:substring match 1))
  (dots (match:substring match 2)))
  (list (cond ((string=? len "breve") -1)
  ((string=? len "longa") -2)
  ((string=? len "maxima") -3)
  (else (log2 (string->number len
(if dots (string-length dots) 0)))
(ly:error (_ "not a valid duration string: ~a") 
duration-string


%% and then:

#(define (string->duration strg)
  (apply ly:make-duration (parse-simple-duration strg)))

%% test
#(display-scheme-music (string->duration "16.."))

Cheers,
  Harm


Here's a back-compat patch that should allow \note to accept strings.  
Could be useful until arranger.ly is updated to use ly:durations in 
places where it relied on strings before.



\version "2.22.0"

#(begin
  (define (duration-or-string? arg)
   (or (ly:duration? arg) (string? arg)))
  (define-markup-command
   (note layout props duration dir)
   (duration-or-string? number?)
   #:category music
   #:properties (note-by-number-markup)
   (if (string? duration)
(set! duration
 (ly:parse-string-expression (ly:parser-clone) duration)))
   (note-by-number-markup layout props
  (ly:duration-log duration)
  (ly:duration-dot-count duration)
  dir)))

\markup {
  \note { 8. } #DOWN \note "8." #DOWN
  \note { \longa*2/3 } #UP \note "\longa*2/3" #UP
}



-- Aaron Hill



Re: Missing 2.20 documentation tarball at http://lilypond.org/all.html

2021-01-16 Thread Aaron Hill

On 2021-01-16 11:48 am, Kenneth Wolcott wrote:

  Missing 2.20 documentation tarball at http://lilypond.org/all.html


The content is still there:

http://lilypond.org/downloads/binaries/documentation/


-- Aaron Hill



Re: Universal default value function

2021-01-24 Thread Aaron Hill

On 2021-01-24 8:17 pm, Vaughan McAlley wrote:

Hi,

I am trying to write a function that will accept a symbol and a value, 
and

assign that value to the symbol *if the variable has not already been
defined *(such as in an include file).

At the moment, it runs without complaining, but the result is always 
"bar",

the default value. Can anyone spot the problem?


Did you mean to attach or include a code snippet?  Hard to spot any 
problem without it.  :)


Regardless, review the following:


\version "2.22.0"

valueOrDefault =
#(define-scheme-function
  (module symbol default)
  ((module? (current-module)) symbol? scheme?)
  (module-ref module symbol default))

defineOnce =
#(define-void-function
  (module symbol value)
  ((module? (current-module)) symbol? scheme?)
  (or (module-defined? module symbol)
  (module-define! module symbol value)))

{
  \valueOrDefault foo { b'1 }
  \defineOnce foo { b'4 4 2 }
  \valueOrDefault foo { b'1 }
  \defineOnce foo { b'8 8 2. }
  \foo
}


I included the optional module parameter in the event that users might 
need to work outside the current scope.



-- Aaron Hill



Re: ties with TeXShop

2021-01-25 Thread Aaron Hill

On 2021-01-25 5:47 am, Aaron Hill wrote:

On 2021-01-25 5:19 am, John D. Berry wrote:

At one point I happily used TeXShop to do all of my Lilypond work.  A
couple of years have passed and I have returned with a new Mac and I
find that I cannot get to this configuration due to an error in
pointer to an italian university.  It says that the page cannot be
found.  Is there another source for the engine that will work for lily
pond in TeXShop?


Is this [1] what you are looking for?

[1]: 
https://web.archive.org/web/20141010002739/http://julovi.net/j/?p=76


Sorry, pasted wrong URL.

I meant this one [2]

[2]: 
https://web.archive.org/web/20141124110511/http://users.dimi.uniud.it/~nicola.vitacolonna/software/lilypond-texshop/



-- Aaron Hill



Re: ties with TeXShop

2021-01-25 Thread Aaron Hill

On 2021-01-25 5:19 am, John D. Berry wrote:

At one point I happily used TeXShop to do all of my Lilypond work.  A
couple of years have passed and I have returned with a new Mac and I
find that I cannot get to this configuration due to an error in
pointer to an italian university.  It says that the page cannot be
found.  Is there another source for the engine that will work for lily
pond in TeXShop?


Is this [1] what you are looking for?

[1]: 
https://web.archive.org/web/20141010002739/http://julovi.net/j/?p=76



-- Aaron Hill



Re: rounded number to an integer?

2021-01-02 Thread Aaron Hill

On 2021-01-02 7:38 pm, Freeman Gilmore wrote:

How do I change a rounded number (decimal number) to an integer?
Example:  (round 60.76) ==> 61.0 want  ==> 61


inexact->exact will do that.


(inexact->exact (round 60.76))
=> 61



For:
#(define  try  (/ (round 60.76) 64))
#(write try)
==> 0.953125
Want
==> 61/64


inexact->exact can return a rational, although it will only generate a 
dyadic rational, that is a rational with a power-of-two denominator.  
Something like 1.2 will not return 6/5, for instance.



(inexact->exact 0.5)
=> 1/2
(inexact->exact 1.2)
=> 5404319552844595/4503599627370496


What you need to do is use a combination of rationalize and 
inexact->exact:



(rationalize (inexact->exact 1.2) 1/100)
=> 6/5



-- Aaron Hill



Re: Scheme help request: How can else of an if-statement be made to do nothing?

2020-12-11 Thread Aaron Hill

On 2020-12-11 12:30 pm, Matthew Fong wrote:

Hello Aaron,

.< Oh boy, that is *simple*. I went off the deep end on this, trying 
to
make another variable that would get assigned the color. That clearly 
is

not the way Scheme works. The inline conditional is a thing of beauty.

Looks like I need to spend more time studying Scheme syntax.


Defining a variable would make sense if you needed the value in a few 
places, since that would cut down on redundant expressions.  But even if 
you only needed the value once, it sometimes makes sense to use 
variables to help keep other expressions simpler.  The \markup below is 
arguably easier to follow without the embedded Scheme expression:



print-if-defined =
#(define-void-function
  (foo sym text)
  ((boolean? #f) symbol? markup?)
  (let ((color (if foo '(0.8 0.2 0.2) '(0.2 0.8 0.2
   (if (defined? sym)
   (add-text #{ \markup \with-color #color #text #}

symA = "Something"

\print-if-defined symB "Text" % hidden
\print-if-defined symA "Text" % shown, green
\print-if-defined ##t symA "Text" % shown, red


NOTE: LilyPond's parser is able to interpret "symA" as a symbol on its 
own without needing to escape to Scheme syntax by writing #'symA.  Just 
something to keep in mind as I think it results in cleaner usage.



-- Aaron Hill



Re: manual alternative endings

2021-02-04 Thread Aaron Hill

On 2021-02-04 1:13 am, Paul Scott wrote:

The code below gives me what I want but gives me a warning.

warning: already have a volta spanner, ending that one prematurely

I'm thinking I need to add (volta #f) to the 2nd repeatCommands string
but If so my scheme is weak enough that I don't know how to add it.

TIA for any help with this,

Paul

\version "2.23.0"

voltaFine = \markup\sans\caps{Fine Ending}
voltaCont = \markup\sans\caps{To Cont.}

\relative {
  f''4 g a b
  \set Score.repeatCommands = #(list(list 'volta voltaFine))
  g4 a g a c1 \bar "|."
  \set Score.repeatCommands = #(list(list 'volta voltaCont))
  b1~1
  \set Score.repeatCommands = #'((volta #f))
  \bar "||"
}


There are a few ways to do this, depending on your comfort level with 
quoting (and quasi-quoting).


1:

... = #(list (list 'volta #f) (list 'volta voltaCont))


2:

... = #(list '(volta #f) (list 'volta voltaCont))


3:

... = #`((volta #f) (volta ,voltaCont))


NOTE: The backtick in the third option begins quasi-quoting, which 
allows you to "unquote" (using the comma) so you can reference the 
defined voltaCont variable.



-- Aaron Hill



Re: \path in markup dashed line

2021-01-27 Thread Aaron Hill

Sending to mailing list for visibility...

On 2021-01-27 5:37 pm, Dimitris Marinakis wrote:
For some reason in both of my systems (Mac & PC), tested with all 
recent

versions, this code only works correctly in 2.19.xx . With the other
versions only the default path gets displayed. All the dashed ones
disappear.
What would cause such behaviour?


Changes to how outputters work it would seem.  Adding a custom stencil 
command requires different work:



% #(module-define! (resolve-module '(scm output-ps))
%   'dashed-path dashed-path-ps)

#(let* ((module (resolve-module '(scm output-ps)))
(alist (module-ref module 'stencil-dispatch-alist '(
  (module-define! module 'stencil-dispatch-alist
   (acons 'dashed-path dashed-path-ps alist)))


As shown above, replace the logic that defines dashed-path as a 
procedure within the output-ps module instead with logic that appends a 
new dispatch entry.


With that, I was able to use 2.22.0 and compile my original code 
otherwise unchanged.



-- Aaron Hill



Re: How can I put a text markup above fermata

2021-06-18 Thread Aaron Hill

On 2021-06-18 10:18 pm, 田村淳 wrote:

Hello list,

This could be a silly question but I could not figure out by myself.
How can I put a text markup (e.g., arco) above fermata?

\relative c'' {c1\fermata^"arco”}


You could adjust the outside-staff-priority of the fermata.  Consider:


\relative c'' {
  c1 -\tweak outside-staff-priority 100 \fermata
 ^"arco"
}


The "arco" above is a TextScript which has a default 
outside-staff-priority of 450.  There is nothing magical about using 100 
in particular for the fermata, only that it is a smaller number.  Grobs 
with a smaller outside-staff-priority will sit closer to the staff.



-- Aaron Hill



Re: Terminology question

2021-06-19 Thread Aaron Hill

On 2021-06-19 6:05 pm, Mark Stephen Mrotek wrote:

I'll accept the burden.
His plays with dynamic dynamics.


Let's throw in some other parts of speech:

"Dynamic dynamcist dynamically dynamicizes dynamicity in dynamics."

(That word is beginning to lose meaning to me now... thanks, semantic 
satiation.)



-- Aaron Hill



Re: nabble (barlines in volta brackets)

2021-06-20 Thread Aaron Hill

On 2021-06-20 1:13 pm, Flaming Hakama by Elaine wrote:
Ok, so I was going to try figuring out how to use my \barline ":|]" in 
a

volta repeat

\defineBarLine ":|]" #'(":|]" "" " |.")
\relative {
  \repeat volta 2 { c''4 d e f | }
  \alternative {
{ c2 e | }
\bar ":|]"
{ f2 g | }
  }
  c1
}

but I get

programming error: Spanner `VoltaBracket' is not fully contained in 
parent

spanner.  Ignoring orphaned part

And it doesn't print the 2nd ending bracket.

And does anyone have a hint as to how to get the 2nd ending to work 
when

using this barline?


Your \bar command is sitting outside a music expression, so it is 
getting treated as an alternative all on its own--if I understand the 
constructs involved.  Try instead:



\defineBarLine ":|]" #'(":|]" "" " |.")
\relative {
  \repeat volta 2 { c''4 d e f | }
  \alternative {
{ c2 e | \bar ":|]" }
{ f2 g | }
  }
  c1
}


P.S.  No idea about the nabble stuff... does the archive [1] at 
lists.gnu.org have the data you want?

[1]: https://lists.gnu.org/archive/html/lilypond-user/


-- Aaron Hill



Re: horizontal lyric spacing?

2021-06-20 Thread Aaron Hill

On 2021-06-20 6:30 pm, Molly Preston wrote:
What is the best way to make more room horizontally for lyrics? I have 
two

syllable words that look like they are one syllable words (ie no hyphen
visible) , and I am not sure the best way to space them or if there is 
some

special property I don't understand?


This is one of my utility functions:


forceHyphen = \lyricmode {
  \once \override LyricHyphen.minimum-distance = #2
}


You then use it like this:


\lyricmode { And the \forceHyphen white -- robed mar -- tyrs fol -- low, 
}




-- Aaron Hill



Re: Center graphical markup on staff

2021-06-21 Thread Aaron Hill

On 2021-06-21 5:31 pm, Nuno Trocado wrote:

Hi everyone!
How can I have the wiggly line in the example below centered inside the 
staff?

Thanks,
Nuno

\score {
  \relative c' {
c4 d
s-\markup \override #'(height . 2) \draw-squiggle-line #1 #'(8 . 0) 
##f

  }
}


While you could play around with negative padding to get the TextScript 
to overlap the staff, I would recommend hijacking something already on 
the staff, such as a rest:



markupStencil =
#(define-music-function
 (markup music)
 (markup? ly:music?)
 (define (proc grob)
  (let* ((sten (grob-interpret-markup grob markup))
 (xex (ly:stencil-extent sten X)))
   (ly:grob-set-property! grob 'minimum-X-extent xex)
   (ly:grob-set-property! grob 'stencil sten)))
 #{ \tweak before-line-breaking #proc #music #})

squiggle = \markup
 \override #'(height . 2)
 \draw-squiggle-line #1 #'(8 . 0) ##f

\score {
 \relative c' { c4 d \markupStencil \squiggle r }
}


-- Aaron Hill



Re: Piano: partial pedalling

2021-05-10 Thread Aaron Hill

On 2021-05-10 11:38 am, Dijkhuizen, J.F. van wrote:

Dear All,

I was wondering if anybody knows if it's possible to notate partial
sustain pedalling in LilyPond (essentially 1/4. half-pedal, 3/4
pedal), and if so how.

There seems to be nothing about it in the manual, and I've not been
able to find anything online that I am able to use. Ideally, I'd like
to be able to notate pedal level changes by means of a line, as is
possible in Dorico, for example:

However, just being able to specify '1/2' at the beginning of a pedal
line, and, for example, 'release pedal slowly' at tthe end of a pedal
line, would be great too.

 Any help with this would be really appreciated!


There are a few ad hoc solutions if you search the archives.  You can 
see if my hack [1] to the PianoPedalBracket stencil a few years ago 
would be of any use.


[1]: 
https://lists.gnu.org/archive/html/lilypond-user/2019-01/msg00522.html



-- Aaron Hill



Re: Piano: partial pedalling

2021-05-10 Thread Aaron Hill

(Please make sure to keep the mailing list on all messages.)

On 2021-05-10 1:42 pm, Dijkhuizen, J.F. van wrote:

Many thanks for this. When I paste the code into Frescobaldi and
compile it, I'm getting the following error message:

error: syntax error, unexpected end of input
{ s4 s4*6\gradualSustain #'((0 2 2 0)(0.3)(0.4 0 5 -3 3)) s4\sustainOff

Do you know what went wrong?


Well, there's a missing closing brace in what you quoted above.  But 
most likely you are hitting an issue where the >> is missing when you 
copy/paste from the lists.gnu.org archive site.  See this version hosted 
on lilybin [1].


[1]: http://lilybin.com/kq9t97/1

-- Aaron Hill



Re: setting partCombine text at a higher level

2021-05-11 Thread Aaron Hill

On 2021-05-11 5:44 pm, Paul Scott wrote:

Greetings,

Can the variables? soloText and its companions soloIIText, etc. be set
at a higher level than \new Staff so it doesn't have to be repeated
for each staff?  (Notation Manual 1.5.2)


You can do it more globally in a \layout block if you want it to apply 
to all staves.  Otherwise, put the variable definitions in a \with block 
that can be referenced on individual staves.



\version "2.22.0"

\layout {
 \context {
  \Staff
  soloText = girl
  soloIIText = boy
  aDueText = together
 }
}

combineTexts = \with {
  soloText = cat
  soloIIText = dog
}

\new Staff <<
  \partCombine
  \relative c'' { g4 g r r a2 g }
  \relative c'' { r4 r a( b) a2 g } >>

\new Staff \with \combineTexts <<
  \partCombine
  \relative c'' { g4 g r r a2 g }
  \relative c'' { r4 r a( b) a2 g } >>



-- Aaron Hill



Re: Tempo marking with 2 notes

2021-05-10 Thread Aaron Hill

On 2021-05-10 6:41 pm, Ahanu Banerjee wrote:

Hello,

Can anyone provide a simple way to make a tempo marking like this: "♩= 
텞 "

?


You should be able to adapt LSR 574 [1] to achieve that.

[1]: https://lsr.di.unimi.it/LSR/Item?id=574


-- Aaron Hill



Re: Horizontal beam parallel to staff

2021-05-10 Thread Aaron Hill

On 2021-05-10 9:10 pm, Pierre Perol-Schneider wrote:

Hi Ahanu,
How about:

\version "2.20.0"
{
  %\override Beam.damping = #5
  \override Beam.positions = #'(5 . 5)
  g''8 b b c'' c'' b b g''
}


And for an automated approach:


\version "2.22.0"

#(define NEAR -1)
#(define FAR 1)
flattenPositions =
#(define-scheme-function
  (rel-pos) (number?)
  (grob-transformer 'positions
   (lambda (grob orig)
(let* ((dir (ly:grob-property grob 'direction))
   (ys (ordered-cons (car orig) (cdr orig)))
   (y (interval-index ys (* dir rel-pos
 (cons y y)

{
  \override Beam.positions = \flattenPositions #NEAR
  g''8 b b c'' a' b'' b'' d'
  \override Beam.positions = \flattenPositions #CENTER
  g''8 b b c'' a' b'' b'' d'
  \override Beam.positions = \flattenPositions #(* 2 FAR)
  g''8 b b c'' a' b'' b'' d'
}



-- Aaron Hill



Re: Changing volta number text

2021-05-14 Thread Aaron Hill

On 2021-05-14 2:47 pm, Ralph Palmer wrote:

I *did* find a thread in the archive :
change of volta number
which has gotten me close, but has an extra end-repeat before the first
volta ending bracket. I'm also not sure the format is the most recent.


How about this?


\version "2.22.0"
\include "english.ly"

changeVoltaText =
#(define-music-function
  (text) (markup?)
  (define (is-volta-text? cmd)
   (and (pair? cmd) (eq? 'volta (car cmd)) (markup? (cadr cmd
  (define (replace-volta-text cmd)
   (if (is-volta-text? cmd) `(volta ,text) cmd))
  (define (proc ctxt)
   (let ((cmds (ly:context-property ctxt 'repeatCommands)))
(set! cmds (map replace-volta-text cmds))
(ly:context-set-property! ctxt 'repeatCommands cmds)))
  #{ \context Score \applyContext #proc #} )

test = {
  \time 3/4
  \repeat volta 3
  {
a'4 b' c' |
b'4 c' d' |
  }
  \alternative {
{
  \changeVoltaText "1., 3."
  e'4 f' g' |
}
{
  d'4 c' b' |
}
{
  \changeVoltaText \markup \with-color #red "4."
  g'4 a' b' |
}
  }
  c'1
}

\score {
  \test
}


NOTE: I'm using \markup in the final alternative just to demonstrate 
that it works.



-- Aaron Hill



Re: Changing volta number text

2021-05-14 Thread Aaron Hill

On 2021-05-14 6:40 pm, Ralph Palmer wrote:
Excellent! Thank you, Aaron. I wish I could understand what your 
function

does - how it works.


The technique involves querying the current Score.repeatCommands and 
replacing any existing (volta "...") command with the user-provided 
version.  This preserves the other repeat commands such as (end-repeat) 
and (volta #f).


Here is a minorly-refactored version with some documentation, comments, 
and a helpful usage warning:



\version "2.22.0"
\include "english.ly"

changeVoltaText =
#(define-music-function
  (text) (markup?)
  (_i "Replaces the volta text within the currently-set 
@code{repeatCommands}.")


  (define (volta-text? cmd)
   ;; Look for the (volta "...") pattern.
   (and (pair? cmd)
(eq? 'volta (car cmd))
(markup? (cadr cmd
  (define (replacer cmd)
   (if (volta-text? cmd) `(volta ,text) cmd))
  (define (proc ctxt)
   (let ((cmds (ly:context-property ctxt 'repeatCommands '(
(if (any volta-text? cmds)
 (ly:context-set-property! ctxt 'repeatCommands (map replacer cmds))
 (ly:input-warning (*location*) "No volta text was replaced."

  #{ \context Score \applyContext #proc #})

test = {
  \time 3/4
  \repeat volta 3
  {
a'4 b' c' |
\changeVoltaText "dud"
#(ly:expect-warning "No volta text was replaced.")
b'4 c' d' |
  }
  \alternative {
{
  \changeVoltaText "1., 3."
  e'4 f' g' |
}
{
  d'4 c' b' |
}
{
  \changeVoltaText \markup \with-color #red "4."
  g'4 a' b' |
}
  }
  c'1
}

\score {
  \test
}




-- Aaron Hill



Re: Lyrics and Repeats

2021-05-18 Thread Aaron Hill

On 2021-05-18 6:21 am, Kaj Persson wrote:

So I have looked at the alternative method, suggested in Notification
Reference, to divide the piece, the voices in parts with one boundary
at at the \repeat. In my current case the repeat point also is where
the number of choral parts change, before that they have common words,
so the method with double angle brackets in the lyrics should be
applicable and suitable  But unfortunately I have not succeeded in
this work, and this was what I tried to present in my first post.
However I do not think the solution I presented is fully correct, but
it was a try. I also had come across the case when a second \lyricsto
introduced an extra \skip. With this post I include a special
presentation of that.

But back to the original task, probably it is impossible to solve it
in the present version of LilyPond. My wish is that with the "<< >>"
method you can forget all counting syllables in the first part of the
piece.


I do not have time to dig in much further, but I think there is an issue 
with using \lyricsto when you are already within it.  Note below that we 
only use \lyricsto once and do not mess about with associatedVoice 
either:



\version "2.22.0"

notes = \new Voice = melody \repeat unfold 8 { b'4 }
words = \new Lyrics \lyricsto melody {
  a a
  << { b b } \new Lyrics { c c d d } >>
  e e
}

<< \notes \words >>


This seems to do what you need by not requiring any skipping.  Lyrics 
"b" and "c" start at the same time, both waiting until "a" is done.  
Note that "d" continues on the second line as it is part of the same 
context as "c"; however, "e" does wait until "d" is complete before 
resuming lyrics in the original context.



-- Aaron Hill

Re: Handling transpositions gracefully

2021-05-17 Thread Aaron Hill

On 2021-05-17 5:43 pm, Mark Probert wrote:

Hi.

I'm not quite sure how to ask this, so please bear with me. Right now
I'm having fun doing jazz lead sheets (for which lilypond is a
fantastic tool--lilyjazz is fantastic! thank you!). What I find I'm
doing is creating a "concert" version, then making a bes version, then
a ees version (I play alto sax and cornet). Basically all the same
source except with a \transpose wrapper around the score.

Is there a recommended way of having a single source and then
triggering the multiple variant outputs? Or do I simply put the stuff
that remains constant an include and have three separate shells for the
different tranpositions?

Any thoughts? (I imagine this is a solved problem...)


You could use multiple \books along with \bookOutputSuffix:


\version "2.22.0"

asdf = \relative f' {
 \time 3/4 \key f \major
 f4. c'8 g4 | a2. \bar "|."
}

\book { \bookOutputSuffix "C" \transpose c c \asdf }
\book { \bookOutputSuffix "Bb" \transpose bes, c \asdf }
\book { \bookOutputSuffix "Eb" \transpose ees c \asdf }


(I might have messed up the actual transpositions, but you should get 
the idea.)



-- Aaron Hill



Re: Lyrics and Repeats

2021-05-15 Thread Aaron Hill

On 2021-05-15 9:07 pm, Kaj Persson wrote:

[...]


\addlyrics and \lyricsto are related constructs that both create 
LyricCombineMusic.  This is what allows you to enter lyric syllables 
without specifying durations, where the durations are inferred by an 
associated Voice.  Note that in this special mode and only this mode, 
\skip durations are ignored.  So it is the count of \skips that matter.


When you are entering lyrics outside LyricCombineMusic, you must specify 
durations manually lest they be assumed given the most recently 
specified duration.  In this case, \skip carries its normal meaning 
where the duration matters.


It should be noted that \setting associatedVoice has no effect outside 
of LyricCombineMusic.


Here is an example demonstrating the difference between using \lyricsto 
and manual durations:



\version "2.22.0"

lyricSkip =
#(define-music-function
  (count) (integer?)
  "Inserts the specified number of lyric skips."
  #{ \repeat unfold #count \skip 1 #})

<<
  \new Voice = melody {
\time 3/4
\partial 4 g'8 8
\repeat volta 2 { 2 4 }
\alternative {
  { 2 4 | 2 8 8 }
  { 4 2 }
}
2. \bar "|."
  }
  \new Lyrics \lyricsto melody {
\set stanza = "lyricsto"
a b | c d | e f | g h i
  }
  \new Lyrics \lyricsto melody {
\lyricSkip 2 | j k \lyricSkip 5 | l m | n
  }
  \new Lyrics \lyricmode {
\set stanza = "manual"
a8 b | c2 d4 | e2 f4 | g2 h8 i
  }
  \new Lyrics \lyricmode {
\skip 4 | j2 k4 \skip 2.*2 | l4 m2 | n2.
  } >>



-- Aaron Hill

Re: Rehearsal mark and fermata over bar line

2021-05-11 Thread Aaron Hill

On 2021-05-11 10:03 am, Rachel Green wrote:

Hi,
How can I add two marks over a bar line - both a fermata and a
rehearsal mark? I figured out how to do each separately, but LilyPond
will only show one of them.
Best,
Rachel

\version "2.20.0"

\relative c
  {
  \time 4/4
  \clef C
  c1
\mark \default
\mark \markup { \musicglyph #"scripts.ufermata"}
  r4 r4
}


LSR 202 [1] demonstrates how to include a segno/coda sign as part of a 
single RehearsalMark.


LSR 575 [2] uses a hidden measure to make it appear that you have two 
RehearsalMarks at the same point in the music.


LSR 976 [3] implements its own custom engraver to support an arbitrary 
number of RehearsalMarks.



[1]: https://lsr.di.unimi.it/LSR/Item?id=202
[2]: https://lsr.di.unimi.it/LSR/Item?id=575
[3]: https://lsr.di.unimi.it/LSR/Item?id=976



-- Aaron Hill



Re: Nashville Number System, again

2021-06-04 Thread Aaron Hill

On 2021-06-04 5:28 pm, Flaming Hakama by Elaine wrote:

However, there is one other Nashville rule that would need to be
accommodated, which is that for minor, the numbers still follow the
relative major.

So, for a song in A minor that goes A- D- A- E7 A- it is not 1- 4- 1- 
57 1-

as you might expect, but is rather 6- 2- 6- 37 6-


I thought the numerals were always relative to the key.  So a "1" is 
always an "A" even if it is "A major" or "A minor".  Where "A major" and 
"A minor" differ is in the assumed chord types:


(from Wikipedia)

Nashville numerical notation 1  2   3  4  5  
6  7

--
Chord type (major key)   major  minor   minor  major  
major  minor  diminished
Chord type (minor key)   minor  diminished  major  minor  
minor  major  major
Chord type (harmonic minor key)  minor  diminished  augmented  minor  
major  major  diminished


So if you wanted "Am Dm Am E7" then that becomes "1 4 1 5M7" in "A 
minor" and "1 4 1 57" in "A harmonic minor".



-- Aaron Hill



Re: \partCombine question

2021-06-02 Thread Aaron Hill

On 2021-06-02 1:21 pm, Federico Sarudiansky wrote:

Hi,

I have a question regarding \partCombine.

Consider the following example:

[...]

Is there a way to produce something like the third staff (except for 
the

double forte) using only \partCombine? I.e. something like setting a
mininum "a2" length? I like the results of the first staff regarding
dynamics but I feel the constant on/off of the "a2" is a little 
annoying.


I know I can avoid the "a2" setting an empty text with \set 
Staff.aDueText
= ##f and then restore it to its previous value. But I wonder if there 
is

another option. Even in this case, if no "a2" is present, it would be
really nice to have the two voices explicit, to avoid confusion.


I would imagine \partCombineApart (or its kin) can help with this.


-- Aaron Hill



Re: SVG export - how might you add classes for all graphical objects?

2021-06-29 Thread Aaron Hill

On 2021-06-29 9:43 am, Jean Abou Samra wrote:

However, this problem can be solved by writing
an engraver (those are the powerful tools that
\applyOutput uses under the hood).

\version "2.22.0"

\layout {
  \context {
\Score
\consists
  #(lambda (context)
 (make-engraver
   (acknowledgers
 ((grob-interface engraver grob source-engraver)
(set! (ly:grob-property grob 'output-attributes)
  `((class . ,(grob::name grob
  }
}

<<
  { c d e f }
  \\
  { g a b c' }




NOTE: You might want this engraver to *append* to the class attribute, 
so you can still specify classes on an individual basis:



\version "2.22.0"

SvgAddClassName =
#(lambda (ctxt)
  (define (add-class-name grob)
   (let* ((attribs (ly:grob-property grob 'output-attributes '()))
  (class (ly:assoc-get 'class attribs '()))
  (name (grob::name grob)))
(set! class (if (null? class) name (format #f "~a ~a" class name)))
(set! attribs (assoc-set! attribs 'class class))
(ly:grob-set-property! grob 'output-attributes attribs)))
  (make-engraver
   (acknowledgers
((grob-interface engraver grob source)
 (add-class-name grob)

\layout { \context { \Score \consists \SvgAddClassName } }

{ \tweak output-attributes #'((class . foo)) b'4 }



-- Aaron Hill



Re: Change size of all notes in one voice with partCombine

2021-07-01 Thread Aaron Hill

On 2021-07-01 10:44 pm, Aaron Hill wrote:

[...]


Also, here's a minor refactor of \localFontSize better separating some 
concerns:



\version "2.22.0"

localFontSize =
#(define-music-function
  (font-size music)
  (number? ly:music?)
  (map (lambda (m)
(ly:music-set-property! m 'tweaks
 (cons `(font-size . ,font-size)
  (ly:music-property m 'tweaks
   (extract-typed-music music 'rhythmic-event))
  music)

soprano = \fixed c' { f4 g a b c'2 }
tenor = \fixed c' { d4 e \tweak color #red f' g 2 }
\partCombine
  { \partCombineChords \soprano }
  { \stemUp \localFontSize -3 \tenor }


The test case below includes an inline \tweak and a chord within the 
tenor part.



-- Aaron Hill

Re: Change size of all notes in one voice with partCombine

2021-07-01 Thread Aaron Hill

On 2021-07-01 10:11 pm, Dinh Hoang Tu wrote:

Yes, I did try \partCombineChords, but it doesn't seem what I expect.
Expectation is 2 notes on same stem, one upper, one lower, not on 
separate

stems.

Below is the test and attached result (2 notes have separate stems)

\version "2.22.1"
localFontSize =
#(define-music-function (font-size music) (number? ly:music?)
   (for-some-music
 (lambda (m)
   (if (music-is-of-type? m 'rhythmic-event)
   (begin
 (set! (ly:music-property m 'tweaks)
   (cons `(font-size . ,font-size)
 (ly:music-property m 'tweaks)))
 #t)
   #f))
 music)
   music)

soprano = { f'4 g'4 a'4 b'4 c''2 }
basso = { d'4 e' f'' g' a'2 }
alto = { d'4 e' \stemUp f'' g' a'2 }
tenor = { d'4 e' f'' g' a'2 }
\new Score { \new Staff << \partCombineChords \soprano \basso >> }
\new Score { \new Staff << \partCombineChords \soprano \alto >> }
\new Score { \new Staff << \partCombineChords \soprano \localFontSize 
-3

\tenor >> }

Please advice if any mistake or missing.


\partCombineChords is not a substitute for \partCombine.

The former just sets an internal state for the part combiner, however 
you must use \partCombine to invoke the combiner.  Consider:



soprano = { f'4 g'4 a'4 b'4 c''2 }
tenor = { d'4 e' f'' g' a'2 }
\partCombine
  { \partCombineChords \soprano }
  { \stemUp \localFontSize -3 \tenor }



-- Aaron Hill

Re: Warning: avoid-slur not set

2021-07-03 Thread Aaron Hill

On 2021-07-03 1:54 pm, Jonathan Armitage wrote:

I can see that the slur clashes with the i, but in spite of much
googling, I cannot for the life of me figure out how to set
avoid-slur. Please could you advise.


You can \override it for a more global effect or you can \tweak it to 
localize the impact.  Here is an example of the latter approach:



\version "2.20.0"
\language "english"

outside = \tweak avoid-slur #'outside \etc
rhf = \rightHandFinger \etc

\relative c' {
  \set fingeringOrientations = #'(left)
  \set strokeFingerOrientations = #'(up)

  \key d \major
  \stemDown
  ( )  fs
}



-- Aaron Hill



Re: Parenthensize a horizontal group?

2021-06-30 Thread Aaron Hill

On 2021-06-30 9:00 pm, Mark Probert wrote:

Hi.

I've looked through docs and snippets and can't seem to find a way to
place parens around a horizontal group of notes (an "optional"
indicator for leadsheets). I've tried

 \parenthesize { a8 bes }

but nope. Is there a simple way? I want to do something like:

 \mark "(" a8 bes \mark ")"

and have the parens aligned on the center of the staff.


Does LSR 902 [1] help?

[1]: https://lsr.di.unimi.it/LSR/Item?id=902


-- Aaron Hill



Re: Parenthensize a horizontal group?

2021-06-30 Thread Aaron Hill

On 2021-06-30 9:07 pm, Aaron Hill wrote:

On 2021-06-30 9:00 pm, Mark Probert wrote:

Hi.

I've looked through docs and snippets and can't seem to find a way to
place parens around a horizontal group of notes (an "optional"
indicator for leadsheets). I've tried

 \parenthesize { a8 bes }

but nope. Is there a simple way? I want to do something like:

 \mark "(" a8 bes \mark ")"

and have the parens aligned on the center of the staff.


Does LSR 902 [1] help?

[1]: https://lsr.di.unimi.it/LSR/Item?id=902



Or perhaps this which might be easier to use if this sort of thing 
occurs often:



\version "2.22.0"

parenthesizeMusic =
#(define-music-function (music) (ly:music?)
  (define ((stencils which) grob)
   (let* ((stens (parentheses-item::calc-parenthesis-stencils grob))
  (sten (which stens)))
(if (eq? which first) (list sten point-stencil) (list point-stencil 
sten

  (define (add-tweak event tweak)
   (ly:music-set-property! event 'tweaks
(cons tweak (ly:music-property event 'tweaks '()
  (let ((evs (extract-typed-music music 'rhythmic-event)))
   (ly:music-set-property! (first evs) 'parenthesize #t)
   (add-tweak (first evs) `((ParenthesesItem . stencils) . ,(stencils 
first)))

   (ly:music-set-property! (last evs) 'parenthesize #t)
   (add-tweak (last evs) `((ParenthesesItem . stencils) . ,(stencils 
second

  music)

{
  \override ParenthesesItem.font-size = 5
  \override ParenthesesItem.extra-offset =
#(lambda (grob) (cons 0 (* -1/2 (ly:grob-staff-position grob
  \parenthesizeMusic {  d' e' f' g' }
}



-- Aaron Hill

Re: SVG export - how might you add classes for all graphical objects?

2021-06-29 Thread Aaron Hill

On 2021-06-29 12:45 pm, Carl Sorensen wrote:

I believe that the logical implications of side-effects are not very
concerning when local variables are set!, so there's probably very
little or no downside to the set!s in Aaron's code.  In fact, it's
possible that Aaron's code will use less heap space by re-using class
instead of adding a new variable grob-class-name.  But I can't help
myself; I want to avoid the grief  Sussman would give me over two
unneeded set! calls.


I prefer that pattern of set! calls because it helps you avoid nesting 
S-expressions too deeply, which I feel greatly improves readability and 
maintainability.  It is the same reason I bothered to define the 
add-class-name procedure, so that it would not be nested within the 
engraver definition itself, better separating concerns.


Additionally, I have taken flack for pushing some of the more functional 
elements of Scheme programming.  (Mention the word "lambda" once, and 
everyone assumes you are a pure functional zealot.)  Regardless, I have 
tended to favor a more imperative approach lately, something that is 
likely to be more consumable for users of LilyPond.



-- Aaron Hill



Re: SVG export - how might you add classes for all graphical objects?

2021-06-29 Thread Aaron Hill

On 2021-06-29 1:20 pm, David Kastrup wrote:


\version "2.22.0"

SvgAddClassName =
#(lambda (ctxt)
  (define (add-class-name grob)
   (let* ((attribs (ly:grob-property grob 'output-attributes '()))
  (class (ly:assoc-get 'class attribs '()))
  (name (grob::name grob)))
(set! class (if (null? class) name (format #f "~a ~a" class 
name)))

(set! attribs (assoc-set! attribs 'class class))
(ly:grob-set-property! grob 'output-attributes attribs)))
  (make-engraver
   (acknowledgers
((grob-interface engraver grob source)
 (add-class-name grob)


That assoc-set! looks like a stinker.  Doesn't it mess with shared data
structures?


Hrm... would it be better to explicitly alist-copy the result from 
ly:assoc-get?  Actually, I guess you could do:



(alist-cons 'class ... (alist-delete 'class attribs))


...since the SRFI says that alist-delete does not modify the original 
structure, only that it might return an alist with a common tail.


And on this point, should LilyPond provide an ly:assoc-set to pair with 
ly:assoc-get that avoids potential issues with shared structures?



-- Aaron Hill



Re: SVG export - how might you add classes for all graphical objects?

2021-06-29 Thread Aaron Hill

On 2021-06-29 1:45 pm, David Kastrup wrote:

Aaron Hill  writes:

Hrm... would it be better to explicitly alist-copy the result from
ly:assoc-get?  Actually, I guess you could do:


(alist-cons 'class ... (alist-delete 'class attribs))



Either that or not even bother about deleting the other entry.


If you don't remove the old entry, then the SVG looks like this:



I am fairly certain that it is not valid to have the same attribute name 
twice in an element in SGML.



-- Aaron Hill



Re: error :GUILE signaled an error for the expression beginning here #

2021-07-11 Thread Aaron Hill

On 2021-07-11 12:32 pm, ming tsang wrote:

I am confused about this "file information" LSR.
Yesterday, I did a ""file>save as" to a file name to
untitled_LSR_file-info_v2182.ly. This morning I tried to run the
untitled_LSR_file-info_v2182.ly, but I got run error:


The code in LSR 197 is not able to properly handle non-ASCII characters 
in a file path.  Upon review, its use of object->string is mangling the 
filename.  Also, the entire premise of the snippet is predicated on the 
false assertion that the command-line only consists of the filename in 
question.  In practice, there are likely to be many other arguments.  At 
best, you might be able to rely on the filename being the last argument:



\version "2.18.2"

filename = #(last (command-line))
\markup { "File Name =" \filename }


However, why mess about with reparsing the command-line arguments in the 
first place?  LilyPond has already done this for you, so just ask 
LilyPond for the current filename:



\version "2.20.0" % or newer

filename = #(define-scheme-function () ()
 (car (ly:input-file-line-char-column (*location*
\markup { "File Name =" \filename }


You could adapt the above to work on 2.18.2, but calling the function 
within markup requires some extra sugar:



\version "2.18.2"

filename = #(define-scheme-function (parser location) ()
 (car (ly:input-file-line-char-column location)))
\markup { "File Name =" $#{ \filename #} }


All the more reason to leave 2.18.2 behind and just focus on the newer 
versions of LilyPond.



-- Aaron Hill



<    4   5   6   7   8   9   10   11   12   13   >