lilypond-user
[Top][All Lists]
Advanced

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

Re: Get string number from TabStaff note


From: Thomas Morley
Subject: Re: Get string number from TabStaff note
Date: Fri, 23 Jan 2015 23:53:25 +0100

2015-01-23 23:03 GMT+01:00 Thomas Morley <address@hidden>:
> 2015-01-21 15:54 GMT+01:00 address@hidden <address@hidden>:
>> Is it possible to know which string a note is placed on in a TabStaff.
>>
>> E.g.
>>
>> %% Start
>> \version "2.19.15"
>>
>> melody = { c'4 }
>>
>> \score {
>>   <<
>>     \new Staff { \melody }
>>     \new TabStaff { \melody }
>>   >>
>> }
>> %% End
>>
>> Here the note c'4 is placed on the second string of the TabStaff.
>> Since I want to do different things (\transpose) depending on which string
>> the note is on, I need to know the string number and I need to know it
>> before it is "printed" on the TabStaff ( I want to transpose the note
>> differently depending on which string it is on)
>>
>>
>> Is this possible?
>
>
> Hi,
>
> is the following of some help?
>
> \version "2.18.0"
>
> \new TabStaff
> \relative c, {
>   \override TabNoteHead.before-line-breaking =
>   #(lambda (grob)
>     (format #t "\nI'm on string No. ~a"
>       (truncate (abs (- (/ (ly:grob-property grob 'staff-position) 2) 4)))))
>   e f g
>   a b c
>   d e f
>   g\4 a
>   b c d
>   e f g
> }
>
>
>
> HTH,
>   Harm

Or maybe something at the lines of

\version "2.18.0"

boo =
#(define-music-function (parser location mus)(ly:music?)
(music-map
  (lambda (m)
   (let ((strgnr '()))
    (if (music-is-of-type? m 'note-event)
        (begin
          (for-each
            (lambda (e)
             (if (music-is-of-type? e 'string-number-event)
                 (begin
                   ;(display (ly:music-property e 'string-number))
                   (set! strgnr (ly:music-property e 'string-number))
                   e)
                 e))
          (ly:music-property m 'articulations))
          (begin
            ;(display strgnr)
            (if (= strgnr 6)
                #{ \transpose c cis, $m #}
                m)
                 ))
        m)))
   mus))

m =
\relative c, {
  e f g
  \boo
  a\6 b c
  d e f
  g\4 a
  b c d
  e f g
}

<<
 \new Staff { \clef "G_8" \m }
 \new TabStaff \m
>>

Cheers,
  Harm



reply via email to

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