Re: Sending around contexts

2021-10-29 Thread Stefano Troncaro
Hi all! I just needed to state that this thread completely blew my mind.
Sorry for the spam, I found this too awesome to watch silently.

El vie, 29 oct 2021 a las 10:25, Kieren MacMillan (<
kieren_macmil...@sympatico.ca>) escribió:

> Hi David,
>
> >> My *big* question is: Can notes be pushed *with timing
> >> synchronization* between context?
> >
> > Without storing events, how would it even be possible without timing
> > synchronisation?  Iteration happens in time order.  Well, apart from
> > grace timing quirks.
>
> 1. That was my intuition, but I’m glad to hear it confirmed.
>
> 2. The grace timing quirk — which has (“coincidentally”?!) been plaguing
> me on my current engraving project — will likely be even more bothersome in
> the type of “context-jumping” scores I’m talking about.
>
> >> Can this kind of mechanism be used to [easily] engrave scores like the
> >> following?
> >
> > There is no "easily" in such scores.  The question is rather whether you
> > encounter problems doing such scores where particular tools can simplify
> > the work of creating the input.  For that one first has to develop an
> > input process and see what problems are "hard" in that context.
>
> I’ll see what I can do about drawing up a reasonably-Minimum Working
> Example to act as an initial straw man.
>
> Thanks,
> Kieren.
> 
>
> Kieren MacMillan, composer (he/him/his)
> ‣ website: www.kierenmacmillan.info
> ‣ email: kie...@kierenmacmillan.info
>
>
>


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

2021-01-16 Thread Stefano Troncaro
Harm, Aaron, thank you both for your answers. Both are great solutions!

El sáb, 16 ene 2021 a las 0:27, Aaron Hill ()
escribió:

> 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
>


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

2021-01-15 Thread 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?


Re: edition-engraver mod on first note

2020-11-07 Thread Stefano Troncaro
I rendered your MWE and Lilypond created the red note... then I checked the
repo and it seems I don't have the newest version, I'm using an old commit
from the refactor-override branch. I will check later with the latest
master and let you know how it goes.

El sáb., 7 nov. 2020 a las 19:47, damianlegassick ()
escribió:

