slides

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

slides

Federico Bruni
Marc Hohl wrote:
 >
 > Generally, such changes are not too difficult to manage, but *we*
as the
 > tablature users should find
 > a consensus, so if there are more proposals, wishes etc., please
let me
 > know.
 >

I have some questions regarding slides.

I think tablature users need different kinds of slides:

* legato slide: just the first note is picked (by fingers or
flatpick), the notes after the first one are not picked again.
In this case, besides the line which ties the numbers together, there
should be an arch (a slur) showing that is a legato slide [this is
what I've always seen in most books and tab editors].

It's probably the most used kind of slide..
And, afaik, there's not a command in LilyPond to achieve that. Please
tell me if I'm wrong.


* slide: not only the first note, but also the notes after are picked.
In this case, a line is sufficient.
This feature is already supported and it's enabled by \glissando


* slide up/ slide down: that is, when you slide from and indefinite
point to a precise note, so basically the first number is missing. It
can't be legato (because there's just one note).

I don't know if I can already get this with \glissando. I never
managed to get it working.
If I write \glissando "the note to slide to", it will connect the note
before with this note.
Do you know any workaround?


Any comments and suggestions are appreciated.


Federico




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

Re: slides

Marc Hohl
Federico Bruni schrieb:

> Marc Hohl wrote:
> >
> > Generally, such changes are not too difficult to manage, but *we* as
> the
> > tablature users should find
> > a consensus, so if there are more proposals, wishes etc., please let me
> > know.
> >
>
> I have some questions regarding slides.
>
> I think tablature users need different kinds of slides:
>
> * legato slide: just the first note is picked (by fingers or
> flatpick), the notes after the first one are not picked again.
> In this case, besides the line which ties the numbers together, there
> should be an arch (a slur) showing that is a legato slide [this is
> what I've always seen in most books and tab editors].
I think you can get this by combining a slur with a glissando line:

c ( \glissando d )

>
> It's probably the most used kind of slide..
> And, afaik, there's not a command in LilyPond to achieve that. Please
> tell me if I'm wrong.
>
>
> * slide: not only the first note, but also the notes after are picked.
> In this case, a line is sufficient.
> This feature is already supported and it's enabled by \glissando
>
>
> * slide up/ slide down: that is, when you slide from and indefinite
> point to a precise note, so basically the first number is missing. It
> can't be legato (because there's just one note).
>
> I don't know if I can already get this with \glissando. I never
> managed to get it working.
> If I write \glissando "the note to slide to", it will connect the note
> before with this note.
> Do you know any workaround?
>
I found the following workaround in the archives:

http://lists.gnu.org/archive/html/lilypond-user/2009-03/msg00190.html

It is not very pretty, but it works, for the moment...

Marc

>
> Any comments and suggestions are appreciated.
>
>
> Federico
>
>
>
>
>



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

Re: slides

Federico Bruni
Marc Hohl wrote:

> Federico Bruni schrieb:
>> Marc Hohl wrote:
>> >
>> > Generally, such changes are not too difficult to manage, but *we* as
>> the
>> > tablature users should find
>> > a consensus, so if there are more proposals, wishes etc., please let me
>> > know.
>> >
>>
>> I have some questions regarding slides.
>>
>> I think tablature users need different kinds of slides:
>>
>> * legato slide: just the first note is picked (by fingers or
>> flatpick), the notes after the first one are not picked again.
>> In this case, besides the line which ties the numbers together, there
>> should be an arch (a slur) showing that is a legato slide [this is
>> what I've always seen in most books and tab editors].
> I think you can get this by combining a slur with a glissando line:
>
> c ( \glissando d )


yes, it works as expected

>>
>>
>> * slide up/ slide down: that is, when you slide from and indefinite
>> point to a precise note, so basically the first number is missing. It
>> can't be legato (because there's just one note).
>>
>> I don't know if I can already get this with \glissando. I never
>> managed to get it working.
>> If I write \glissando "the note to slide to", it will connect the note
>> before with this note.
>> Do you know any workaround?
>>
> I found the following workaround in the archives:
>
> http://lists.gnu.org/archive/html/lilypond-user/2009-03/msg00190.html
>
> It is not very pretty, but it works, for the moment...
>

I've tried this:
\grace{ \hideNotes a8\glissando s s \unHideNotes}  b4\3  d  e2

but it works just on the staff, the TabStaff displays the first note (a8)

how can I hide the note in TabStaff as well?


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

Re: slides

Marc Hohl
Federico Bruni schrieb:

> Marc Hohl wrote:
>> Federico Bruni schrieb:
>>> Marc Hohl wrote:
>>> >
>>> > Generally, such changes are not too difficult to manage, but *we*
>>> as the
>>> > tablature users should find
>>> > a consensus, so if there are more proposals, wishes etc., please
>>> let me
>>> > know.
>>> >
>>>
>>> I have some questions regarding slides.
>>>
>>> I think tablature users need different kinds of slides:
>>>
>>> * legato slide: just the first note is picked (by fingers or
>>> flatpick), the notes after the first one are not picked again.
>>> In this case, besides the line which ties the numbers together,
>>> there should be an arch (a slur) showing that is a legato slide
>>> [this is what I've always seen in most books and tab editors].
>> I think you can get this by combining a slur with a glissando line:
>>
>> c ( \glissando d )
>
>
> yes, it works as expected
>
>>>
>>>
>>> * slide up/ slide down: that is, when you slide from and indefinite
>>> point to a precise note, so basically the first number is missing.
>>> It can't be legato (because there's just one note).
>>>
>>> I don't know if I can already get this with \glissando. I never
>>> managed to get it working.
>>> If I write \glissando "the note to slide to", it will connect the
>>> note before with this note.
>>> Do you know any workaround?
>>>
>> I found the following workaround in the archives:
>>
>> http://lists.gnu.org/archive/html/lilypond-user/2009-03/msg00190.html
>>
>> It is not very pretty, but it works, for the moment...
>>
>
> I've tried this:
> \grace{ \hideNotes a8\glissando s s \unHideNotes}  b4\3  d  e2
>
> but it works just on the staff, the TabStaff displays the first note (a8)
>
> how can I hide the note in TabStaff as well?
Ah, yes, of course.

You can define

\hideFretNumber = \override TabNoteHead #'transparent = ##t
\unHideFretNumber = \revert TabNoteHead #'transparent

