Re: printing the current moment in a context

2017-09-11 Thread Kieren MacMillan
Hi Jan-Peter,

> did you receive this message?

Yes, I received that. Sorry for not responding sooner.

> Did you have a chance to test the code?

Unfortunately not yet.
I will as soon as I can — early next week at the latest.

Thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


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


Re: printing the current moment in a context

2017-09-11 Thread Jan-Peter Voigt

Hi Kieren,

did you receive this message? Did you have a chance to test the code?

Best
Jan-Peter


Am 23.08.2017 um 10:58 schrieb Jan-Peter Voigt:

Hi Kieren,

I merged a few things into master. Now upbeats and instant voices should 
work as expected. At least in my tiny examples they do.


I'd like you to test two things:

1. test, if the master branch doesn't fail with your scores. I tested 
the code and only merged stuff that passed my checking view. But 
sometimes tiny fixes cause problems the developer never expected ...


2. check the branch 'music-event-broadcast'. I use that branch for my 
own scores without a problem. Most mods are broadcast as events and so 
some more tweaks are available for editionMod.


If those tests run correct, I will merge music-event-broadcast into 
master. That will ease further development.


Jan-Peter



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


Re: printing the current moment in a context

2017-08-23 Thread Jan-Peter Voigt

Hi Kieren,

I merged a few things into master. Now upbeats and instant voices should 
work as expected. At least in my tiny examples they do.


I'd like you to test two things:

1. test, if the master branch doesn't fail with your scores. I tested 
the code and only merged stuff that passed my checking view. But 
sometimes tiny fixes cause problems the developer never expected ...


2. check the branch 'music-event-broadcast'. I use that branch for my 
own scores without a problem. Most mods are broadcast as events and so 
some more tweaks are available for editionMod.


If those tests run correct, I will merge music-event-broadcast into 
master. That will ease further development.


Jan-Peter


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


Re: printing the current moment in a context

2017-08-22 Thread Jan-Peter Voigt

thanks!
That does it


Am 22.08.2017 um 11:54 schrieb David Kastrup:

Jan-Peter Voigt  writes:


... OK, now I found it!

It is a matter of order: If the edition-engraver is consisted before
the Timing the timing-information is not updated and so the last
reported timestep is used in the start-translation-timestep slot of
the engraver. A lot of the mods are applied in that stage of
translation.

So if you move the timing engravers *before* consisting the EE, the
mods are applied at the right timestep.

I don't know, if it is possible to change the order of
engravers/translators after they have been consisted. But I hope this
info helps for now.


Sounds like it would make sense to set "must-be-last" to #t in your
engraver definition.




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


Re: printing the current moment in a context

2017-08-22 Thread David Kastrup
Jan-Peter Voigt  writes:

> ... OK, now I found it!
>
> It is a matter of order: If the edition-engraver is consisted before
> the Timing the timing-information is not updated and so the last
> reported timestep is used in the start-translation-timestep slot of
> the engraver. A lot of the mods are applied in that stage of
> translation.
>
> So if you move the timing engravers *before* consisting the EE, the
> mods are applied at the right timestep.
>
> I don't know, if it is possible to change the order of
> engravers/translators after they have been consisted. But I hope this
> info helps for now.

Sounds like it would make sense to set "must-be-last" to #t in your
engraver definition.

-- 
David Kastrup

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


Re: printing the current moment in a context

2017-08-22 Thread Jan-Peter Voigt

... OK, now I found it!

It is a matter of order: If the edition-engraver is consisted before the 
Timing the timing-information is not updated and so the last reported 
timestep is used in the start-translation-timestep slot of the engraver. 
A lot of the mods are applied in that stage of translation.


So if you move the timing engravers *before* consisting the EE, the mods 
are applied at the right timestep.


I don't know, if it is possible to change the order of 
engravers/translators after they have been consisted. But I hope this 
info helps for now.


Jan-Peter



Am 22.08.2017 um 11:06 schrieb Jan-Peter Voigt:

Hi Kieren,

the issue is not fixed (yet), but I found a hint. The EE uses the 
context-properties currentBarNumber and measurePosition to collect 
current mods from the tree. Somehow these values are laid back inside 
the EE code so they report the preceding moment when the Timing is moved 
away from the Score context.

I have to build a MWE to expose the bug and to solve it.

Jan-Peter



Am 16.08.2017 um 15:55 schrieb Kieren MacMillan:

Hi David,


I'll try it in my "real-world" score and report back.


