Re: Having trouble understanding optional and variable amount of arguments

2018-02-28 Thread David Kastrup
Stefano Troncaro  writes:

> Thank you! I see that this is not an option then. Also, I now understand
> why I couldn't make the optional arguments work, since I always left them
> for last.
>
> Do you know if it is possible to have a flexible amount of optional
> arguments that appear before the last mandatory one? Say, for example
> (define-music-function (arg1 args music) (number? ??? ly:music?) where arg1
> and music are mandatory, and basically everything between arg1 and the next
> music expression is compacted into a list and accessed as args in the body
> of the function. Not with that syntax necessarily, but something that
> allows for that kind of usage?

You know that a number or symbol list can be entered as a
comma-separated list?

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Having trouble understanding optional and variable amount of arguments

2018-02-28 Thread David Kastrup
Stefano Troncaro  writes:

> Thank you! I see that this is not an option then. Also, I now understand
> why I couldn't make the optional arguments work, since I always left them
> for last.

You can use an explicit \default to substitute optional arguments in
final position.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Having trouble understanding optional and variable amount of arguments

2018-02-28 Thread Urs Liska


Am 1. März 2018 03:26:31 MEZ schrieb Stefano Troncaro 
:
>Thank you! I see that this is not an option then. Also, I now
>understand
>why I couldn't make the optional arguments work, since I always left
>them
>for last.
>
>Do you know if it is possible to have a flexible amount of optional
>arguments that appear before the last mandatory one? Say, for example
>(define-music-function (arg1 args music) (number? ??? ly:music?) where
>arg1
>and music are mandatory, and basically everything between arg1 and the
>next
>music expression is compacted into a list and accessed as args in the
>body
>of the function. Not with that syntax necessarily, but something that
>allows for that kind of usage?

I *think* that's not doable in general (I'd love to be proven wrong), but if 
you can have all optional args as symbols you can use a dot-separated symbol 
list.

What I generally use is a \with {} argument which can take arbitrary named 
arguments. In oll-core there are a few helper functions for this, especially 
context-mod->props that turns the value into a regular alist.
I've just started thinking about an enhancement that
- allows to require some arguments
- can set missing args to defaults
- allows type checking

I'd be happy to collaborate on this.

Best
Urs
>
>2018-02-28 20:45 GMT-03:00 Simon Albrecht :
>
>> On 28.02.2018 23:54, Stefano Troncaro wrote:
>>
>>> I need a little help again. I'm struggling to understand how one
>would
>>> make a music function like \tempo, that accepts a variable number of
>>> arguments. I couldn't find its definition so I couldn't look for
>myself.
>>>
>>> So far I know about making lambdas that take additional arguments
>and
>>> store the extras in a list, but this does not work in a music
>function (or
>>> if it works I don't know how to do it). And while I could make a
>lambda
>>> that then passes the arguments to a music function, then I can't use
>it
>>> with Lilypond syntax, so I'm forced to put the lambda and all it's
>>> arguments between parenthesis.
>>>
>>> But \tempo doesn't require parenthesis, and the parser still
>understands
>>> what is part of the function and what not. How would one go about
>writing a
>>> function that behaves like this?
>>>
>>
>> As has been said, \tempo isn’t a music function. However, you _can_
>define
>> functions with optional arguments; it’s mentioned in <
>> http://lilypond.org/doc/v2.19/Documentation/extending/schem
>> e-function-definitions>. The last optional argument has to be
>followed by
>> a mandatory argument of different type, because that’s how the parser
>will
>> recognise that optional arguments were skipped.
>>
>> HTH, Simon
>>

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Having trouble understanding optional and variable amount of arguments

2018-02-28 Thread Stefano Troncaro
Thank you! I see that this is not an option then. Also, I now understand
why I couldn't make the optional arguments work, since I always left them
for last.

Do you know if it is possible to have a flexible amount of optional
arguments that appear before the last mandatory one? Say, for example
(define-music-function (arg1 args music) (number? ??? ly:music?) where arg1
and music are mandatory, and basically everything between arg1 and the next
music expression is compacted into a list and accessed as args in the body
of the function. Not with that syntax necessarily, but something that
allows for that kind of usage?

2018-02-28 20:45 GMT-03:00 Simon Albrecht :

> On 28.02.2018 23:54, Stefano Troncaro wrote:
>
>> I need a little help again. I'm struggling to understand how one would
>> make a music function like \tempo, that accepts a variable number of
>> arguments. I couldn't find its definition so I couldn't look for myself.
>>
>> So far I know about making lambdas that take additional arguments and
>> store the extras in a list, but this does not work in a music function (or
>> if it works I don't know how to do it). And while I could make a lambda
>> that then passes the arguments to a music function, then I can't use it
>> with Lilypond syntax, so I'm forced to put the lambda and all it's
>> arguments between parenthesis.
>>
>> But \tempo doesn't require parenthesis, and the parser still understands
>> what is part of the function and what not. How would one go about writing a
>> function that behaves like this?
>>
>
> As has been said, \tempo isn’t a music function. However, you _can_ define
> functions with optional arguments; it’s mentioned in <
> http://lilypond.org/doc/v2.19/Documentation/extending/schem
> e-function-definitions>. The last optional argument has to be followed by
> a mandatory argument of different type, because that’s how the parser will
> recognise that optional arguments were skipped.
>
> HTH, Simon
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Edition Engraver -- multiple editions

2018-02-28 Thread Craig Dabelstein
Hi all,

I thought I had my head around the edition engraver but I'm going wrong
somewhere. If I want to have different mods for a score, the parts, and a
selection of mods applicable to both the score and the parts, do I need to
create three different editions such as this:

\addEdition score
\addEdition parts
\addEdition scoreandparts

If so, how do I switch between them?

I was trying to use different editionIDs for everything but it's not
working. Can a score have multiple IDs such as:

\layout{
\context {
\Score
\editionID ##f score
\editionID ##f both
}
}

Thanks in advance,

Craig

-- 
*Craig Dabelstein*
Maxime's Music
craig.dabelst...@gmail.com
*http://maximesmusic.com *
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Having trouble understanding optional and variable amount of arguments

2018-02-28 Thread Simon Albrecht

On 28.02.2018 23:54, Stefano Troncaro wrote:
I need a little help again. I'm struggling to understand how one would 
make a music function like \tempo, that accepts a variable number of 
arguments. I couldn't find its definition so I couldn't look for myself.


So far I know about making lambdas that take additional arguments and 
store the extras in a list, but this does not work in a music function 
(or if it works I don't know how to do it). And while I could make a 
lambda that then passes the arguments to a music function, then I 
can't use it with Lilypond syntax, so I'm forced to put the lambda and 
all it's arguments between parenthesis.


But \tempo doesn't require parenthesis, and the parser still 
understands what is part of the function and what not. How would one 
go about writing a function that behaves like this?


As has been said, \tempo isn’t a music function. However, you _can_ 
define functions with optional arguments; it’s mentioned in 
. 
The last optional argument has to be followed by a mandatory argument of 
different type, because that’s how the parser will recognise that 
optional arguments were skipped.


HTH, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Having trouble understanding optional and variable amount of arguments

2018-02-28 Thread Caagr98
I think \tempo (and a few other commands such as \repeat\alternative, \set, and 
\override) are hardcoded in the Lilypond compiler using methods not accessible 
through Scheme, so you can't make that kind of functions yourself. You can make 
functions with optional arguments, though. I think the syntax is something like 
(define-music-function (optional-int-defaults-to-4 music) ((int? 4) ly:music?) 
...).

On 02/28/18 23:54, Stefano Troncaro wrote:
> Hello everyone,
> 
> I need a little help again. I'm struggling to understand how one would make a 
> music function like \tempo, that accepts a variable number of arguments. I 
> couldn't find its definition so I couldn't look for myself.
> 
> So far I know about making lambdas that take additional arguments and store 
> the extras in a list, but this does not work in a music function (or if it 
> works I don't know how to do it). And while I could make a lambda that then 
> passes the arguments to a music function, then I can't use it with Lilypond 
> syntax, so I'm forced to put the lambda and all it's arguments between 
> parenthesis.
> 
> But \tempo doesn't require parenthesis, and the parser still understands what 
> is part of the function and what not. How would one go about writing a 
> function that behaves like this?
> 
> Thank you in advance for your help!
> Stéfano
> 
> 
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
> 

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Having trouble understanding optional and variable amount of arguments

2018-02-28 Thread Stefano Troncaro
Hello everyone,

I need a little help again. I'm struggling to understand how one would make
a music function like \tempo, that accepts a variable number of arguments.
I couldn't find its definition so I couldn't look for myself.

So far I know about making lambdas that take additional arguments and store
the extras in a list, but this does not work in a music function (or if it
works I don't know how to do it). And while I could make a lambda that then
passes the arguments to a music function, then I can't use it with Lilypond
syntax, so I'm forced to put the lambda and all it's arguments between
parenthesis.

But \tempo doesn't require parenthesis, and the parser still understands
what is part of the function and what not. How would one go about writing a
function that behaves like this?

Thank you in advance for your help!
Stéfano
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: transpose to a set of pitches

2018-02-28 Thread Sirius Barras
On 27 February 2018 at 22:24, Thomas Morley 
wrote:

> 2018-02-27 19:12 GMT+01:00 Sirius Barras :
> > I would like to transpose a motif (using \modalTranspose) to a _set_ of
> > different pitches. At the moment this is what I do:
> >
> > scale = {c d e f g a b}
> > motif = {c' e' g' c'}
> > {
> >   \modalTranspose c e \scale \motif
> >   \modalTranspose c g \scale \motif
> >   \modalTranspose c a \scale \motif
> > }
> >
> > How can I do something similar to this:
> >
> > toPitchSet = {e g a}
> > scale = {c d e f g a b}
> > motif = {c' e' g' c'}
> > {
> >   \modalTranspose c \toPitchSet \scale \motif
> > }
> >
> > Many thanks, S.
>
>
> How about:
>
> \version "2.19.65"
>
> %% Based on a function by David K
> multipleModalTransposes =
> #(define-music-function (parser location m scale music)
>   (ly:music? ly:music? ly:music?)
>   ;; If `music' is simple `SequentialMusic', we need to go for 'elements
> instead
>   ;; of 'element. In this case we also need to "unfold" the resulting
>   ;; `possible-elts' one level
>   (let* ((seq-mus? (music-is-of-type? music 'sequential-music))
>  (possible-elts
>(map
>  (lambda (pitch)
>  (ly:music-property
>#{ \modalTranspose c $pitch $scale $music #}
>  (if seq-mus?
> 'elements
> 'element)))
> (event-chord-pitches m
>
> (music-clone m
>   'elements
>   (if seq-mus?
>   (apply append '() possible-elts)
>   possible-elts
>
> toPitchSet = { e g a e b }
> scale = { c d e f g a b }
> motif =
>   %\absolute { c' e' g' c' }
>   %\relative { c' e g c, }
>   %\relative c' { c e g c, }
>   %\fixed c' { c e g c }
>   %\context Voice { c'4 e' g' c' }
>   { c'4 e' g' c' }
>
> \multipleModalTransposes \toPitchSet \scale \motif
>
>
> Cheers,
>   Harm
>

Great! Thanks a lot, s.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: \pralllUp inside Staff

2018-02-28 Thread David Kastrup
Ali Cuota  writes:

> Hi Torsten,
>
> done. Again many thanks, this works perfectly.
>
> BTW: I will publish in imslp, this seems more interesting for
> everybody, than mutopia.

One does not preclude the other, and the focus of Mutopia is on LilyPond
sources.  So if I want to do an arrangement of my own (or even try
squeezing to fewer pages), Mutopia is my first checkpoint.  Also Mutopia
converts older scores to more recent LilyPond versions (at glacial speed
but nevertheless).  Again, this makes for nicer starting points.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user