lilypond-user
[Top][All Lists]
Advanced

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

Re: Writing a number in stead of notehead.


From: Thomas Morley
Subject: Re: Writing a number in stead of notehead.
Date: Sat, 2 Apr 2016 15:46:23 +0200

2016-04-02 14:33 GMT+02:00 Simon Albrecht <address@hidden>:
> On 02.04.2016 12:27, Philip Bergwerf wrote:
>>
>> I am searching for a simple way to manually replace the notehead symbol to
>> a
>> digit like a guitar-tab note. Is there a simple command to do that?
>
>
> There are many ways, more or less simple, and as Malte already said, the
> point is we need to know what the number is supposed to stand for. The
> pitch? The fret number? Whatever else?
>
> Best, Simon
>
>

Maybe an educated guess may help:

\version "2.19.36"

nmbrHead =
#(define-music-function (what)(symbol?)
#{
  \override NoteHead.stencil =
    #(lambda (grob)
       (let* ((event (event-cause grob))
              (durlog (ly:duration-log (ly:event-property event 'duration)))
              (durstring (number->string (expt 2 durlog))))
         (grob-interpret-markup grob
           (markup #:fontsize -3 #:vcenter #:with-color red #:bold
           (cond ((eq? what 'duration) durstring)
                 ((eq? what 'staff-position)
                  (number->string (ly:grob-property grob 'staff-position)))
                 ((eq? what 'pitch)
                  (number->string
                    (1+ (ly:pitch-notename (ly:event-property event 'pitch)))))
                 (else (markup #:ellipse "else?")))))))
#})

music =
\relative c' {
  c2. d4 e4 f8 g16 a32 b32 \tuplet 3/2 { c8 d8 e8 } f8.. g32
}

guessBox =
\markup \box { \with-dimensions #'(0 . 1) #'(0 . 1) \null }

iN = \with { instrumentName = \guessBox }

\new Staff \iN { \nmbrHead #'duration <>^"duration" \music }
\new Staff \iN { \nmbrHead #'staff-position <>^"staff-position" \music }
\new Staff \iN { \nmbrHead #'pitch <>^"pitch" \music }
\new Staff \iN { \nmbrHead #'else? <>^"else?" \music }


-Harm



reply via email to

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