[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing a function

From: Aaron Hill
Subject: Re: Writing a function
Date: Sun, 12 May 2019 07:26:08 -0700
User-agent: Roundcube Webmail/1.3.8

On 2019-05-12 3:40 am, David Kastrup wrote:
Rok Kršmanc <address@hidden> writes:


I would like to write a function for the next music expression:
\once \override TextScript.extra-offset = #'(0 . 1)

Here is my try:
f =
#(define-music-function (parser location offset music)
  (number? ly:music?)
    \once \override TextScript.extra-offset = #'(0 . $offset)
    $music ^"o"

When I call this function:
\f #1 c

I get syntax error:
unexpected '^'

What am I doing wrong?

First it seems like a bad idea to redefine \f ("forte").  But the main
problem is that an expression like $music cannot take articulations
(this has been ameliorated to some degree in current development, likely
appearing as 2.21 eventually).

You can achieve about the same effect with << $music <>-"o" >> namely
putting the articulation instead on a simultaneously executing empty

Would an event function possibly make more sense?  Consider:

\version "2.19.82"

foo = #(define-event-function (offset) (number?)
  #{ \tweak extra-offset #(cons 0 offset)
     ^"foo" #})

{ b'4 \foo #0.5 b' b' \foo #-1 }

-- Aaron Hill

reply via email to

[Prev in Thread] Current Thread [Next in Thread]