Here is a screenshot of a portion of my current engraving:


As you can see, the second staff is [correctly] displaying 36@0, and 
the third staff is [correctly] displaying 35@1/4.


*HOWEVER*: the edition-engraver tweak required to color the notes in 
the PianoStaff had to be set at 35@1/8 [!!] in order to correctly 
start at the moment which is obviously 35@1/4. I feel certain this is 
a flaw in the edition-engraver, and not with your 
Current_moment_engraver code — I'm hoping your Current_moment_engraver 
code [found two messages earlier in this thread] might help Jan-Peter 
fix the edition-engraver (ASAP!) so that it correctly targets moments 
in polymetric scores.


Many thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info 
‣ email: i...@kierenmacmillan.info 




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


\version "2.19.65"
\include "oll-core/package.ily"
\loadPackage edition-engraver



#(define (moment->string mom)
   (if (zero? (ly:moment-grace mom))
   (number->string (ly:moment-main mom))
   (format "~sG~a" (ly:moment-main mom) (ly:moment-grace mom

Current_moment_engraver =
#(make-engraver
  (acknowledgers
   ((text-script-interface self grob origin)
(let ((ctx (ly:translator-context self)))
  (if (equal? (ly:grob-property grob 'text) "@")
  (set! (ly:grob-property grob 'text)
#{ \markup \with-color #red
   #(format "~a@~a" (ly:context-property ctx 'currentBarNumber)
  (moment->string (ly:context-property ctx 'measurePosition))) #}))

#(ly:register-translator
  Current_moment_engraver 'Current_moment_engraver
  '((description . "\
This engraver replaces text scripts with a text of @code{@@} with
a red currentBarNumber@measurePosition indicator.")))

% first move the Timing_translator
\layout {
  \context {
\Score
\remove "Timing_translator"
\remove "Default_bar_line_engraver"
  }
  \context {
\Staff
\consists "Timing_translator"
\consists "Default_bar_line_engraver"
  }
}
% consist the edition engraver after/behind the timing_translator
\consistToContexts #edition-engraver Staff

\addEdition test
\editionMod test 1 1/16 Staff \once \override NoteHead.color = #red

\new Staff \with { \consists "Current_moment_engraver" }
\relative c' { c16 d-"@" f g a c d e }
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: printing the current moment in a context

2017-08-22 Thread Jan-Peter Voigt

Hi Kieren,

the issue is not fixed (yet), but I found a hint. The EE uses the 
context-properties currentBarNumber and measurePosition to collect 
current mods from the tree. Somehow these values are laid back inside 
the EE code so they report the preceding moment when the Timing is moved 
away from the Score context.

I have to build a MWE to expose the bug and to solve it.

Jan-Peter



Am 16.08.2017 um 15:55 schrieb Kieren MacMillan:

Hi David,


I'll try it in my "real-world" score and report back.


Here is a screenshot of a portion of my current engraving:


As you can see, the second staff is [correctly] displaying 36@0, and the 
third staff is [correctly] displaying 35@1/4.


*HOWEVER*: the edition-engraver tweak required to color the notes in the 
PianoStaff had to be set at 35@1/8 [!!] in order to correctly start at 
the moment which is obviously 35@1/4. I feel certain this is a flaw in 
the edition-engraver, and not with your Current_moment_engraver code — 
I'm hoping your Current_moment_engraver code [found two messages earlier 
in this thread] might help Jan-Peter fix the edition-engraver (ASAP!) so 
that it correctly targets moments in polymetric scores.


Many thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info 
‣ email: i...@kierenmacmillan.info 




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


Re: printing the current moment in a context

2017-08-18 Thread Kieren MacMillan
Hi all,

> In the case of cadenze, it would make more sense to use
> absolute time for additional _offsets_ to a bar/measurepos pair.

+1

Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


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


Re: printing the current moment in a context

2017-08-18 Thread Kieren MacMillan
Hi Jan-Peter,

Here are the features I think would be essential in the optimal 
edition-engraver:

1. offset from a mark or moment 0;
2. relative (the default?) and absolute offset;
3. targetting of a context id (requires an offset for tweaking);
4. targetting of a [unique] grob id (does not require an offset for tweaking).

I can draw up pseudo-code use cases, and would be happy to discuss this on- or 
off- list, If it would help you with development.

In related news: if even a good solid beta of the new edition-engraver is ready 
soon (e.g., a few weeks? a month, or two max?), I am giving several 
lectures/presentations this academic year, and would love for the EE to be 
highlighted in those presentations.

Cheers,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


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


Re: printing the current moment in a context

2017-08-18 Thread Jan-Peter Voigt
Hi David,

you are right. This is an idea I also thought about. I will  see how to add 
that.
A while ago Kieren and I discussed using a mark event together with an offset 
for use in polymetric scores.

Jan-Peter 

Am 18. August 2017 09:13:21 MESZ schrieb David Kastrup :
>Jan-Peter Voigt  writes:
>
>> Hi Kieren,
>>
>> it is not implemented yet, allthough I carry this idea for a while.
>It
>> is no problem to use ly:context-now, but it adds another
>schema/branch
>> to the tree. That shouldn't be a big deal, but still it has to be
>> implemented carefully.
>
>Personally I think this would be very unwieldy on its own (though a
>good
>fallback/workaround when polyrhythmic situations are not properly
>resolved).  In the case of cadenze, it would make more sense to use
>absolute time for additional _offsets_ to a bar/measurepos pair.
>
>-- 
>David Kastrup

-- 
Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: printing the current moment in a context

2017-08-18 Thread David Kastrup
Jan-Peter Voigt  writes:

> Hi Kieren,
>
> it is not implemented yet, allthough I carry this idea for a while. It
> is no problem to use ly:context-now, but it adds another schema/branch
> to the tree. That shouldn't be a big deal, but still it has to be
> implemented carefully.

Personally I think this would be very unwieldy on its own (though a good
fallback/workaround when polyrhythmic situations are not properly
resolved).  In the case of cadenze, it would make more sense to use
absolute time for additional _offsets_ to a bar/measurepos pair.

-- 
David Kastrup

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


Re: printing the current moment in a context

2017-08-18 Thread Jan-Peter Voigt
Hi Kieren,

it is not implemented yet, allthough I carry this idea for a while. It is no 
problem to use ly:context-now, but it adds another schema/branch to the tree. 
That shouldn't be a big deal, but still it has to be implemented carefully.

Jan-Peter 

Am 17. August 2017 23:47:56 MESZ schrieb Kieren MacMillan 
:
>Hi Jan-Peter,
>
>>> May I ask, after \cadenzaOn there is no moment anymore?
>> 
>> It doesn't advance.  That's pretty much the point of a cadenza.
>> 
>>> Is there some other internal counter for this?
>> 
>> Absolute time as via ly:context-now or grob::when .  This is global
>and
>> unfazed by all timing and context changes
>
>Is there a way to use this 'absolute time' in the edition-engraver?
>
>Thanks,
>Kieren.
>
>
>Kieren MacMillan, composer
>‣ website: www.kierenmacmillan.info
>‣ email: i...@kierenmacmillan.info

-- 
Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: printing the current moment in a context

2017-08-17 Thread Kieren MacMillan
Hi Jan-Peter,

>> May I ask, after \cadenzaOn there is no moment anymore?
> 
> It doesn't advance.  That's pretty much the point of a cadenza.
> 
>> Is there some other internal counter for this?
> 
> Absolute time as via ly:context-now or grob::when .  This is global and
> unfazed by all timing and context changes

Is there a way to use this 'absolute time' in the edition-engraver?

Thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


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


Re: printing the current moment in a context

2017-08-16 Thread David Kastrup
Francisco Vila  writes:

> On 16/08/17 14:53, David Kastrup wrote:
>> Kieren MacMillan  writes:
>>
>>> Hi David,
>>>
 Something like
>>> This is great!
>>>
>>> …except in the *exact* circumstance I actually need it for:
>
> {
>  c d-"@" f g
> c d-"@" f g
> \cadenzaOn
> c d-"@" f g
> c d-"@" f g
> }
>
> May I ask, after \cadenzaOn there is no moment anymore?

It doesn't advance.  That's pretty much the point of a cadenza.

> Is there some other internal counter for this?

Absolute time as via ly:context-now or grob::when .  This is global and
unfazed by all timing and context changes (eat your heart out,
Einstein).

-- 
David Kastrup

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


Re: printing the current moment in a context

2017-08-16 Thread Francisco Vila
On 16/08/17 14:53, David Kastrup wrote:
> Kieren MacMillan  writes:
>
>> Hi David,
>>
>>> Something like
>> This is great!
>>
>> …except in the *exact* circumstance I actually need it for:

{
 c d-"@" f g
c d-"@" f g
\cadenzaOn
c d-"@" f g
c d-"@" f g
}

May I ask, after \cadenzaOn there is no moment anymore? Is there some
other internal counter for this?


-- 
Francisco Vila. Badajoz (Spain)
paconet.org , csmbadajoz.com


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


Re: printing the current moment in a context

2017-08-16 Thread David Kastrup
Kieren MacMillan  writes:

> Hi David,
>
>> Perhaps it would have been worthwhile creating a minimal example
>> demonstrating the exact circumstance you actually need it for...
>
> Your revised code — brilliant, as always! —

I was rather angling for "illuminating".  "brilliant" means one gets
saddled with the work.

And

> #(ly:register-translator
>  Current_moment_engraver 'Current_moment_engraver
>  '((description . "\
> This engraver replaces text scripts with a text of @code{@@} with
> a red currentBarNumber@measurePosition indicator.")))

would barf because of the last @ if it ever were to be typeset in
documentation.  Needs to be @@ to make it through Texinfo.

-- 
David Kastrup

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


Re: printing the current moment in a context

2017-08-16 Thread Kieren MacMillan
Hi David,

> I'll try it in my "real-world" score and report back.

Here is a screenshot of a portion of my current engraving:



As you can see, the second staff is [correctly] displaying 36@0, and the third 
staff is [correctly] displaying 35@1/4.

*HOWEVER*: the edition-engraver tweak required to color the notes in the 
PianoStaff had to be set at 35@1/8 [!!] in order to correctly start at the 
moment which is obviously 35@1/4. I feel certain this is a flaw in the 
edition-engraver, and not with your Current_moment_engraver code — I'm hoping 
your Current_moment_engraver code [found two messages earlier in this thread] 
might help Jan-Peter fix the edition-engraver (ASAP!) so that it correctly 
targets moments in polymetric scores.

Many thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info 
‣ email: i...@kierenmacmillan.info 

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


Re: printing the current moment in a context

2017-08-16 Thread Kieren MacMillan
Hi David,

> Perhaps it would have been worthwhile creating a minimal example
> demonstrating the exact circumstance you actually need it for...

Your revised code — brilliant, as always! — appears to work perfectly on the 
attached MWE of the exact circumstance I need.
I'll try it in my "real-world" score and report back.

Thanks!
Kieren.

%%%  SNIPPET BEGINS
\version "2.19.64"

#(define (moment->string mom)
 (if (zero? (ly:moment-grace mom))
  (number->string (ly:moment-main mom))
  (format "~sG~a" (ly:moment-main mom) (ly:moment-grace mom

Current_moment_engraver =
#(make-engraver
 (acknowledgers
  ((text-script-interface self grob origin)
   (let ((ctx (ly:translator-context self)))
 (if (equal? (ly:grob-property grob 'text) "@")
  (set! (ly:grob-property grob 'text)
#{ \markup \with-color #red
   #(format "~a@~a" (ly:context-property ctx 'currentBarNumber)
(moment->string (ly:context-property ctx 
'measurePosition))) #}))

#(ly:register-translator
 Current_moment_engraver 'Current_moment_engraver
 '((description . "\
This engraver replaces text scripts with a text of @code{@@} with
a red currentBarNumber@measurePosition indicator.")))

\layout {
  \context {
\Score
\remove "Timing_translator"
\remove "Default_bar_line_engraver"
  }
  \context {
\Staff
\consists "Timing_translator"
\consists "Default_bar_line_engraver"
\consists "Current_moment_engraver"
  }
}

<<
  \new Staff { c d-"@" f g }
  \new Staff { \time 3/4 c4 d f g2.-"@" }
>>
%%%  SNIPPET ENDS



Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


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


Re: printing the current moment in a context

2017-08-16 Thread David Kastrup
Kieren MacMillan  writes:

> Hi David,
>
>> Something like
>
> This is great!
>
> …except in the *exact* circumstance I actually need it for:

Perhaps it would have been worthwhile creating a minimal example
demonstrating the exact circumstance you actually need it for...

-- 
David Kastrup

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


Re: printing the current moment in a context

2017-08-16 Thread David Kastrup
Kieren MacMillan  writes:

> Hi David,
>
>> Something like
>
> This is great!
>
> …except in the *exact* circumstance I actually need it for:
>
>   SNIPPET BEGINS
> \version "2.19.64"
>
> #(define (moment->string mom)
>  (if (zero? (ly:moment-grace mom))
>   (number->string (ly:moment-main mom))
>   (format "~sG~a" (ly:moment-main mom) (ly:moment-grace mom
>
> currentmom =
> -\tweak text
> #(lambda (grob)
>   (let* ((loc (grob::rhythmic-location grob)))
> (if (pair? loc)
>#{ \markup \with-color #red #(format "~a@~a" (car loc)
> (moment->string (cdr loc))) #}
> "")))
> -""
>
> \layout {
>   \context {
> \Score
> \remove "Timing_translator"
> \remove "Default_bar_line_engraver"
>   }
>   \context {
> \Staff
> \consists "Timing_translator"
> \consists "Default_bar_line_engraver"
>   }
> }
>
> { c d\currentmom f g }
>   SNIPPET ENDS
>
> Any way to get the moment of the current context when Timing has been moved 
> from Score?

That's more tricky since "rhythmic-location" is recorded in
PaperColumn/NonMusicalPaperColumn items that only exist per-Score.  You
could try moving Paper_column_engraver along with the other engravers
you move but I would be surprised if this does not cause a lot of havoc.

So maybe do this entirely differently?

\version "2.19.65"

#(define (moment->string mom)
  (if (zero? (ly:moment-grace mom))
   (number->string (ly:moment-main mom))
   (format "~sG~a" (ly:moment-main mom) (ly:moment-grace mom

Current_moment_engraver =
#(make-engraver
  (acknowledgers
   ((text-script-interface self grob origin)
(let ((ctx (ly:translator-context self)))
  (if (equal? (ly:grob-property grob 'text) "@")
	  (set! (ly:grob-property grob 'text)
		#{ \markup \with-color #red
		   #(format "~a@~a" (ly:context-property ctx 'currentBarNumber)
			(moment->string (ly:context-property ctx 'measurePosition))) #}))

#(ly:register-translator
  Current_moment_engraver 'Current_moment_engraver
  '((description . "\
This engraver replaces text scripts with a text of @code{@@} with
a red currentBarNumber@measurePosition indicator.")))

\new Staff \with { \consists "Current_moment_engraver" }
{ c d-"@" f g }

Of course, here is to you not actually ever wanting to output just "@".
You'd consist this engraver where it can be expected to see useful
values of currentBarNumber/measurePosition, so likely in the same
contexts where you move your Timing_translator.

No idea whether this will behave sensibly in the context of timing
changes such as \partial .

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


Re: printing the current moment in a context

2017-08-16 Thread Kieren MacMillan
Hi David,

> Something like

This is great!

…except in the *exact* circumstance I actually need it for:

  SNIPPET BEGINS
\version "2.19.64"

#(define (moment->string mom)
 (if (zero? (ly:moment-grace mom))
  (number->string (ly:moment-main mom))
  (format "~sG~a" (ly:moment-main mom) (ly:moment-grace mom

currentmom =
-\tweak text
#(lambda (grob)
  (let* ((loc (grob::rhythmic-location grob)))
(if (pair? loc)
 #{ \markup \with-color #red #(format "~a@~a" (car loc)
  (moment->string (cdr loc))) #}
"")))
-""

\layout {
  \context {
\Score
\remove "Timing_translator"
\remove "Default_bar_line_engraver"
  }
  \context {
\Staff
\consists "Timing_translator"
\consists "Default_bar_line_engraver"
  }
}

{ c d\currentmom f g }
  SNIPPET ENDS

Any way to get the moment of the current context when Timing has been moved 
from Score?

Thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


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


Re: printing the current moment in a context

2017-08-16 Thread David Kastrup
Kieren MacMillan  writes:

> Hi all,
>
> Is there a function (2.19.64) that will output the current context
> moment (e.g., measure number and beat) as markup?
> In my polymetric scores, I need to target moments (using the
> edition-engraver), and it currently involves a bit too much
> trial-and-error…

Something like

#(define (moment->string mom)
  (if (zero? (ly:moment-grace mom))
   (number->string (ly:moment-main mom))
   (format "~sG~a" (ly:moment-main mom) (ly:moment-grace mom

currentmom =
-\tweak text
#(lambda (grob)
   (let* ((loc (grob::rhythmic-location grob)))
 (if (pair? loc)
	 #{ \markup \with-color #red #(format "~a@~a" (car loc)
	  (moment->string (cdr loc))) #}
 "")))
-""

{ c d\currentmom f g }

I would have used rhythmic-location->string but it relies on
ly:moment->string that never ever was defined over the history of
LilyPond.  Cough cough.

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