and put it in (I don't have tested the code, please let me know if it
doesn't work)

Marc
>
>
>



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

Re: slides

Carl Sorensen



On 8/29/09 3:39 PM, "Marc Hohl" <[hidden email]> wrote:

> Federico Bruni schrieb:
>> Marc Hohl wrote:
>>> Federico Bruni schrieb:
>>>> Marc Hohl wrote:
>>>>>
>>>>> Generally, such changes are not too difficult to manage, but *we*
>>>> as the
>>>>> tablature users should find
>>>>> a consensus, so if there are more proposals, wishes etc., please
>>>> let me
>>>>> know.
>>>>>
>>>>
>>>> I have some questions regarding slides.
>>>>
>>>> I think tablature users need different kinds of slides:
>>>>
>>>> * legato slide: just the first note is picked (by fingers or
>>>> flatpick), the notes after the first one are not picked again.
>>>> In this case, besides the line which ties the numbers together,
>>>> there should be an arch (a slur) showing that is a legato slide
>>>> [this is what I've always seen in most books and tab editors].
>>> I think you can get this by combining a slur with a glissando line:
>>>
>>> c ( \glissando d )
>>
>>
>> yes, it works as expected
>>
>>>>
>>>>
>>>> * slide up/ slide down: that is, when you slide from and indefinite
>>>> point to a precise note, so basically the first number is missing.
>>>> It can't be legato (because there's just one note).
>>>>
>>>> I don't know if I can already get this with \glissando. I never
>>>> managed to get it working.
>>>> If I write \glissando "the note to slide to", it will connect the
>>>> note before with this note.
>>>> Do you know any workaround?
>>>>
>>> I found the following workaround in the archives:
>>>
>>> http://lists.gnu.org/archive/html/lilypond-user/2009-03/msg00190.html
>>>
>>> It is not very pretty, but it works, for the moment...
>>>
>>
>> I've tried this:
>> \grace{ \hideNotes a8\glissando s s \unHideNotes}  b4\3  d  e2
>>
>> but it works just on the staff, the TabStaff displays the first note (a8)
>>
>> how can I hide the note in TabStaff as well?
> Ah, yes, of course.
>
> You can define
>
> \hideFretNumber = \override TabNoteHead #'transparent = ##t
> \unHideFretNumber = \revert TabNoteHead #'transparent
>


For the definition, you need to remove the \ at the start:

hideFretNumber = \override TabNoteHead #'transparent = ##t
unHideFretNumber = \revert TabNoteHead #'transparent

Carl



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

Re: slides

Marc Hohl
Carl Sorensen schrieb:

>
> On 8/29/09 3:39 PM, "Marc Hohl" <[hidden email]> wrote:
>
>  
>> Federico Bruni schrieb:
>>    
>>> Marc Hohl wrote:
>>>      
>>>> Federico Bruni schrieb:
>>>>        
>>>>> Marc Hohl wrote:
>>>>>          
>>>>>> Generally, such changes are not too difficult to manage, but *we*
>>>>>>            
>>>>> as the
>>>>>          
>>>>>> tablature users should find
>>>>>> a consensus, so if there are more proposals, wishes etc., please
>>>>>>            
>>>>> let me
>>>>>          
>>>>>> know.
>>>>>>
>>>>>>            
>>>>> I have some questions regarding slides.
>>>>>
>>>>> I think tablature users need different kinds of slides:
>>>>>
>>>>> * legato slide: just the first note is picked (by fingers or
>>>>> flatpick), the notes after the first one are not picked again.
>>>>> In this case, besides the line which ties the numbers together,
>>>>> there should be an arch (a slur) showing that is a legato slide
>>>>> [this is what I've always seen in most books and tab editors].
>>>>>          
>>>> I think you can get this by combining a slur with a glissando line:
>>>>
>>>> c ( \glissando d )
>>>>        
>>> yes, it works as expected
>>>
>>>      
>>>>> * slide up/ slide down: that is, when you slide from and indefinite
>>>>> point to a precise note, so basically the first number is missing.
>>>>> It can't be legato (because there's just one note).
>>>>>
>>>>> I don't know if I can already get this with \glissando. I never
>>>>> managed to get it working.
>>>>> If I write \glissando "the note to slide to", it will connect the
>>>>> note before with this note.
>>>>> Do you know any workaround?
>>>>>
>>>>>          
>>>> I found the following workaround in the archives:
>>>>
>>>> http://lists.gnu.org/archive/html/lilypond-user/2009-03/msg00190.html
>>>>
>>>> It is not very pretty, but it works, for the moment...
>>>>
>>>>        
>>> I've tried this:
>>> \grace{ \hideNotes a8\glissando s s \unHideNotes}  b4\3  d  e2
>>>
>>> but it works just on the staff, the TabStaff displays the first note (a8)
>>>
>>> how can I hide the note in TabStaff as well?
>>>      
>> Ah, yes, of course.
>>
>> You can define
>>
>> \hideFretNumber = \override TabNoteHead #'transparent = ##t
>> \unHideFretNumber = \revert TabNoteHead #'transparent
>>
>>    
>
>
> For the definition, you need to remove the \ at the start:
>
> hideFretNumber = \override TabNoteHead #'transparent = ##t
> unHideFretNumber = \revert TabNoteHead #'transparent
>  
Silly me - you're right, of course.

It is just too late to write 100% error-proof mails ;-)

I'll go to bed now. Things will become better tomorrow ;-)

Marc
> Carl
>
>
>
>
>  



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

Re: slides

Valentin Villenave
Administrator
In reply to this post by Marc Hohl
On Sat, Aug 29, 2009 at 3:33 PM, Marc Hohl<[hidden email]> wrote:
> I found the following workaround in the archives:
>
> http://lists.gnu.org/archive/html/lilypond-user/2009-03/msg00190.html
>
> It is not very pretty, but it works, for the moment...

Hi everybody,

sorry for reviving this discussion, but could someone add this to the
LSR? (or send me a convenient snippet, with title, description and
everything so that I can add it myself)


Regards,
Valentin


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

Re: slides

Federico Bruni
In reply to this post by Federico Bruni

Hi Valentin,


find attached an example.

I must include tablature.ly because otherwise the slides in tabstaff