> Hi Stefano
>
> this is extracted from the example-1.ly from the repo
>
> \version "2.20.0"
> \include "oll-core/package.ily"
> \loadPackage edition-engraver
> \addEdition test
> \editionMod test 1 0/4 along.Voice.A \once \override NoteHead.color = #red
> \editionMod test 1 1/4 along.Voice.A \once \override NoteHead.color =
> #green
> \consistToContexts #edition-engraver Staff.Voice
> \new Staff \with { \editionID along } { c'4 c' c' c' }
>
> no red note...
>
> Damian
>
> On 7 November 2020 at 19:55, Stefano Troncaro 
> wrote:
>
> Hi Damian, can you post an example? If I remember correctly (I may be
> misremembering) there is an issue in scores starting with \partial
>
> But for example I use the following on a score:
>
> LVm = \musicPath PNO.left.Voice.main
>> \editionMod ed 1 0 \LVm {
>>   \once \override DynamicText.X-extent = #empty-interval
>>   <>_#(make-dynamic-text "col pedale")
>> }
>
>
> And it works properly.
>
> Hope that helps,
> Stéfano
>
> El vie., 6 nov. 2020 a las 13:41, damianlegassick (<
> damianlegass...@mac.com>) escribió:
>
>> Hi
>>
>> I can't persuade edition-engraver to add an \editionMod starting on the
>> downbeat of the first bar. I can't even do it with the example.ly from
>> the repo (is that why there's an R1 at the top?).
>>
>> any clues for a workaround or am I being dumb?
>>
>> Damian
>>
>


Re: edition-engraver mod on first note

2020-11-07 Thread Stefano Troncaro
Hi Damian, can you post an example? If I remember correctly (I may be
misremembering) there is an issue in scores starting with \partial

But for example I use the following on a score:

LVm = \musicPath PNO.left.Voice.main
> \editionMod ed 1 0 \LVm {
>   \once \override DynamicText.X-extent = #empty-interval
>   <>_#(make-dynamic-text "col pedale")
> }


And it works properly.

Hope that helps,
Stéfano

El vie., 6 nov. 2020 a las 13:41, damianlegassick ()
escribió:

> Hi
>
> I can't persuade edition-engraver to add an \editionMod starting on the
> downbeat of the first bar. I can't even do it with the example.ly from
> the repo (is that why there's an R1 at the top?).
>
> any clues for a workaround or am I being dumb?
>
> Damian
>


Re: arranger.ly (new library)

2020-10-23 Thread Stefano Troncaro
+1 for adding this to oLL. I remember trying to do this with the Edition
Engraver but being unable to achieve it.

El jue., 22 oct. 2020 a las 21:49, Gilles Thibault ()
escribió:

> Le 2020-10-23 02:19, Andrew Bernard a écrit :
> > Hi Gilles,
> >
> > Why don't we put it in openLilyLib? Avoid the balkanisation process of
> > having dozens of personal git repos? I am happy to prepare it and do
> > the work. OLL is got, so nothing will change in terms of development.
> >
> > Andrew
> >
> > On Fri, 23 Oct 2020 at 11:04, Gilles Thibault  wrote:
> >>
> >> I have been using a Lilypond library called "arranger.ly" for several
> >> years. It has made it much easier for me to create arrangements for
> >> large ensembles and it is time for me to share this new approach with
> >> the community.
> >>
> >> W
>
> Oh yes. Very good idea. Thank you.
>
> --
> Gilles
>
>


Re: TextScript baseline in Dynamics context

2019-12-27 Thread Stefano Troncaro
Hi Kieren, I was not aware of that function. Thank you for sharing it and
thank you Harm for coding it!

El vie., 27 dic. 2019 a las 16:24, Kieren MacMillan (<
kieren_macmil...@sympatico.ca>) escribió:

> Hi Paul,
>
> > is "custdyn" already in Lily or did you define it somewhere?
>
> Harm built it (see, e.g.,
> https://lists.gnu.org/archive/html/lilypond-user/2019-09/msg00159.html),
> but I changed the name of the function in my own include file(s).
>
> Hope that helps!
> Kieren.
> 
>
> Kieren MacMillan, composer (he/him/his)
> ‣ website: www.kierenmacmillan.info
> ‣ email: i...@kierenmacmillan.info
>
>
>


Re: Put the property of a grob in the output-attributes list

2019-12-24 Thread Stefano Troncaro
Hi Paolo,

I've worked a bit on the token function and I think it's considerably
improved. In the event->grob and event->output-attribute-list functions you
can set what properties you want for what grob/event, making it easier to
expand the funcion as needed instead of having to manually write the
function for each case.

I made it so that the syntax for \token is the same as the syntax for
\tweak since I think that will be more consistent with Lilypond's already
implemented syntax. In the example there is a comment with a quick
explanation nevertheless, and it should be apparent why there is a problem
with the "\token f\markup {'foobar'}" example you described in your
previous email.

The bad news is that I checked the Internals Reference and I don't know how
to find absolute coordinates for TextScripts, since they are placed
relative to other objects. Perhaps someone else can help with this.


\version "2.19.83"

% Syntax: same as \tweak:
%   \tweak Beam.color #red c8 d e c--- valid
%   \tweak Beam.color #red c8 [ d e c ]--- invalid
%   c8 -\tweak Beam.color #red [ d e c ]   --- use this instead of invalid
example above
% In short, if the object that is to be modified is found in the music
input, the tweak
% must be placed before the object. Only \tweak before a note if the grob
to be modified
% is created from the note event (for example, noteheads, stems,
accidentals, etc).

token = #(let* ((ctr 0)
(ctr!
 (lambda ()
   (set! ctr (1+ ctr))
   ctr))
(event->grob '())
(event->output-attribute-list '()))
   (set! event->grob
 (define-scheme-function (evt) (symbol?)
   (case evt
 ((BeamEvent) 'Beam)
 ((NoteEvent) (event->grob 'BeamEvent)) ;modify an
automatic beam
 ((TextScriptEvent) 'TextScript)
 (else (ly:error (format "token can't handle ~a\n"
evt))
   (set! event->output-attribute-list
 (define-scheme-function (evt) (symbol?)
   (case evt
 ((BeamEvent) '(beam-thickness))
 ((NoteEvent) (event->output-attribute-list
'BeamEvent)) ;modify an automatic beam
 ((TextScriptEvent) '(direction))
 (else '()

   (define-music-function (mus) (ly:music?)
 (let* ((id (format #f "foobar_~a" (ctr!)))
(type (ly:music-property mus 'name))
(sym (event->grob type))
(atts (event->output-attribute-list type)))
   #{ \tweak #(list sym 'after-line-breaking) #(lambda (grob)
(let* ((output-atts (ly:grob-property grob 'output-attributes))
   (atts-to-append
(map (lambda (att)
   (cons att (ly:grob-property grob att)))
  atts))
   (output-atts (append output-atts atts-to-append)))
  (ly:grob-set-property! grob 'output-attributes output-atts)))
  \tweak #(list sym 'output-attributes 'id) #id
  #mus #} )))

\relative { c'4 \token d8 -\token -\markup "hello" e f -\token [ g e] c }


Hope this helps!

El lun., 23 dic. 2019 a las 6:08, Paolo Prete ()
escribió:

> Hi Stefano,
>
> 1) I need to store in the output-attributes the "direction"  of the
> TextScript (it says if the object is above or below the staff)
> I can obtain this info with map-some-music() [ by looking
> at (ly:music-property evt 'direction) ]. But in this way I need to set the
> direction in the music expression.
>
> \token f^\markup {'foobar'}
>
> Instead, I want to obtain this info also when it's not set by the me in
> the music expression, and it's calculated by Lilypond:
>
> \token f\markup {'foobar'}
>
> 2) I need to obtain the absolute and relative coordinates calculated by
> Lilypond for the same TextScript.
>
> Point 1) is very important, because I don't have this info in the svg
> output.
> About the coordinates: I can calculate them by parsing the svg file, as I
> did for beams and slurs. But it would be better if I obtain them
> automatically by Lilypond and pass them to the SVG Javascript script.
>
> Thanks again!
> Best
> P
>
>
>
>
>
>
>
>
>
>
>
>
> On Mon, Dec 23, 2019 at 8:38 AM Stefano Troncaro <
> stefanotronc...@gmail.com> wrote:
>
>> Hi Paolo, I'm glad you found it useful! Could you give me an example of
>> what you want to do with TextScripts? Besides giving them an id, what
>> properties do you need stored in the svg output attributes?
>>
>> El dom., 22 dic. 2019 a las 14:04, Paolo Prete ()
>> escribió:
>>
>>> Tha

Re: Put the property of a grob in the output-attributes list

2019-12-22 Thread Stefano Troncaro
Hi Paolo, I'm glad you found it useful! Could you give me an example of
what you want to do with TextScripts? Besides giving them an id, what
properties do you need stored in the svg output attributes?

El dom., 22 dic. 2019 a las 14:04, Paolo Prete ()
escribió:

> Thank you again Stefano. This helps again and you will see how good it
> will fit in the library I'm coding.
> However, I can't make it work for a TextScript (either before the notevent
> or before the markup token). I tried also map-some-music(), but it doesn't
> fix it.
>
> \version "2.19.83"
>
> token = #(let* ((ctr 0)
> (ctr! (lambda ()
> (set! ctr (1+ ctr))
> ctr)))
>(define-music-function (mus) (ly:music?)
>  (let* ((id (format #f "foobar_~a" (ctr!)))
> (type (ly:music-property mus 'name))
> (mexp (case type
> ((BeamEvent NoteEvent TextScriptEvent )
>   #{ \tweak TextScript.after-line-breaking #(lambda
> (grob)
>(let* ((outprop (ly:grob-property grob
> 'direction))
>   (prop (ly:grob-property grob 'direction))
>   (outprop (append outprop
> `((beam-thickness . ,prop)
>  (display (format #f "\n\n~a\n\n"
> prop))
>  (ly:grob-set-property! grob
> 'output-attributes outprop)))
>  \tweak TextScript.output-attributes.id #id #mus
> #} )
> (else #{ \tweak output-attributes.id #id #mus #} 
>    mexp)))
>
> \relative {  c'4 d8-\token [ e ] \token f^\markup {'iii'} g c,4  }
>
> On Sun, Dec 22, 2019 at 4:21 PM Stefano Troncaro <
> stefanotronc...@gmail.com> wrote:
>
>> Hi Paolo,
>>
>> The main problem here is that \tweak can only modify the object that is
>> next to it, so you can tweak a NoteHead to modify an automatic beam, but to
>> modify a beam that is created manually because of a [ in the input you need
>> to place the tweak before the [. See:
>>
>> %
>> \version "2.19.83"
>>
>> \relative {
>>   c'8[ \tweak Beam.color #red d]   %doesn't work
>>   \tweak Beam.color #red e f   %works
>>   \tweak Beam.color #red g[ a] %doesn't work
>>   b -\tweak Beam.color #red [ c ]  %works
>> }
>> %
>>
>> That said, I modified the function you sent so that it also considerds
>> NoteEvents and modifies the automatically created beams with the desired
>> properties:
>>
>> %
>> \version "2.19.83"
>>
>> token = #(let* ((ctr 0)
>> (ctr! (lambda ()
>> (set! ctr (1+ ctr))
>> ctr)))
>>(define-music-function (mus) (ly:music?)
>>  (let* ((id (format #f "foobar_~a" (ctr!)))
>> (type (ly:music-property mus 'name))
>> (mexp (case type
>> ((BeamEvent NoteEvent)
>>   #{ \tweak Beam.after-line-breaking #(lambda (grob)
>>(let* ((outprop (ly:grob-property grob
>> 'output-attributes))
>>   (beam-thickness (ly:grob-property grob
>> 'beam-thickness))
>>   (outprop (append outprop
>> `((beam-thickness . ,beam-thickness)
>>  ;(display (format #f "\n\n~a\n\n"
>> beam-thickness))
>>  (ly:grob-set-property! grob
>> 'output-attributes outprop)))
>>  \tweak Beam.output-attributes.id #id #mus #} )
>> (else #{ \tweak output-attributes.id #id #mus #} 
>>mexp)))
>>
>> \relative { c'4 d8-\token [ e ] \token f g c,4 }
>> %
>>
>> The code could be cleaner I think, I'll try to improve it if I get some
>> free time. Meanwhile I hope this helps
>>
>> El dom., 22 dic. 2019 a las 7:58, Paolo Prete ()
>> escribió:
>>
>>> Hello all.
>>>
>>> the following function (thanks to Stefano!) inserts the beam-thickness
>>> property of a Beam in the list of output-attributes of the corresponding
>>> SVG item. It does its job if I place the function soon before a beam symbol
>>> "[".  But it doesn't work (no errors, but the output-attributes property is
>>> not set) if  place it before a notename. How can I fix that? Should I
>>> map-some

Re: Put the property of a grob in the output-attributes list

2019-12-22 Thread Stefano Troncaro
Hi Paolo,

The main problem here is that \tweak can only modify the object that is
next to it, so you can tweak a NoteHead to modify an automatic beam, but to
modify a beam that is created manually because of a [ in the input you need
to place the tweak before the [. See:

%
\version "2.19.83"

\relative {
  c'8[ \tweak Beam.color #red d]   %doesn't work
  \tweak Beam.color #red e f   %works
  \tweak Beam.color #red g[ a] %doesn't work
  b -\tweak Beam.color #red [ c ]  %works
}
%

That said, I modified the function you sent so that it also considerds
NoteEvents and modifies the automatically created beams with the desired
properties:

%
\version "2.19.83"

token = #(let* ((ctr 0)
(ctr! (lambda ()
(set! ctr (1+ ctr))
ctr)))
   (define-music-function (mus) (ly:music?)
 (let* ((id (format #f "foobar_~a" (ctr!)))
(type (ly:music-property mus 'name))
(mexp (case type
((BeamEvent NoteEvent)
  #{ \tweak Beam.after-line-breaking #(lambda (grob)
   (let* ((outprop (ly:grob-property grob
'output-attributes))
  (beam-thickness (ly:grob-property grob
'beam-thickness))
  (outprop (append outprop
`((beam-thickness . ,beam-thickness)
 ;(display (format #f "\n\n~a\n\n"
beam-thickness))
 (ly:grob-set-property! grob 'output-attributes
outprop)))
 \tweak Beam.output-attributes.id #id #mus #} )
(else #{ \tweak output-attributes.id #id #mus #} 
   mexp)))

\relative { c'4 d8-\token [ e ] \token f g c,4 }
%

The code could be cleaner I think, I'll try to improve it if I get some
free time. Meanwhile I hope this helps

El dom., 22 dic. 2019 a las 7:58, Paolo Prete ()
escribió:

> Hello all.
>
> the following function (thanks to Stefano!) inserts the beam-thickness
> property of a Beam in the list of output-attributes of the corresponding
> SVG item. It does its job if I place the function soon before a beam symbol
> "[".  But it doesn't work (no errors, but the output-attributes property is
> not set) if  place it before a notename. How can I fix that? Should I
> map-some-music() and iterate until I find the BeamEvent? I tried that too,
> but without success.
> Thanks.
>
> token = #(let* ((ctr 0)
> (ctr! (lambda ()
> (set! ctr (1+ ctr))
> ctr)))
>(define-music-function (mus) (ly:music?)
>  (let* ((id (format #f "foobar_~a" (ctr!)))
> (mexp #{ \tweak output-attributes.id #id #mus #} )
> (type (ly:music-property mus 'name))
> (mexp (case type
> ('BeamEvent
>   #{ \tweak Beam.after-line-breaking #(lambda (grob)
>(let* ((outprop (ly:grob-property grob
> 'output-attributes))
>   (beam-thickness (ly:grob-property grob
> 'beam-thickness))
>   (outprop (append outprop
> `((beam-thickness . ,beam-thickness)
>  (begin
>   (ly:grob-set-property! grob
> 'output-attributes outprop)
>   (display "\n\n")
>   (display beam-thickness)
>   (display "\n\n"
>   #mexp #} )
> (else mexp
>mexp)))
>
> \relative { c'4 d8-\token [ e ] \token f[ g ] c,4 }
>


Re: Need help with Scheme code

2019-12-19 Thread Stefano Troncaro
Hi Paolo,

AFAIK the problem here is that \tweak reads the next event of the input and
you can't access those properties because the event has not been translated
to a grob yet so lilypond has not yet calculated those values (others more
suited than me may be able to explain it more elegantly or correct me if I
have conceptual errors).

For these types of situations I use both the "before-line-breaking" and the
"after-line-breaking" properties, both can be set to a function that is
passed the grob as a variable. So we can do the following to achieve what
you want:

\version "2.19.83"

token = #(let* ((ctr 0)
(ctr! (lambda ()
(set! ctr (1+ ctr))
ctr)))
   (define-music-function (mus) (ly:music?)
 (let* ((id (format #f "foobar_~a" (ctr!)))
(mexp #{ \tweak output-attributes.id #id #mus #} )
(type (ly:music-property mus 'name))
(mexp (case type
('BeamEvent
  #{ \tweak Beam.after-line-breaking #(lambda (grob)
   (let* ((outprop (ly:grob-property grob
'output-attributes))
  (beam-thickness (ly:grob-property grob
'beam-thickness))
  (outprop (append outprop
`((beam-thickness . ,beam-thickness)
 (ly:grob-set-property! grob 'output-attributes
outprop)))
  #mexp #} )
(else mexp
   mexp)))

\relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }


I wrote the token function in a way that I think will be easy for you to
expand, testing for different types of events and saving different
properties to the output attributes property.

Hope this helps,
Stéfano

El mié., 18 dic. 2019 a las 17:11, Paolo Prete ()
escribió:

> Hi Jaap,
>
> it doesn't fit with what I'm searching for (sorry: my question was not
> enough clear) .
> I need to obtain the property set/calculated by Lilypond, not the one set
> by me.
> Shortly: for a Beam, how can I:
>
> (set! myVar positions-of-the-beam-set-by-lilypond)
>
> or:
>
> (set! myVar Y-offset-of-the-beam-set-by-lilypond)
>
> ?
>
> I don't understand if these properties are user-only settable, or if they
> are set by Lilypond too.
> If they are not set by Lilypond, how can I obtain them and  put them into
> myVar ?
>
> My aim is to pass these properties to the SVG script through the "
> output-attributes" mechanism, instead of having to parse the SVG output
> with JS (which is possible too, but I would like to avoid that)
>
> Thanks,
> P
>
> On Wed, Dec 18, 2019 at 6:57 PM  wrote:
>
>> Without giving you any solution, I can give you a hint:
>>
>>
>>
>> Write the music in the traditional way, with and without your
>> modification.
>>
>>
>>
>> In your lilypond file put:
>>
>> \displayMusic oldmusic
>>
>> \displayMusic newmusic
>>
>>
>>
>> And what you can see wht you have to write by observing the differences
>>
>>
>>
>> Jaap
>>
>>
>>
>> *From:* lilypond-user > de-wolff@gnu.org> *On Behalf Of *Paolo Prete
>> *Sent:* Wednesday, December 18, 2019 3:30 PM
>> *To:* Aaron Hill 
>> *Cc:* lilypond-user 
>> *Subject:* Re: Need help with Scheme code
>>
>>
>>
>> Thanks again.
>>
>> Now, from what I see, I can extract if #mus is a Beam
>> with  (ly:music-property mus 'name)  --> BeamEvent
>>
>> After that, how can I set, inside the same function you wrote, a variable
>> with the  beam-thickness value of the corresponding Beam?
>>
>> something like (pseudo code):  (set! myVar
>> current-value-of-beam-thickness )
>>
>>
>>
>>
>>
>>
>>
>> On Wed, Dec 18, 2019 at 5:14 AM Aaron Hill 
>> wrote:
>>
>> On 2019-12-17 6:01 pm, Paolo Prete wrote:
>> > And thanks again to the Scheme-master Aaron.
>>
>> I appreciate the kind words, though I doubt my experience rises to the
>> level of "master".
>>
>> > One last thing:
>> >
>> > how can I arrange that function so to obtain output-attributes =
>> > output-attributes + id ?
>> >
>> > For example: if output-attributes is (('a' . 'aa') ('i' . 'ii'))  it
>> > must
>> > become:(('a' . 'aa') ('i' . 'ii') ('id' . 'foobar_1'))
>>
>> Where or how are the other output-attributes being set?  It is my
>> understanding that output-attributes is unset by default, so any
>> \override or \tweak would not need to worry about existing definitions.
>>
>> That said, consider this pattern:
>>
>> 
>> \version "2.19.83"
>> { \tweak Accidental.output-attributes.id 123 bes'4 }
>> 
>>
>> Keep in mind this only *adds* a new key-value pair to the alist; it does
>> not change an existing entry with the same key.
>>
>>
>> -- Aaron Hill
>>
>>


Re: Need help with Scheme code

2019-12-17 Thread Stefano Troncaro
Hi Paolo,

After some googling and tweaking I managed to make the counter you wished:

\version "2.19.83"

#(define* (make-counter #:optional (cnt 0) (inc 1))
   (lambda ()
 (set! cnt (+ cnt inc))
 cnt))

#(define serial (make-counter))

token = -\tweak output-attributes #`((id . ,(string-append "foobar_"
(number->string (serial) \etc

\relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }

I will test your snippet for modifying beams later! Thank you for the work
you are doing.

Hope this helps!
Stéfano

El mar., 17 dic. 2019 a las 19:23, Paolo Prete ()
escribió:

> In addition, Stefano, If you have time, please try the snippet for tuning
> the beams (second attachment). Any test of these things are very helpful
> for me.
>
> On Tue, Dec 17, 2019 at 11:18 PM Stefano Troncaro <
> stefanotronc...@gmail.com> wrote:
>
>> Hi Paolo,
>>
>> Look at this:
>>
>> \version "2.19.83"
>>
>> token = -\tweak output-attributes #'((id . "foobar")) \etc
>>
>> \relative { c'4 d8 -\token [ e ] f2 }
>>
>> That achieves half of what you want. Now, how to make "foobar"
>> automatically increment I don't know, perhaps someone else can help with
>> that.
>>
>> Hope that helps!
>> Stéfano
>>
>> El mar., 17 dic. 2019 a las 19:06, Paolo Prete ()
>> escribió:
>>
>>> Hello all,
>>>
>>> In order to automate the reverse process of the lilypond+javascript
>>> snippets (write the GUI modifications of the grobs to the .ly file) I need
>>> to make the following code work:
>>>
>>> %
>>> token = \tweak output-attributes  #'((id . "foobar"))
>>>
>>> \score
>>> {
>>>{
>>>   a8 \token [ c' c' c']
>>>}
>>> }
>>>
>>> %
>>>
>>> But it doesn't compile.
>>> What's the right way to define the "token" variable?
>>>
>>> Note that I can compile on 2.19.84 (but not on 2.19.55) the following
>>> code
>>>
>>> %
>>>
>>> \score
>>> {
>>>{
>>>   a8 \tweak output-attributes  #'((id . "foobar")) [ c' c' c']
>>>}
>>> }
>>>
>>> %
>>>
>>> In addition: how can replace "foobar" with a global variable (string +
>>> number) that is incremented at each call of "token"  ?
>>> The ids must be: foobar_1, foobar_2  etc.
>>>
>>> Thanks,
>>> Paolo
>>>
>>>
>>>
>>>
>>>


Re: Need help with Scheme code

2019-12-17 Thread Stefano Troncaro
Hi Paolo,

Look at this:

\version "2.19.83"

token = -\tweak output-attributes #'((id . "foobar")) \etc

\relative { c'4 d8 -\token [ e ] f2 }

That achieves half of what you want. Now, how to make "foobar"
automatically increment I don't know, perhaps someone else can help with
that.

Hope that helps!
Stéfano

El mar., 17 dic. 2019 a las 19:06, Paolo Prete ()
escribió:

> Hello all,
>
> In order to automate the reverse process of the lilypond+javascript
> snippets (write the GUI modifications of the grobs to the .ly file) I need
> to make the following code work:
>
> %
> token = \tweak output-attributes  #'((id . "foobar"))
>
> \score
> {
>{
>   a8 \token [ c' c' c']
>}
> }
>
> %
>
> But it doesn't compile.
> What's the right way to define the "token" variable?
>
> Note that I can compile on 2.19.84 (but not on 2.19.55) the following code
>
> %
>
> \score
> {
>{
>   a8 \tweak output-attributes  #'((id . "foobar")) [ c' c' c']
>}
> }
>
> %
>
> In addition: how can replace "foobar" with a global variable (string +
> number) that is incremented at each call of "token"  ?
> The ids must be: foobar_1, foobar_2  etc.
>
> Thanks,
> Paolo
>
>
>
>
>


Re: A Javascript test code for modifying ties and slurs with mouse

2019-12-15 Thread Stefano Troncaro
Hi Paolo, I tried it out and it seems to be working great! This should save
a lot of time. Thank you!

El dom., 15 dic. 2019 a las 4:05, Werner LEMBERG () escribió:

>
> > At this point, here's the complete all-in-one .ly template.  [...]
>
> It would be nice if you could format this to avoid line lengths longer
> than 80 characters.  As the non-HTML part of your e-mail shows, the
> code becomes very hard to read otherwise.
>
>
> Werner
>
>


Re: A Javascript test code for modifying ties and slurs with mouse

2019-12-14 Thread Stefano Troncaro
Hi Paolo, I was also having that concern.

Elaine replied in a new thread with a solution for that, in which instead
of adding the script to the svg files with lilypond you just use an
external script. I haven't tested it yet but it seems to me like that'll be
a cleaner approach, you just include the file with the function to show the
control points and the layout definitions and that's all you need.

I guess you could make it even cleaner and have the shell script put the
include statement in the .ly file.

I'd go with that solution for now. Now what I'm curious about is if there's
a way to automate the process of bringing the modified shapes into the
lilypond file instead of having to manually paste every one. I have no clue
on how to achieve that honestly, but that'd be incredible.

HTH,
Stéfano

El sáb., 14 dic. 2019 a las 20:08, Paolo Prete ()
escribió:

> Hi Stefano,
>
> your suggestion produces the script for every page, but it requires to
> manually add a property in the \paper scope. Instead, I would like to
> automatically set this property, and leave the user to set all the score
> properties (including the paper's one) without messing up the code adding
> pieces of the template of the script. So to obtain something like (which is
> much cleaner):
>
> \include "JSSVGSlurTuner.ly"
>
> {
>
>  \addJSSVGSlurTuner
>
>  . my score .
>
> }
>
> Thanks for your help
> P
>
>
> On Sat, Dec 14, 2019 at 11:13 PM Stefano Troncaro <
> stefanotronc...@gmail.com> wrote:
>
>> Hi Paolo,
>>
>> Since Aaron's svg-script function creates an empty \markup, you can use
>> the properties oddFooterMarkup and evenFooterMarkup of the \paper block to
>> have your script embedded at the end of every page. Look:
>>
>> %%%
>> \version "2.19.83"
>>
>> svg-script = #(define-scheme-function (body) (string?)
>>(markup #:stencil (ly:make-stencil (list 'embedded-svg
>>  (string-join (list "<![CDATA["
>>body "]]>") "\n")) '(0 . 0) '(0 . 0
>>
>> script-for-every-page = \svg-script
>> #"var flat = document.getElementById('flat');
>>flat.style.color = 'red';
>>function spin(what, amount) {
>>  let angle = 0.0;
>>  return function () {
>>const bbox = what.getBBox();
>>const xform = ['rotate(',
>>  (angle = (angle + amount) % 360.0),
>>  bbox.x + 0.5 * bbox.width,
>>  bbox.y + 0.75 * bbox.height, ')'];
>>what.setAttribute('transform', xform.join(' '));
>>  }
>>}
>>setInterval(spin(flat, 5), 100);"
>>
>> \paper {
>>   oddFooterMarkup = \script-for-every-page
>>   evenFooterMarkup = \script-for-every-page
>> }
>>
>> { g'4 a' \tweak Accidental.output-attributes #'((id . "flat")) bes'2
>> \pageBreak
>>   g'4 a' \tweak Accidental.output-attributes #'((id . "flat")) bes'2 }
>> %%%
>>
>> Love what your script is doing so far!
>>
>> Hope that helps,
>> Stefano
>>
>> El sáb., 14 dic. 2019 a las 18:39, Paolo Prete ()
>> escribió:
>>
>>> Thanks Aaron, it did the trick.
>>>
>>> However, how can I make it work for multiple pages output?
>>>
>>> On Sat, Dec 14, 2019 at 4:26 AM Aaron Hill 
>>> wrote:
>>>
>>>> On 2019-12-13 5:59 pm, Paolo Pr wrote:
>>>> > First of all, I need to add with Lilypond a   tag to the svg
>>>> > file
>>>> > just before the ending </svg> tag  in the following way:
>>>> >
>>>> > 1)
>>>> > 
>>>> >  <script xlink:href="lilyEasySlurs.js">
>>>> > 
>>>> >
>>>> > OR in the following way:
>>>> >
>>>> > 2)
>>>> > 
>>>> > 
>>>> > <![CDATA[
>>>> > ...javascript code...
>>>> > ]]>
>>>> > 
>>>> > 
>>>>
>>>> Well, one could use (abuse?) the embedded-svg stencil command:
>>>>
>>>> 
>>>> \version "2.19.83"
>>>>
>>>> svg-script = #(define-scheme-function (body) (string?)
>>>>(markup #:stencil (ly:make-stencil (list 'embedded-svg
>>>>  (string-join (list "<![CDATA["
>>>>body "]]>") "\n")) '(0 . 0) '(0 . 0
>>>>
>>>> { g'4 a' \tweak Accidental.output-attributes #'((id . "flat")) bes'2 }
>>>>
>>>> \svg-script
>>>> #"var flat = document.getElementById('flat');
>>>>flat.style.color = 'red';
>>>>function spin(what, amount) {
>>>>  let angle = 0.0;
>>>>  return function () {
>>>>const bbox = what.getBBox();
>>>>const xform = ['rotate(',
>>>>  (angle = (angle + amount) % 360.0),
>>>>  bbox.x + 0.5 * bbox.width,
>>>>  bbox.y + 0.75 * bbox.height, ')'];
>>>>what.setAttribute('transform', xform.join(' '));
>>>>  }
>>>>}
>>>>setInterval(spin(flat, 5), 100);"
>>>> 
>>>>
>>>> This adds a top-level \markup that contains a stencil to instruct
>>>> output-svg.scm to write the specified string to the output.
>>>>
>>>>
>>>> -- Aaron Hill
>>>>
>>>>


Re: A Javascript test code for modifying ties and slurs with mouse

2019-12-14 Thread Stefano Troncaro
Hi Paolo,

Since Aaron's svg-script function creates an empty \markup, you can use the
properties oddFooterMarkup and evenFooterMarkup of the \paper block to have
your script embedded at the end of every page. Look:

%%%
\version "2.19.83"

svg-script = #(define-scheme-function (body) (string?)
   (markup #:stencil (ly:make-stencil (list 'embedded-svg
 (string-join (list "") "\n")) '(0 . 0) '(0 . 0

script-for-every-page = \svg-script
#"var flat = document.getElementById('flat');
   flat.style.color = 'red';
   function spin(what, amount) {
 let angle = 0.0;
 return function () {
   const bbox = what.getBBox();
   const xform = ['rotate(',
 (angle = (angle + amount) % 360.0),
 bbox.x + 0.5 * bbox.width,
 bbox.y + 0.75 * bbox.height, ')'];
   what.setAttribute('transform', xform.join(' '));
 }
   }
   setInterval(spin(flat, 5), 100);"

\paper {
  oddFooterMarkup = \script-for-every-page
  evenFooterMarkup = \script-for-every-page
}

{ g'4 a' \tweak Accidental.output-attributes #'((id . "flat")) bes'2
\pageBreak
  g'4 a' \tweak Accidental.output-attributes #'((id . "flat")) bes'2 }
%%%

Love what your script is doing so far!

Hope that helps,
Stefano

El sáb., 14 dic. 2019 a las 18:39, Paolo Prete ()
escribió:

> Thanks Aaron, it did the trick.
>
> However, how can I make it work for multiple pages output?
>
> On Sat, Dec 14, 2019 at 4:26 AM Aaron Hill 
> wrote:
>
>> On 2019-12-13 5:59 pm, Paolo Pr wrote:
>> > First of all, I need to add with Lilypond a   tag to the svg
>> > file
>> > just before the ending  tag  in the following way:
>> >
>> > 1)
>> > 
>> >