How can I obtain articulation informations?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How can I obtain articulation informations?

Marc Hohl
Hello all,

after answering Federicos request for the proper handling of ties and
harmonic angle brackets in tablature, I dived into scheme once more
after a long, long break...now I am stuck with a probably simple problem:

I work on the code for
parentheses-item::calc-tabstaff-parenthesis-stencils in scm/tablature.scm:

(define-public (parentheses-item::calc-tabstaff-parenthesis-stencils grob)
  ;; the grob we want to parenthesize
  (let ((victim (ly:grob-array-ref (ly:grob-object grob 'elements) 0)))
    ;;(display (ly:event-property (event-cause victim) 'articulations))
    ;; check whether it's a note head
    (if (grob::has-interface victim 'note-head-interface)
        (begin
          ;; tweak appearance before retrieving
          ;; list of stencils '(left-paren right-paren)
          ;; get the font-size from victim (=TabNoteHead) to handle
          ;; grace notes properly
          (ly:grob-set-property! grob 'font-size
                                 (ly:grob-property victim 'font-size))
          ;; calculate the padding:
          ;; if there are harmonic angle brackets, shift the parentheses
          (let* ((articulation (ly:event-property (event-cause victim)
'articulations)))
                     (display "\n--> ")(display articulation))
                     ;; here I am stuck
          (ly:grob-set-property! grob 'padding 0)
          ;; apply whiteout to each element of the list
          (map stencil-whiteout
               (parentheses-item::calc-parenthesis-stencils grob)))
        (parentheses-item::calc-parenthesis-stencils grob))))


I get the list of articulations from victim and need to find out whether
we have an
'HarmonicEvent: if yes, I choose a padding > 0 , otherwise I leave the
padding = 0.

I grepped through the code and tried various constructs for about an
hour now; can someone give me
a gentle push towards the obvious?

Thanks in advance,

Marc

---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How can I obtain articulation informations?

Neil Puttock
On 30 May 2010 21:06, Marc Hohl <[hidden email]> wrote:

> I grepped through the code and tried various constructs for about an hour
> now; can someone give me
> a gentle push towards the obvious?

I doubt you need to worry about 'articulations here, since harmonics
in tablature are separate from ordinary parentheses (hint:
HarmonicParenthesesItem).

Cheers,
Neil

---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How can I obtain articulation informations?

Marc Hohl
Neil Puttock schrieb:

> On 30 May 2010 21:06, Marc Hohl <[hidden email]> wrote:
>
>  
>> I grepped through the code and tried various constructs for about an hour
>> now; can someone give me
>> a gentle push towards the obvious?
>>    
>
> I doubt you need to worry about 'articulations here, since harmonics
> in tablature are separate from ordinary parentheses (hint:
> HarmonicParenthesesItem).
>  
I am not sure whether I understand your proposals correctly.
I need to enclosure the harmonics within ordinary parentheses after
a line break, i.e. something like "(<7>)". The padding for the ()s
is set to zero in the routine I posted, so the parentheses are drawn over
the <>s.

My idea was to check within the parenthesize-tab-note-head routine
whether the tab note head is harmonic, and adjust the padding accordingly.

Marc


---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How can I obtain articulation informations?

Neil Puttock
On 31 May 2010 08:01, Marc Hohl <[hidden email]> wrote:

> I am not sure whether I understand your proposals correctly.
> I need to enclosure the harmonics within ordinary parentheses after
> a line break, i.e. something like "(<7>)". The padding for the ()s
> is set to zero in the routine I posted, so the parentheses are drawn over
> the <>s.

Ah, sorry, I didn't digest your reply to Federico properly. :)

> My idea was to check within the parenthesize-tab-note-head routine
> whether the tab note head is harmonic, and adjust the padding accordingly.

OK, but surely you need to work with tie::handle-tab-note-head?  IIRC,
the parentheses on the tied notes come via a stencil override, not
from ParenthesesItem.

For the articulations check, try looking at note-finger in
scm/translation-functions.scm.  Something similar to this, using
for-each instead of map, should work.

Cheers,
Neil

---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How can I obtain articulation informations?

Marc Hohl
Neil Puttock schrieb:

> On 31 May 2010 08:01, Marc Hohl <[hidden email]> wrote:
>
>  
>> I am not sure whether I understand your proposals correctly.
>> I need to enclosure the harmonics within ordinary parentheses after
>> a line break, i.e. something like "(<7>)". The padding for the ()s
>> is set to zero in the routine I posted, so the parentheses are drawn over
>> the <>s.
>>    
>
> Ah, sorry, I didn't digest your reply to Federico properly. :)
>
>  
>> My idea was to check within the parenthesize-tab-note-head routine
>> whether the tab note head is harmonic, and adjust the padding accordingly.
>>    
>
> OK, but surely you need to work with tie::handle-tab-note-head?  IIRC,
> the parentheses on the tied notes come via a stencil override, not
> from ParenthesesItem.
>  
Yes, but I have to cover two cases:
a) the harmonic is tied to a note -> make it invisible
b) the tied note occurs after a line break -> draw parentheses
around the angle bracketed tab note head
> For the articulations check, try looking at note-finger in
> scm/translation-functions.scm.  Something similar to this, using
> for-each instead of map, should work.
>  
ok, I will try this - thanks for the hint.

Marc
> Cheers,
> Neil
>
> ---
> ----
> Join the Frogs!
>
>
>  


---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Stencil combination [was: Re: How can I obtain articulation informations?]

Marc Hohl
In reply to this post by Neil Puttock
Neil Puttock schrieb:
> [...]
> OK, but surely you need to work with tie::handle-tab-note-head?  IIRC,
> the parentheses on the tied notes come via a stencil override, not
> from ParenthesesItem.
>  
You are right. I included my "harmonic detector" now in
parenthesize-tab-note-head;
this seems the appropriate place to me, because this function is called
several times
(for ties and repeat ties), so it would be convenient if this function
handles the
harmonics properly.

I have now

(define-public (parenthesize-tab-note-head grob)

  ;; helper function
  (define (is-harmonic grob)
    (let* ((articulations (ly:event-property (event-cause grob)
'articulations))
           (harmonic-found #f))

      (for-each (lambda (art)
                  (if (eq? 'harmonic-event (ly:event-property art 'class))
                      (set! harmonic-found #t)))
                articulations)
      harmonic-found))

  (let* ((font (ly:grob-default-font grob))
         (open (stencil-whiteout
                (ly:font-get-glyph font "accidentals.leftparen")))
         (close (stencil-whiteout
                 (ly:font-get-glyph font "accidentals.rightparen")))
         (me (ly:text-interface::print grob))
         (padding (if (is-harmonic grob) 10 0)))

    (ly:stencil-combine-at-edge
     (ly:stencil-combine-at-edge me X LEFT open padding) X RIGHT close
padding)))

The value of 10 for the padding is ridicously, but so I can spot the
effect at first glance.
Now it seems that the padding itself has a whiteout effect, because the
string lines
are erased and sometimes the harmonic brackets, too (I think the latter
is due to the
internal order in which the grobs are placed) - see the attached pictures.

Why does the whitespace occur? Is there another possibility to combine
the stencils appropriately
so that they "leave space" for the harmonic brackets?


> For the articulations check, try looking at note-finger in
> scm/translation-functions.scm.  Something similar to this, using
> for-each instead of map, should work.
>
>  
Yes, works great - thanks for the tip, I was sure that I saw some
functions handling with
the articulation informations before while digging through the code some
time ago,
but I forgot where.

Marc
> Cheers,
> Neil
>
>  


strange_whiteout1.jpg (7K) Download Attachment
strange_whiteout2.jpg (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stencil combination [was: Re: How can I obtain articulation informations?]

Neil Puttock
On 1 June 2010 16:32, Marc Hohl <[hidden email]> wrote:

> Why does the whitespace occur?

It probably comes from 'whiteout (which is set to #t for TabNoteHead).

Cheers,
Neil

---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stencil combination [was: Re: How can I obtain articulation informations?]

Marc Hohl
Neil Puttock schrieb:
> On 1 June 2010 16:32, Marc Hohl <[hidden email]> wrote:
>
>  
>> Why does the whitespace occur?
>>    
>
> It probably comes from 'whiteout (which is set to #t for TabNoteHead).
>  
Thanks for the explanation.

I am currently working on this, and similarly to your solution with the
parentheses, I redraw the angled brackets within the parenthesizing
subroutine in tablature.scm. It is not completely finished yet, but
some parts work already very well ;-)

Marc
> Cheers,
> Neil
>
> ---
> ----
> Join the Frogs!
>
>
>  


---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Manipulating HarmonicParenthesesItem stuff within tie callback [was Re: [frogs] How can I obtain articulation informations?]

Marc Hohl
In reply to this post by Neil Puttock
Neil Puttock schrieb:
> [...]
> OK, but surely you need to work with tie::handle-tab-note-head?  IIRC,
> the parentheses on the tied notes come via a stencil override, not
> from ParenthesesItem.
>  
Can I manipulate HarmonicParenthesesItem #'stencil or ~ #'transparent
within the callback tie::handle-tab-note-head (to be found in
scm/tablature.scm)?

I can obtain the TabNoteHead via ly:spanner-bound, and I can check
whether the TabNoteHead includes a harmonic-event.
Now, similarly to the code for making the TabNoteHead invisible,
I have to do something like

\once \override HarmonicParenthesesItem #'transparent = ##t

within the callback. This means I need to code

(ly:grob-set-property! harmonic-brackets 'transparent #t)

where harmonic-brackets ist the grob I am aiming for.
Am I on the right track here? I have already covered the case where
a fret number is parenthesized *and* a harmonic, i.e. (<7>),
but the "simple" case where an "empty" tab note head has
surrounding harmonic brackets < > that have to be removed is
still open...

Thanks in advance,

Marc



---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating HarmonicParenthesesItem stuff within tie callback [was Re: [frogs] How can I obtain articulation informations?]

Neil Puttock
On 11 June 2010 10:36, Marc Hohl <[hidden email]> wrote:

> Can I manipulate HarmonicParenthesesItem #'stencil or ~ #'transparent
> within the callback tie::handle-tab-note-head (to be found in
> scm/tablature.scm)?

Why not use a callback for HarmonicParenthesesItem itself?  Its
Y-parent is the TabNoteHead, so a callback which sets 'transparent by
reading the parent grob's 'transparent property should work.

Cheers,
Neil

---
----
Join the Frogs!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating HarmonicParenthesesItem stuff within tie callback [was Re: [frogs] How can I obtain articulation informations?]

Marc Hohl
Neil Puttock schrieb:

> On 11 June 2010 10:36, Marc Hohl <[hidden email]> wrote:
>
>  
>> Can I manipulate HarmonicParenthesesItem #'stencil or ~ #'transparent
>> within the callback tie::handle-tab-note-head (to be found in
>> scm/tablature.scm)?
>>    
>
> Why not use a callback for HarmonicParenthesesItem itself?  Its
> Y-parent is the TabNoteHead, so a callback which sets 'transparent by
> reading the parent grob's 'transparent property should work.
>  
Sounds good - I'll give it a try.

Thank you!

Marc
> Cheers,
> Neil
>
> ---
> ----
> Join the Frogs!
>
>
>  


---
----
Join the Frogs!

Loading...