point in the same direction, both for slide into and slide from (if you comment it out, you'll see what I mean).


As soon as 2.13.4 is released, it won't be necessary anymore. Maybe we can update it then...


Title= Slide into / Slide from

(does anybody know any better name?)


Description= if you want to draw a slide from a not precise point of the fretboard to a specific fret,

you must add a grace hidden note before the note which is actually played.



Cheers,

Federico


 

----- Original Message -----

From: Valentin Villenave

Sent: 09/07/09 07:32 pm

To: [hidden email]

Subject: Re: [tablatures] slides

 

On Sat, Aug 29, 2009 at 3:33 PM, Marc Hohl wrote:
> I found the following workaround in the archives:
>
> http://lists.gnu.org/archive/html/lilypond-user/2009-03/msg00190.html
>
> It is not very pretty, but it works, for the moment...

Hi everybody,

sorry for reviving this discussion, but could someone add this to the
LSR? (or send me a convenient snippet, with title, description and
everything so that I can add it myself)


Regards,
Valentin

 



slide-test.ly (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: slides

Valentin Villenave
Administrator
On Tue, Sep 8, 2009 at 11:11 AM, Federico Bruni<[hidden email]> wrote:
> find attached an example.
>
> I must include tablature.ly because otherwise the slides in tabstaff
> point in the same direction, both for slide into and slide from (if you
> comment it out, you'll see what I mean).
>
> As soon as 2.13.4 is released, it won't be necessary anymore. Maybe we can
> update it then...

Hm, tricky. Besides, your snippet could be written in a more elgant
way, by using a single command to hide notes *and* fret numbers. And
perhaps you can avoid having a "unHide" command, by using \once. Could
you give it a try?

> Title= Slide into / Slide from
>
> (does anybody know any better name?)

I'd use "Guitar slides".

> Description= if you want to draw a slide from a not precise point of the
> fretboard to a specific fret,
> you must add a grace hidden note before the note which is actually played.

If you want to rewrite your code, I'll wait until it's ready before merging it.

Regards,
Valentin

slide-test.ly (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: slides

Federico Bruni
Valentin Villenave wrote:

> On Tue, Sep 8, 2009 at 11:11 AM, Federico Bruni<[hidden email]> wrote:
>> find attached an example.
>>
>> I must include tablature.ly because otherwise the slides in tabstaff
>> point in the same direction, both for slide into and slide from (if you
>> comment it out, you'll see what I mean).
>>
>> As soon as 2.13.4 is released, it won't be necessary anymore. Maybe we can
>> update it then...
>
> Hm, tricky. Besides, your snippet could be written in a more elgant
> way, by using a single command to hide notes *and* fret numbers. And
> perhaps you can avoid having a "unHide" command, by using \once. Could
> you give it a try?
>
Hi Valentine,

thanks for your suggestions.
I've come up with this new code (see file attached).

It's my first tweaking, so it might be "naive"..
Anyway, it works :-)


>> Title= Slide into / Slide from
>>
>> (does anybody know any better name?)
>
> I'd use "Guitar slides".
>

Actually, it can be used in any fretted instrument, not only guitar..
Anyway, choose what you think is better..

>> Description= if you want to draw a slide from a not precise point of the
>> fretboard to a specific fret,
>> you must add a grace hidden note before the note which is actually played.
>
> If you want to rewrite your code, I'll wait until it's ready before merging it.
>
> Regards,
> Valentin


\version "2.12.1"
% since version 2.13.4 you won't need to include tablature.ly
\include "tablature.ly"

%% Hide fret number: useful to draw slide into/from a casual point of
%% the fretboard.
hideFretNumber = { \once \override TabNoteHead #'transparent = ##t
                 \once \override NoteHead #'transparent = ##t
                 \once \override Stem #'transparent = ##t
}

music= \relative c' {
      \grace { \hideFretNumber d8\2 \glissando s2 } g2\2
      \grace { \hideFretNumber g8\2 \glissando s2 } d2 |
     
      \grace { \hideFretNumber c,8 \glissando s } f4\5^\markup \tiny "Slide into"
      \grace { \hideFretNumber f8 \glissando s } a4\4
      \grace { \hideFretNumber e'8\3 \glissando s } b4\3^\markup \tiny "Slide from"
      \grace { \hideFretNumber b'8 \glissando s2 } g4 |
    }

\score {
  <<
    \new Staff {
      \music
    }
    \new TabStaff {
      \music
    }
  >>
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: slides

Valentin Villenave
Administrator
On Sat, Sep 12, 2009 at 7:52 PM, Federico Bruni <[hidden email]> wrote:

> I've come up with this new code (see file attached).

Much better!

I've uploaded it as http://lsr.dsi.unimi.it/LSR/Item?id=633

I'm not sure what tablature.ly would change in the snippet. It didn't
exist in 2.12 (which the LSR is running), and as far as I can see, it
doesn't exist (yet?) in the 2.13 branch.

Cheers,
Valentin


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

Re: slides

Federico Bruni
Valentin Villenave wrote:

> On Sat, Sep 12, 2009 at 7:52 PM, Federico Bruni <[hidden email]> wrote:
>
>> I've come up with this new code (see file attached).
>
> Much better!
>
> I've uploaded it as http://lsr.dsi.unimi.it/LSR/Item?id=633
>
> I'm not sure what tablature.ly would change in the snippet. It didn't
> exist in 2.12 (which the LSR is running), and as far as I can see, it
> doesn't exist (yet?) in the 2.13 branch.
>
In this case, tablature.ly is useful because it modifies the slope of
the slides.
Without tablature.ly, all the slides go from down left to up right (no
matter if it's a slide into or a slide from).
With tablature.ly, slide into have down left --> up right direction,
while slide from have up left --> down right direction.

I attach an image..

tablature.ly is a file written by Marc Hohl to allow us to test the
new tablature features. It won't exist in any future version of
LilyPond, as that code will be included in different configuration
files (ask Marc if you want to know more).

So, I think it might be a good idea to add tablature.ly in the LSR.
(you find it attached)


%%%% tablature.ly
%%%%
%%%% source file of the GNU LilyPond music typesetter
%%%%
%%%% (c) 2009 Marc Hohl <[hidden email]>


% some publications use the triangle-shaped note head
% for palm mute, so here we go:
palmMuteOn = {
  \override NoteHead #'style = #'do
}

palmMuteOff = {
  \revert NoteHead #'style
}

% for single notes (even in chord constructs <...>),
% or grouped notes in {...}
palmMute =
#(define-music-function (parser location note) (ly:music?)
  ;; are we inside a <...>?
  (if (eq? (ly:music-property note 'name) 'NoteEvent)
      ;; yes -> add a tweak
      (begin (set! (ly:music-property note 'tweaks)
                    (acons 'style 'do (ly:music-property note 'tweaks)))
      note)
      ;; no -> use predefined commands to switch to triangle-shaped note heads
      #{
        \palmMuteOn
        $note
        \palmMuteOff
      #}))


% dead notes are marked with a cross-shape note head,
% both in normal notation and in tablature:
deadNotesOn = {
  \override TabNoteHead #'style = #'cross
  \override NoteHead #'style = #'cross
}

deadNotesOff = {
  \revert TabNoteHead #'style
  \revert NoteHead #'style
}

% for single notes (even in chord constructs <...>),
% or grouped notes in {...}
deadNote =
#(define-music-function (parser location note) (ly:music?)
  ;; are we inside a <...>?
  (if (eq? (ly:music-property note 'name) 'NoteEvent)
      ;; yes -> add a tweak
      (begin (set! (ly:music-property note 'tweaks)
                    (acons 'style 'cross (ly:music-property note 'tweaks)))
       note)
       ;; no -> use predefined commmands for changing
       ;; note head and tablature fret signs
       #{
         \deadNotesOn
         $note
         \deadNotesOff
       #}))

% for more control over glyph-name calculations,
% use custom callback with tab noteheads which will ignore
% 'style = 'do
#(define-public (tab-note-head::calc-glyph-name grob)
  (let ((style (ly:grob-property grob 'style)))
   (case style
      ((cross) "2cross"))))

% ensure we only call notehead callback when
% 'style = 'cross
#(define-public (tab-note-head::whiteout-if-style-set grob)
  (let ((style (ly:grob-property grob 'style)))
       (if (and (symbol? style)
                (eq? style 'cross))
           (stencil-whiteout (ly:note-head::print grob))
           (ly:text-interface::print grob))))

% definitions for the "moderntab" clef:
% the "moderntab" clef will be added to the list of known clefs,
% so it can be used as any other clef:
%
% \clef "moderntab"
%
#(add-new-clef "moderntab" "markup.moderntab" 0 0 0)

% this function decides which clef to take
#(define-public (clef::print-modern-tab-if-set grob)
  (let ((glyph (ly:grob-property grob 'glyph)))
       ;; which clef is wanted?
       (if (string=? glyph "markup.moderntab")
           ;; if it is "moderntab", we'll draw it
           (let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
                  (line-count   (ly:grob-property staff-symbol 'line-count))
                  (staff-space  (ly:grob-property staff-symbol 'staff-space 1)))
                 (grob-interpret-markup grob (make-customTabClef-markup line-count staff-space)))
           ;; otherwise, we simply use the default printing routine
           (ly:clef::print grob))))

% define sans serif-style tab-Clefs as a markup:
#(define-markup-command (customTabClef layout props num-strings staff-space) (integer? number?)
  (define (square x) (* x x))
  (let* ((scale-factor (/ staff-space 1.5))
         (font-size (- (* num-strings 1.5 scale-factor) 7))
         (base-skip (* (square (+ (* num-strings 0.195) 0.4)) scale-factor)))

        (interpret-markup layout props
           (markup #:vcenter #:bold
                   #:override (cons 'font-family 'sans)
                   #:fontsize font-size
                   #:override (cons 'baseline-skip base-skip)
                   #:left-align #:center-column ("T" "A" "B")))))

% if the stems are drawn, it is nice to have a double stem for
% (dotted) half notes to distinguish them from quarter notes:
#(define-public (tabvoice::draw-double-stem-for-half-notes grob)
  (let ((stem (ly:stem::print grob)))

       ;; is the note a (dotted) half note?
       (if (= 1 (ly:grob-property grob 'duration-log))
           ;; yes -> draw double stem
           (ly:stencil-combine-at-edge stem X RIGHT stem 0.5)
           ;; no -> draw simple stem
           stem)))

% as default, the glissando line between fret numbers goes
% upwards, here we have a function to correct this behavior:
#(define-public (glissando::calc-tab-extra-dy grob)
  (let* ((original (ly:grob-original grob))
         (left-bound (ly:spanner-bound original LEFT))
         (right-bound (ly:spanner-bound original RIGHT))
         (left-pitch (ly:event-property (event-cause left-bound) 'pitch))
         (right-pitch (ly:event-property (event-cause right-bound) 'pitch)))

    (if (< (ly:pitch-semitones right-pitch) (ly:pitch-semitones left-pitch))
        -0.75
         0.75)))

% for ties in tablature, fret numbers that are tied to should be invisible,
% except for 'tied to' numbers after a line break; these will be parenthesized
% (thanks to Neil for his solution):
#(define-public (parenthesize-tab-note-head grob)
  ;; Helper function to parenthesize tab noteheads,
  ;; since we can't use ParenthesesItem at this stage
  ;; This is basically the same as the C++ function
  ;; in accidental.cc, converted to Scheme
  (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)))
        (ly:stencil-combine-at-edge
         (ly:stencil-combine-at-edge
          me
          X
          LEFT
          open)
         X
         RIGHT
         close)))

% ParenthesesItem doesn't work very well for TabNoteHead, since
% the parentheses are too small and clash with the staff-lines
% Define a callback for the 'stencils property which will tweak
% the parentheses' appearance for TabNoteHead
#(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)))
     ;; check whether it's a notehead
     (if (grob::has-interface victim 'note-head-interface)
         (begin
           ;; tweak appearance before retrieving list of stencils '(left-paren right-paren)
           (ly:grob-set-property! grob 'font-size -2)
           (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))))

 the handler for ties in tablature; split ties yield in a parenthesized
 fret number, otherwise the fret number will be invisible.
 #(define-public (tie::handle-tab-tie grob)
   (let* ((original (ly:grob-original grob))
          (tied-tab-note-head (ly:spanner-bound grob RIGHT))
          (siblings (if (ly:grob? original)
                        (ly:spanner-broken-into original) '())))

     (if (and (>= (length siblings) 2)
              (eq? (car (last-pair siblings)) grob))
         ;; tie is split -> parenthesize
         (ly:grob-set-property! tied-tab-note-head 'stencil
                                (lambda (grob) (parenthesize-tab-note-head grob)))

         ;; tie is not split -> make fret number invisible
         (ly:grob-set-property! tied-tab-note-head 'transparent #t))))


% repeat ties occur within alternatives in a repeat construct;
% the correspondig fret numbers are shown in parentheses:
#(define-public (repeat-tie::parenthesize-tab grob)
  (let ((tied-tab-note-head (ly:grob-object grob 'note-head)))

        (ly:grob-set-property! tied-tab-note-head 'stencil
                               (lambda (grob) (parenthesize-tab-note-head grob)))))

% This allows to hide the fret numbers also in a RepeatTie.
% It can be called using this line:
% \override RepeatTie #'after-line-breaking = #repeat-tie::erase-tab
#(define (repeat-tie::erase-tab grob)
 (let ((tied-tabnotehead (ly:grob-object grob 'note-head)))

(ly:grob-set-property! tied-tabnotehead 'transparent #t)))

% a command for switching to the (improved) full notation
tabFullNotation = {
  % time signature
  \revert TabStaff.TimeSignature #'stencil
  % stems (the half note gets a double stem)
  \override TabVoice.Stem #'stencil = #tabvoice::draw-double-stem-for-half-notes
  % beams, dots
  \revert TabVoice.Beam #'stencil
  \revert TabVoice.Dots #'stencil
  \revert TabVoice.Tie #'stencil
  \revert TabVoice.Tie #'after-line-breaking
  \revert TabVoice.RepeatTie #'stencil
  \revert TabVoice.RepeatTie #'after-line-braking
  \revert TabVoice.LaissezVibrerTie #'stencil
  \revert TabVoice.Slur #'stencil
  \revert PhrasingSlur #'stencil
  % tuplet stuff
  \revert TabVoice.TupletBracket #'stencil
  \revert TabVoice.TupletNumber #'stencil
  % dynamic signs
  \revert DynamicText #'transparent
  \revert DynamicTextSpanner #'stencil
  \revert TabVoice.DynamicTextSpanner #'stencil
  \revert TabVoice.Hairpin #'transparent
  % rests
  \revert TabVoice.Rest #'stencil
  \revert TabVoice.MultiMeasureRest #'stencil
  % markups etc.
  \revert TabVoice.Script #'stencil
  \revert TabVoice.TextScript #'stencil
  \revert TabStaff.Arpeggio #'stencil
}

% the defaults for tablature:
\layout {
  \context {
    \TabStaff
    % the clef handler
    \override Clef #'stencil = #clef::print-modern-tab-if-set
    % no time signature
    \override TimeSignature #'stencil = ##f
    % better parentheses in a TabStaff
    \override ParenthesesItem #'stencils = #parentheses-item::calc-tabstaff-parenthesis-stencils
    % no arpeggios
    \override Arpeggio #'stencil = ##f
  }
  \context {
    \TabVoice
    % remove stems, beams, dots and rests ...
    \override Stem #'stencil = ##f
    \override Beam #'stencil = ##f
    \override Dots #'stencil = ##f
    \override Rest #'stencil = ##f
    \override MultiMeasureRest #'stencil = ##f
    % ... all kinds of ties/slurs
    \override Tie  #'stencil = ##f
    \override RepeatTie #'stencil = ##f
    \override LaissezVibrerTie #'stencil = ##f
    \override Slur #'stencil = ##f
    \override PhrasingSlur #'stencil = ##f
    % 'tied to' fret numbers become invisible or parenthesized, respectively)
    \override Tie #'after-line-breaking = #tie::handle-tab-tie
    \override RepeatTie #'after-line-breaking = #repeat-tie::parenthesize-tab
    % ... and all kinds of markups, spanners etc.
    \override TupletBracket #'stencil = ##f
    \override TupletNumber #'stencil = ##f
    \override DynamicText #'transparent = ##t
    \override DynamicTextSpanner #'stencil = ##f
    \override TextSpanner #'stencil = ##f
    \override Hairpin #'transparent = ##t
    \override Script #'stencil = ##f
    \override TextScript #'stencil = ##f
    % the direction for glissando lines will be automatically corrected
    \override Glissando #'extra-dy = #glissando::calc-tab-extra-dy
    % dead notes in tablature and within chord constructs
    \override TabNoteHead #'glyph-name = #tab-note-head::calc-glyph-name
    \override TabNoteHead #'stencil = #tab-note-head::whiteout-if-style-set
  }
}

slide-test2.png (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: slides

Marc Hohl
Federico Bruni schrieb:

> Valentin Villenave wrote:
>> On Sat, Sep 12, 2009 at 7:52 PM, Federico Bruni <[hidden email]>
>> wrote:
>>
>>> I've come up with this new code (see file attached).
>>
>> Much better!
>>
>> I've uploaded it as http://lsr.dsi.unimi.it/LSR/Item?id=633
>>
>> I'm not sure what tablature.ly would change in the snippet. It didn't
>> exist in 2.12 (which the LSR is running), and as far as I can see, it
>> doesn't exist (yet?) in the 2.13 branch.
>>
>
> In this case, tablature.ly is useful because it modifies the slope of
> the slides.
> Without tablature.ly, all the slides go from down left to up right (no
> matter if it's a slide into or a slide from).
> With tablature.ly, slide into have down left --> up right direction,
> while slide from have up left --> down right direction.
>
> I attach an image..
>
As you can see in the image, the ledger lines are still visible (for
guitar, you normally use
\clef "treble_8", so in your example, the ledger lines wouldn't appear
either).
> tablature.ly is a file written by Marc Hohl to allow us to test the
> new tablature features. It won't exist in any future version of
> LilyPond, as that code will be included in different configuration
> files (ask Marc if you want to know more).
>
> So, I think it might be a good idea to add tablature.ly in the LSR.
> (you find it attached)
Hm, I am not sure about this, but if we would include it, we should
remove the "moderntab" part,
because this demands changing internal files to work properly.

Marc




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

Re: slides

Carl Sorensen



On 9/14/09 2:36 AM, "Marc Hohl" <[hidden email]> wrote:

> Federico Bruni schrieb:
>> Valentin Villenave wrote:
>> tablature.ly is a file written by Marc Hohl to allow us to test the
>> new tablature features. It won't exist in any future version of
>> LilyPond, as that code will be included in different configuration
>> files (ask Marc if you want to know more).
>>
>> So, I think it might be a good idea to add tablature.ly in the LSR.
>> (you find it attached)
> Hm, I am not sure about this, but if we would include it, we should
> remove the "moderntab" part,
> because this demands changing internal files to work properly.

I think you could just add the changed definition to your tablature.ly file.

Scheme doesn't object to redefinition of a procedure.

Carl



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

Re: slides

Marc Hohl
Carl Sorensen schrieb:

>
> On 9/14/09 2:36 AM, "Marc Hohl" <[hidden email]> wrote:
>
>  
>> Federico Bruni schrieb:
>>    
>>> Valentin Villenave wrote:
>>> tablature.ly is a file written by Marc Hohl to allow us to test the
>>> new tablature features. It won't exist in any future version of
>>> LilyPond, as that code will be included in different configuration
>>> files (ask Marc if you want to know more).
>>>
>>> So, I think it might be a good idea to add tablature.ly in the LSR.
>>> (you find it attached)
>>>      
>> Hm, I am not sure about this, but if we would include it, we should
>> remove the "moderntab" part,
>> because this demands changing internal files to work properly.
>>    
>
> I think you could just add the changed definition to your tablature.ly file.
>
> Scheme doesn't object to redefinition of a procedure.
>  
As far as I know, the alists for resolving the clef name in
scm/parser-clef.scm
are not defined globally, so I had to put the definition for add-new-clef in
this file.

Marc
> Carl
>
>
>
>
>  



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

Re: slides

Carl Sorensen



On 9/14/09 11:33 AM, "Marc Hohl" <[hidden email]> wrote:

> Carl Sorensen schrieb:
>>
>> On 9/14/09 2:36 AM, "Marc Hohl" <[hidden email]> wrote:
>>
>>  
>>> Federico Bruni schrieb:
>>>    
>>>> Valentin Villenave wrote:
>>>> tablature.ly is a file written by Marc Hohl to allow us to test the
>>>> new tablature features. It won't exist in any future version of
>>>> LilyPond, as that code will be included in different configuration
>>>> files (ask Marc if you want to know more).
>>>>
>>>> So, I think it might be a good idea to add tablature.ly in the LSR.
>>>> (you find it attached)
>>>>      
>>> Hm, I am not sure about this, but if we would include it, we should
>>> remove the "moderntab" part,
>>> because this demands changing internal files to work properly.
>>>    
>>
>> I think you could just add the changed definition to your tablature.ly file.
>>
>> Scheme doesn't object to redefinition of a procedure.
>>  
> As far as I know, the alists for resolving the clef name in
> scm/parser-clef.scm
> are not defined globally, so I had to put the definition for add-new-clef in
> this file.
>

No question it's the right way to do it for 2.13.4.

But the whole thin (including the alists) could be copied to tablature.ly
for immediate use with 2.12, couldn't it?

Carl



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

Re: slides

Marc Hohl
Carl Sorensen schrieb:

>
> On 9/14/09 11:33 AM, "Marc Hohl" <[hidden email]> wrote:
>
>  
>> Carl Sorensen schrieb:
>>    
>>> On 9/14/09 2:36 AM, "Marc Hohl" <[hidden email]> wrote:
>>>
>>>  
>>>      
>>>> Federico Bruni schrieb:
>>>>    
>>>>        
>>>>> Valentin Villenave wrote:
>>>>> tablature.ly is a file written by Marc Hohl to allow us to test the
>>>>> new tablature features. It won't exist in any future version of
>>>>> LilyPond, as that code will be included in different configuration
>>>>> files (ask Marc if you want to know more).
>>>>>
>>>>> So, I think it might be a good idea to add tablature.ly in the LSR.
>>>>> (you find it attached)
>>>>>      
>>>>>          
>>>> Hm, I am not sure about this, but if we would include it, we should
>>>> remove the "moderntab" part,
>>>> because this demands changing internal files to work properly.
>>>>    
>>>>        
>>> I think you could just add the changed definition to your tablature.ly file.
>>>
>>> Scheme doesn't object to redefinition of a procedure.
>>>  
>>>      
>> As far as I know, the alists for resolving the clef name in
>> scm/parser-clef.scm
>> are not defined globally, so I had to put the definition for add-new-clef in
>> this file.
>>
>>    
>
> No question it's the right way to do it for 2.13.4.
>
> But the whole thin (including the alists) could be copied to tablature.ly
> for immediate use with 2.12, couldn't it?
>  
Ah, ok, then I misunderstood your proposal. Yes, if we include the
alists, then
everything will work as expected (at least I hope so ;-).
I'll try to ship a working tablature.ly within the next days...

Marc
> Carl
>
>
>
>
>  



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

Re: slides

Marc Hohl
In reply to this post by Carl Sorensen
Carl Sorensen schrieb:
> [...]
>
> No question it's the right way to do it for 2.13.4.
>
> But the whole thin (including the alists) could be copied to tablature.ly
> for immediate use with 2.12, couldn't it?
>
> Carl
>  
Hm, after a bit of investigating I can only produce error messages.
What I did: I included the definition of c0-pitch-alist together with
the definition for add-new-clef in tablature.ly, which didn't work:

In procedure cdr in expression (cdr (assoc # c0-pitch-alist)):
/home/marc/lilypond/usr/share/lilypond/current/scm/parser-clef.scm:119:45:
Wrong type (expecting pair): #f
(by the way, I don't understand this error, because when I #(display
c0-pitch-alist), I looks
as it should be)

Then I added the supported-clefs list to the file with the result that
the error message went away, but lilypond still claims that the clef
"moderntab" can't be found.

Then again, I tried to hardcode the values for the moderntab clef,
and this resulted in the attached file, but it still doesn't work. I
also tried to
include the definition for make-clef-set from scm/parser-clef.scm
in tablature.ly, but the function string-match is not known at this stage.

What can I do to make this work? Any hints are appreciated!

Marc
>
>
>
>  



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

Re: slides

Carl Sorensen



On 9/14/09 1:30 PM, "Marc Hohl" <[hidden email]> wrote:

> Carl Sorensen schrieb:
>> [...]
>>
>> No question it's the right way to do it for 2.13.4.
>>
>> But the whole thin (including the alists) could be copied to tablature.ly
>> for immediate use with 2.12, couldn't it?
>>
>> Carl
>>  
> Hm, after a bit of investigating I can only produce error messages.
> What I did: I included the definition of c0-pitch-alist together with
> the definition for add-new-clef in tablature.ly, which didn't work:
>
> In procedure cdr in expression (cdr (assoc # c0-pitch-alist)):
> /home/marc/lilypond/usr/share/lilypond/current/scm/parser-clef.scm:119:45:
> Wrong type (expecting pair): #f
> (by the way, I don't understand this error, because when I #(display
> c0-pitch-alist), I looks
> as it should be)

(assoc # c0-pitch-alist)  looks fishy to me.

I think that the error comes from the cdr call, which needs a pair, but the
assoc call returns #f.


>
> Then I added the supported-clefs list to the file with the result that
> the error message went away, but lilypond still claims that the clef
> "moderntab" can't be found.
>
> Then again, I tried to hardcode the values for the moderntab clef,
> and this resulted in the attached file, but it still doesn't work. I
> also tried to
> include the definition for make-clef-set from scm/parser-clef.scm
> in tablature.ly, but the function string-match is not known at this stage.

I didn't get an attachment with this file, so I don't know how to
troubleshoot it  for you.

Thanks,

Carl



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

Re: slides

Marc Hohl
Carl Sorensen schrieb:

>
> On 9/14/09 1:30 PM, "Marc Hohl" <[hidden email]> wrote:
>
>  
>> Carl Sorensen schrieb:
>>    
>>> [...]
>>>
>>> No question it's the right way to do it for 2.13.4.
>>>
>>> But the whole thin (including the alists) could be copied to tablature.ly
>>> for immediate use with 2.12, couldn't it?
>>>
>>> Carl
>>>  
>>>      
>> Hm, after a bit of investigating I can only produce error messages.
>> What I did: I included the definition of c0-pitch-alist together with
>> the definition for add-new-clef in tablature.ly, which didn't work:
>>
>> In procedure cdr in expression (cdr (assoc # c0-pitch-alist)):
>> /home/marc/lilypond/usr/share/lilypond/current/scm/parser-clef.scm:119:45:
>> Wrong type (expecting pair): #f
>> (by the way, I don't understand this error, because when I #(display
>> c0-pitch-alist), I looks
>> as it should be)
>>    
>
> (assoc # c0-pitch-alist)  looks fishy to me.
>
> I think that the error comes from the cdr call, which needs a pair, but the
> assoc call returns #f.
>  
Yes, and my first thought was that there were error building up the alist,
but the list seems to be ok...

>
>  
>> Then I added the supported-clefs list to the file with the result that
>> the error message went away, but lilypond still claims that the clef
>> "moderntab" can't be found.
>>
>> Then again, I tried to hardcode the values for the moderntab clef,
>> and this resulted in the attached file, but it still doesn't work. I
>> also tried to
>> include the definition for make-clef-set from scm/parser-clef.scm
>> in tablature.ly, but the function string-match is not known at this stage.
>>    
>
> I didn't get an attachment with this file, so I don't know how to
> troubleshoot it  for you.
>  
Oh, yes, I wanted to attach the file ... I hope in some years from now the
email clients are clever enough to warn you if you mention "attached" or
"send ... to you" that there is propably some attachment missing :-)

Here it is. Thanks in advance for your support!

Marc
> Thanks,
>
> Carl
>
>
>
>
>  


%%%% tablature.ly
%%%%
%%%% source file of the GNU LilyPond music typesetter
%%%%
%%%% (c) 2009 Marc Hohl <[hidden email]>

%a copy of the alists from scm/parser-clef.scm
% because it isn't defined as -public (the moderntab
% entry is inserted):
#(define-public c0-pitch-alist
  '(("clefs.G" . -4)
    ("clefs.C" . 0)
    ("clefs.F" . 4)
    ("clefs.percussion" . 0)
    ("clefs.tab" . 0 )
    ("clefs.vaticana.do" . 0)
    ("clefs.vaticana.fa" . 4)
    ("clefs.medicaea.do" . 0)
    ("clefs.medicaea.fa" . 4)
    ("clefs.hufnagel.do" . 0)
    ("clefs.hufnagel.fa" . 4)
    ("clefs.hufnagel.do.fa" . 0)
    ("clefs.mensural.c" . 0)
    ("clefs.mensural.f" . 4)
    ("clefs.mensural.g" . -4)
    ("clefs.neomensural.c" . 0)
    ("clefs.petrucci.c1" . 0)
    ("clefs.petrucci.c2" . 0)
    ("clefs.petrucci.c3" . 0)
    ("clefs.petrucci.c4" . 0)
    ("clefs.petrucci.c5" . 0)
    ("clefs.petrucci.f" . 4)
    ("clefs.petrucci.g" . -4)
    ("markup.moderntab" . 0)))

#(define-public supported-clefs
  '(("treble" . ("clefs.G" -2 0))
    ("violin" . ("clefs.G" -2 0))
    ("G" . ("clefs.G" -2 0))
    ("G2" . ("clefs.G" -2 0))
    ("french" . ("clefs.G" -4 0))
    ("soprano" . ("clefs.C" -4 0))
    ("mezzosoprano" . ("clefs.C" -2 0))
    ("alto" . ("clefs.C" 0 0))
    ("C" . ("clefs.C" 0 0))
    ("tenor" . ("clefs.C" 2 0))
    ("baritone" . ("clefs.C" 4 0))
    ("varbaritone" . ("clefs.F" 0 0))
    ("bass" . ("clefs.F" 2 0))
    ("F" . ("clefs.F" 2 0))
    ("subbass" . ("clefs.F" 4 0))
    ("percussion" . ("clefs.percussion" 0 0))
    ("tab" . ("clefs.tab" 0 0))
    ("moderntab" . ("markup.moderntab" 0 0))

    ;; should move mensural stuff to separate file?
    ("vaticana-do1" . ("clefs.vaticana.do" -1 0))
    ("vaticana-do2" . ("clefs.vaticana.do" 1 0))
    ("vaticana-do3" . ("clefs.vaticana.do" 3 0))
    ("vaticana-fa1" . ("clefs.vaticana.fa" -1 0))

    ("vaticana-fa2" . ("clefs.vaticana.fa" 1 0))
    ("medicaea-do1" . ("clefs.medicaea.do" -1 0))
    ("medicaea-do2" . ("clefs.medicaea.do" 1 0))
    ("medicaea-do3" . ("clefs.medicaea.do" 3 0))
    ("medicaea-fa1" . ("clefs.medicaea.fa" -1 0))
    ("medicaea-fa2" . ("clefs.medicaea.fa" 1 0))
    ("hufnagel-do1" . ("clefs.hufnagel.do" -1 0))
    ("hufnagel-do2" . ("clefs.hufnagel.do" 1 0))
    ("hufnagel-do3" . ("clefs.hufnagel.do" 3 0))
    ("hufnagel-fa1" . ("clefs.hufnagel.fa" -1 0))
    ("hufnagel-fa2" . ("clefs.hufnagel.fa" 1 0))
    ("hufnagel-do-fa" . ("clefs.hufnagel.do.fa" 4 0))
    ("mensural-c1" . ("clefs.mensural.c" -2 0))
    ("mensural-c2" . ("clefs.mensural.c" 0 0))
    ("mensural-c3" . ("clefs.mensural.c" 2 0))
    ("mensural-c4" . ("clefs.mensural.c" 4 0))
    ("mensural-f" . ("clefs.mensural.f" 2 0))
    ("mensural-g" . ("clefs.mensural.g" -2 0))
    ("neomensural-c1" . ("clefs.neomensural.c" -4 0))
    ("neomensural-c2" . ("clefs.neomensural.c" -2 0))
    ("neomensural-c3" . ("clefs.neomensural.c" 0 0))
    ("neomensural-c4" . ("clefs.neomensural.c" 2 0))
    ("petrucci-c1" . ("clefs.petrucci.c1" -4 0))
    ("petrucci-c2" . ("clefs.petrucci.c2" -2 0))
    ("petrucci-c3" . ("clefs.petrucci.c3" 0 0))
    ("petrucci-c4" . ("clefs.petrucci.c4" 2 0))
    ("petrucci-c5" . ("clefs.petrucci.c5" 4 0))
    ("petrucci-f3" . ("clefs.petrucci.f" 0 0))
    ("petrucci-f4" . ("clefs.petrucci.f" 2 0))
    ("petrucci-f" . ("clefs.petrucci.f" 2 0))
    ("petrucci-g" . ("clefs.petrucci.g" -2 0))))


% some publications use the triangle-shaped note head
% for palm mute, so here we go:
palmMuteOn = {
  \override NoteHead #'style = #'do
}

palmMuteOff = {
  \revert NoteHead #'style
}

% for single notes (even in chord constructs <...>),
% or grouped notes in {...}
palmMute =
#(define-music-function (parser location note) (ly:music?)
  ;; are we inside a <...>?
  (if (eq? (ly:music-property note 'name) 'NoteEvent)
      ;; yes -> add a tweak
      (begin (set! (ly:music-property note 'tweaks)
                    (acons 'style 'do (ly:music-property note 'tweaks)))
      note)
      ;; no -> use predefined commands to switch to triangle-shaped note heads
      #{
        \palmMuteOn
        $note
        \palmMuteOff
      #}))


% dead notes are marked with a cross-shape note head,
% both in normal notation and in tablature:
deadNotesOn = {
  \override TabNoteHead #'style = #'cross
  \override NoteHead #'style = #'cross
}

deadNotesOff = {
  \revert TabNoteHead #'style
  \revert NoteHead #'style
}

% for single notes (even in chord constructs <...>),
% or grouped notes in {...}
deadNote =
#(define-music-function (parser location note) (ly:music?)
  ;; are we inside a <...>?
  (if (eq? (ly:music-property note 'name) 'NoteEvent)
      ;; yes -> add a tweak
      (begin (set! (ly:music-property note 'tweaks)
                    (acons 'style 'cross (ly:music-property note 'tweaks)))
       note)
       ;; no -> use predefined commmands for changing
       ;; note head and tablature fret signs
       #{
         \deadNotesOn
         $note
         \deadNotesOff
       #}))

% for more control over glyph-name calculations,
% use custom callback with tab noteheads which will ignore
% 'style = 'do
#(define-public (tab-note-head::calc-glyph-name grob)
  (let ((style (ly:grob-property grob 'style)))
   (case style
      ((cross) "2cross"))))

% ensure we only call notehead callback when
% 'style = 'cross
#(define (tab-note-head::whiteout-if-style-set grob)
  (let ((style (ly:grob-property grob 'style)))
       (if (and (symbol? style)
                (eq? style 'cross))
           (stencil-whiteout (ly:note-head::print grob))
           (ly:text-interface::print grob))))

% this function decides which clef to take
#(define (clef::print-modern-tab-if-set grob)
  (let ((glyph (ly:grob-property grob 'glyph)))
       ;; which clef is wanted?
       (if (string=? glyph "markup.moderntab")
           ;; if it is "moderntab", we'll draw it
           (let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
                  (line-count   (ly:grob-property staff-symbol 'line-count))
                  (staff-space  (ly:grob-property staff-symbol 'staff-space 1)))
                 (grob-interpret-markup grob (make-customTabClef-markup line-count staff-space)))
           ;; otherwise, we simply use the default printing routine
           (ly:clef::print grob))))

% define sans serif-style tab-Clefs as a markup:
#(define-markup-command (customTabClef layout props num-strings staff-space) (integer? number?)
  (define (square x) (* x x))
  (let* ((scale-factor (/ staff-space 1.5))
         (font-size (- (* num-strings 1.5 scale-factor) 7))
         (base-skip (* (square (+ (* num-strings 0.195) 0.4)) scale-factor)))

        (interpret-markup layout props
           (markup #:vcenter #:bold
                   #:override (cons 'font-family 'sans)
                   #:fontsize font-size
                   #:override (cons 'baseline-skip base-skip)
                   #:left-align #:center-column ("T" "A" "B")))))

% if the stems are drawn, it is nice to have a double stem for
% (dotted) half notes to distinguish them from quarter notes:
#(define-public (tabvoice::draw-double-stem-for-half-notes grob)
  (let ((stem (ly:stem::print grob)))

       ;; is the note a (dotted) half note?
       (if (= 1 (ly:grob-property grob 'duration-log))
           ;; yes -> draw double stem
           (ly:stencil-combine-at-edge stem X RIGHT stem 0.5)
           ;; no -> draw simple stem
           stem)))

% as default, the glissando line between fret numbers goes
% upwards, here we have a function to correct this behavior:
#(define-public (glissando::calc-tab-extra-dy grob)
  (let* ((original (ly:grob-original grob))
         (left-bound (ly:spanner-bound original LEFT))
         (right-bound (ly:spanner-bound original RIGHT))
         (left-pitch (ly:event-property (event-cause left-bound) 'pitch))
         (right-pitch (ly:event-property (event-cause right-bound) 'pitch)))

    (if (< (ly:pitch-semitones right-pitch) (ly:pitch-semitones left-pitch))
        -0.75
         0.75)))

% for ties in tablature, fret numbers that are tied to should be invisible,
% except for 'tied to' numbers after a line break; these will be parenthesized
% (thanks to Neil for his solution):
#(define-public (parenthesize-tab-note-head grob)
  ;; Helper function to parenthesize tab noteheads,
  ;; since we can't use ParenthesesItem at this stage
  ;; This is basically the same as the C++ function
  ;; in accidental.cc, converted to Scheme
  (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)))
        (ly:stencil-combine-at-edge
         (ly:stencil-combine-at-edge
          me
          X
          LEFT
          open)
         X
         RIGHT
         close)))

% ParenthesesItem doesn't work very well for TabNoteHead, since
% the parentheses are too small and clash with the staff-lines
% Define a callback for the 'stencils property which will tweak
% the parentheses' appearance for TabNoteHead
#(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)))
     ;; check whether it's a notehead
     (if (grob::has-interface victim 'note-head-interface)
         (begin
           ;; tweak appearance before retrieving list of stencils '(left-paren right-paren)
           (ly:grob-set-property! grob 'font-size -2)
           (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))))

% the handler for ties in tablature; split ties yield in a parenthesized
% fret number, otherwise the fret number will be invisible.
#(define-public (tie::handle-tab-tie grob)
   (let* ((original (ly:grob-original grob))
          (tied-tab-note-head (ly:spanner-bound grob RIGHT))
          (siblings (if (ly:grob? original)
                        (ly:spanner-broken-into original) '())))

     (if (and (>= (length siblings) 2)
              (eq? (car (last-pair siblings)) grob))
         ;; tie is split -> parenthesize
         (ly:grob-set-property! tied-tab-note-head 'stencil
                                (lambda (grob) (parenthesize-tab-note-head grob)))

         ;; tie is not split -> make fret number invisible
         (ly:grob-set-property! tied-tab-note-head 'transparent #t))))

% repeat ties occur within alternatives in a repeat construct;
% the correspondig fret numbers are shown in parentheses:
#(define-public (repeat-tie::parenthesize-tab grob)
  (let ((tied-tab-note-head (ly:grob-object grob 'note-head)))

        (ly:grob-set-property! tied-tab-note-head 'stencil
                               (lambda (grob) (parenthesize-tab-note-head grob)))))

% a command for switching to the (improved) full notation
tabFullNotation = {
  % time signature
  \revert TabStaff.TimeSignature #'stencil
  % stems (the half note gets a double stem)
  \override TabVoice.Stem #'stencil = #tabvoice::draw-double-stem-for-half-notes
  % beams, dots
  \revert TabVoice.Beam #'stencil
  \revert TabVoice.Dots #'stencil
  \revert TabVoice.Tie #'stencil
  \revert TabVoice.Tie #'after-line-breaking
  \revert TabVoice.RepeatTie #'stencil
  \revert TabVoice.RepeatTie #'after-line-braking
  \revert TabVoice.LaissezVibrerTie #'stencil
  \revert TabVoice.Slur #'stencil
  \revert PhrasingSlur #'stencil
  % tuplet stuff
  \revert TabVoice.TupletBracket #'stencil
  \revert TabVoice.TupletNumber #'stencil
  % dynamic signs
  \revert DynamicText #'transparent
  \revert DynamicTextSpanner #'stencil
  \revert TabVoice.DynamicTextSpanner #'stencil
  \revert TabVoice.Hairpin #'transparent
  % rests
  \revert TabVoice.Rest #'stencil
  \revert TabVoice.MultiMeasureRest #'stencil
  % markups etc.
  \revert TabVoice.Script #'stencil
  \revert TabVoice.TextScript #'stencil
  \revert TabStaff.Arpeggio #'stencil
}

% the defaults for tablature:
\layout {
  \context {
    \TabStaff
    % the clef handler
    \override Clef #'stencil = #clef::print-modern-tab-if-set
    % no time signature
    \override TimeSignature #'stencil = ##f
    % better parentheses in a TabStaff
    \override ParenthesesItem #'stencils = #parentheses-item::calc-tabstaff-parenthesis-stencils
    % no arpeggios
    \override Arpeggio #'stencil = ##f
  }
  \context {
    \TabVoice
    % remove stems, beams, dots and rests ...
    \override Stem #'stencil = ##f
    \override Beam #'stencil = ##f
    \override Dots #'stencil = ##f
    \override Rest #'stencil = ##f
    \override MultiMeasureRest #'stencil = ##f
    % ... all kinds of ties/slurs
    \override Tie  #'stencil = ##f
    \override RepeatTie #'stencil = ##f
    \override LaissezVibrerTie #'stencil = ##f
    \override Slur #'stencil = ##f
    \override PhrasingSlur #'stencil = ##f
    % 'tied to' fret numbers become invisible or parenthesized, respectively)
    \override Tie #'after-line-breaking = #tie::handle-tab-tie
    \override RepeatTie #'after-line-breaking = #repeat-tie::parenthesize-tab
    % ... and all kinds of markups, spanners etc.
    \override TupletBracket #'stencil = ##f
    \override TupletNumber #'stencil = ##f
    \override DynamicText #'transparent = ##t
    \override DynamicTextSpanner #'stencil = ##f
    \override TextSpanner #'stencil = ##f
    \override Hairpin #'transparent = ##t
    \override Script #'stencil = ##f
    \override TextScript #'stencil = ##f
    % the direction for glissando lines will be automatically corrected
    \override Glissando #'extra-dy = #glissando::calc-tab-extra-dy
    % dead notes in tablature and within chord constructs
    \override TabNoteHead #'glyph-name = #tab-note-head::calc-glyph-name
    \override TabNoteHead #'stencil = #tab-note-head::whiteout-if-style-set
  }
}

\version "2.13.3"
\include "tablature.ly"

% some stuff
bass = \relative c,, {
   e4 g a b
   b4 f g d'
   \bar "|."
}

\score {
   <<
      \new Staff { \clef "bass_8" \bass }
      \new TabStaff   { \clef "moderntab"
                        \set TabStaff.stringTunings = #bass-tuning
                        \bass }
   >>
}
12
Loading...