[tablatures] Fwd: tablature.ly

[ Thread Index | Date Index | More lilynet.net/tablatures Archives ]


For archival purposes, I am forwarding to the tablatures list some
previous discussions that may have taken place privately or on the
LilyPond-user mailing list.

- Valentin


Forwarded conversation
Subject: tablature.ly
------------------------

From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/25
To: lilypond-user@xxxxxxx, "Carl D. Sorensen" <c_sorensen@xxxxxxx>,
David Stocker <dstocker@xxxxxxxxxxxxxxxxx>, Grammostola Rosea
<rosea.grammostola@xxxxxxxxx>


Hello tablature users*,

after some days of struggling with lilypond's internals, I have
created a file tablature.ly
which supports:

1) two commands to switch between the display style:
 \tabNumbersOnly shows only the mubers,
 \tabFullNotation shows up everything (as it is the default in
\TabVoice upto now)

2) two commands for the possible clefs:
 \calligraphicTabClef #<tuning>
 \sansSerifTabClef #<tuning>
 (I didn't like "modern" or "old" clef, so I used commands which
describe the apperance
 of the clefs).
 The sans serif clef is available for 4 to 7 strings. It internally sets
 \TabStaff.stringTunings to <tuning>.

3) some more tunings are defined:
 guitar-seven-string-tuning
 guitar-drop-d-tuning        bass-four-string-tuning
bass-drop-d-tuning        bass-five-string-tuning
bass-six-string-tuning
 (yes I know, the already defined "bass-tuning" is the same as my
"bass-four-string-tuning", but
  as I write music for various basses, this is easier to read at first glance.)

4) commandos for palm mute playing and dead notes are supported (palm
mute is not a tablature-specific
 issue, but as electric guitar players use tablature and often play
palm mute, I think this is ok).
 At first I thought of using \x for dead notes, but in other threads
\x is used for almost everything,
 so I leave it to the user to say x = \deadNotes and use \x for faster
typing myriads of dead notes :-)

I post this along with a test file, so you can check this out.

*Carl, which isn't really a tablature user, has given me a lot of
support an insight to lilypond,
and he proposed to include tablature.ly in future releases of
lilypond, so this would be the place to
go for further development (bendings, etc.). Establishing
\tabNumbersOnly as a standard would mean to
break with older versions, but as it is a single command, this should
not be considered as a serious
drawback.

As there are more people invoved in developing tablature extensions
for lilypond, I send tablature.ly
to this list for testing purposes, so changes, corrections etc. could
be discussed before establishing
the file in future versions. As I said before, it is just a starting
point, any suggestions, improvements
etc. are welcome. Are there other tunings we should consider being
defined internally?

Yet again, I would like to thank Carl for his great help and patience,
and as far as I can see now,
making contributions to lilypond is easier than one might think, there
are a lot of people outside
willing to help you, if you are willing to bring lilypond further on,
so give it a try!

Greetings,

Marc

% tablature.ly

% these definitions will be moved to scm/output-lib.scm
#(define-public guitar-seven-string-tuning '(4 -1 -5 -10 -15 -20 -25))
#(define-public guitar-drop-d-tuning       '(4 -1 -5 -10 -15 -22))
#(define-public bass-four-string-tuning    '(-17 -22 -27 -32))
#(define-public bass-drop-d-tuning         '(-17 -22 -27 -34))
#(define-public bass-five-string-tuning    '(-17 -22 -27 -32 -37))
#(define-public bass-six-string-tuning     '(-12 -17 -22 -27 -32 -37))



% some publications use the triangled note head
% for palm mute, so here we go:
palmMuteOn = { \set shapeNoteStyles = #'#(do do do do do do do ) }
palmMuteOff = { \unset shapeNoteStyles }
% for single notes (or groups of notes within { ...} :
palmMute =  #(define-music-function (parser location note) (ly:music?)
     #{
        \set shapeNoteStyles = #'#(do do do do do do do )
        $note
        \unset shapeNoteStyles
     #})

% x-tab-format uses a "x" instead of the fret number:
#(define (x-tab-format str context event)
   (make-whiteout-markup
     (make-vcenter-markup
       (markup #:musicglyph "noteheads.s2cross"))))

% dead notes are marked with a cross-shape note head,
% both in normal notation and in tablature:
deadNotesOn = {
  \override NoteHead #'style = #'cross
  \set tablatureFormat = #x-tab-format
}
deadNotesOff = {
  \unset tablatureFormat
  \revert NoteHead #'style
}
% for single notes or groups of notes within {...}:
deadNotes = #(define-music-function (parser location notes) (ly:music?)
  #{
     \override NoteHead #'style = #'cross
     \set tablatureFormat = #x-tab-format
     $notes
     \unset tablatureFormat
     \revert NoteHead #'style
  #})

% define sans serif-style tab-Clefs according to
% http://lsr.dsi.unimi.it/LSR/Item?id=323
% for 4, 5, 6 and 7 strings

#(define-markup-command (customTabClef layout props tuning) (pair?)
   (let* ((num-strings (length tuning))
          ;; the number of strings has to be in 4....7
          (num-strings (cond ((< num-strings 4) 4)
                             ((> num-strings 7) 7)
                             (else num-strings)))
          (raise-value (- (* num-strings 0.4) 0.9))
          (font-size (- (* num-strings 1.5) 7))
          (base-skip (cond ((= 4 num-strings) 1.55)
                           ((= 5 num-strings) 1.84)
                           ((= 6 num-strings)  2.00)
                           ((= 7 num-strings) 2.08)))
          (new-props (cons (list
                             '(font-family . sans)
                             (cons 'baseline-skip base-skip))
                            props)))
      (interpret-markup layout new-props
        (markup #:raise raise-value #:bold #:fontsize font-size
               #:column ("T" "A" "B")))))

% Wrappers for the different clefs
% the argument is the string-tuning, which is automatically set.
sansSerifTabClef = #(define-music-function (parser location tuning) (pair?)
  #{
     \override TabStaff.Clef #'stencil = #ly:text-interface::print
     \override TabStaff.Clef #'text = \markup \customTabClef $tuning
     \set TabStaff.stringTunings = $tuning
  #})

calligraphicTabClef = #(define-music-function (parser location tuning) (pair?)
  #{
     \revert TabStaff.Clef #'stencil
     \set TabStaff.stringTunings = $tuning
  #})

% commands for switching between tablature with numbers only...
tabNumbersOnly = {
  % no time signature
  \override TabStaff.TimeSignature #'stencil = ##f
  % no stems, beams, dots, ties and slurs
  \override TabVoice.Stem #'stencil = ##f
  \override TabVoice.Beam #'stencil = ##f
  \override TabVoice.Dots #'stencil = ##f
  \override TabVoice.Tie  #'stencil = ##f
  \override TabVoice.Slur #'stencil = ##f
  % no tuplet stuff
  \override TabVoice.TupletBracket #'stencil = ##f
  \override TabVoice.TupletNumber #'stencil = ##f
  % no dynamic signs, text spanners etc.
  \override DynamicText #'transparent = ##t
  \override DynamicTextSpanner #'stencil = ##f
  \override TextSpanner #'stencil = ##f
  \override Hairpin #'transparent = ##t
  % no rests
  \override TabVoice.Rest #'stencil = ##f
  \override TabVoice.MultiMeasureRest #'stencil = ##f
  % no markups
  \override TabVoice.Script #'stencil = ##f
  \override TabVoice.TextScript #'stencil = ##f
}
% and the full notation
tabFullNotation = {
  % time signature
  \revert TabStaff.TimeSignature #'stencil
  % stems, beams, dots
  \revert TabVoice.Stem #'stencil
  \revert TabVoice.Beam #'stencil
  \revert TabVoice.Dots #'stencil
  \revert TabVoice.Tie #'stencil
  \revert TabVoice.Slur #'stencil
  % tuplet stuff
  \revert TabVoice.TupletBracket #'stencil
  \revert TabVoice.TupletNumber #'stencil
  % dynamic signs
  \revert DynamicText #'transparent
  \override DynamicTextSpanner #'stencil = ##f
  \revert TabVoice.DynamicTextSpanner #'stencil
  \revert TabVoice.Hairpin #'transparent
  % rests
  \revert TabVoice.Rest #'stencil
  \revert TabVoice.MultiMeasureRest #'stencil
  % markups
  \revert TabVoice.Script #'stencil
  \revert TabVoice.TextScript #'stencil
}

\version "2.12.2"
\include "tablature.ly"

\markup {First, a lot of stuff as it is displayed both in notation and
in tablature.}

alotofstuff = {
  \time 3/4
  c4^"test" d( e)
  f4\f g a^\fermata
  c8\< c16 c ~ c2\!
  c'2.
  \mark \default
  R2.
  r4 d4 r8 r
  \times 3/4 { b4 c d c }
  c4. d-_( e\varcoda)
  ->f g~ a\prall g\thumb e-. f-. g-.
  \times 3/4 { b4 c d c }
  \bar "|."
}

\score {
  <<
     \new Staff \alotofstuff
     \new TabStaff \alotofstuff
  >>
}

\markup{When we invoke tabNumbersOnly, it looks better.}

\score {
  <<
     \new Staff \alotofstuff
     \new TabStaff   { \tabNumbersOnly \alotofstuff }
  >>
}

\markup{ tablature.ly supports an easy way to mark notes as played
palm mute-style...}

palmmute = \relative c, {
   \time 4/4
   e8^\markup { \musicglyph #"noteheads.u2do"  = palm mute }
\palmMuteOn e e \palmMuteOff  e e  \palmMute e e e
   e8 \palmMute { e e e } e e e e
   \palmMuteOn
   < e b' e>8 e e e <e b' e>2
   \bar "|."
}

\score {
  <<
     \new Staff { \clef "G_8" \palmmute }
     \new TabStaff  { \tabNumbersOnly
                      \calligraphicTabClef #guitar-tuning
                      \palmmute }
  >>
}

\markup {... or dead notes:}

deadnotes = \relative c,, {
  e8. \deadNotesOn e16 \deadNotesOff g4 a b
  e8. \deadNotes e16 g4 a b
  e,4. \deadNotes { e8 e e } e4
  \bar "|."
}

\score {
  <<
     \new Staff { \clef "bass_8" \deadnotes }
     \new TabStaff  { \tabNumbersOnly
                      \sansSerifTabClef #bass-four-string-tuning
                      \deadnotes }
  >>
}

\markup { The new sansSerifTab-Clef supports tablatures from 4 to 7 strings..}
% some stuff
bass = \relative c,, {
  e4 g a b
  b4 f g d'
  \bar "|."
}

% four strings, calculated clef
\score {
  <<
     \new Staff { \mark \markup{4 strings}
                  \clef "bass_8" \bass }
     \new TabStaff   { \tabNumbersOnly
                       \sansSerifTabClef #bass-four-string-tuning
                       \bass }
  >>
}

% five strings, calculated clef
\score {
  <<
     \new Staff { \mark \markup{5 strings}
                  \clef "bass_8" \bass }
     \new TabStaff   { \tabNumbersOnly
                       \sansSerifTabClef #bass-five-string-tuning
                       \bass }
  >>
}

guitar = \relative c {
  c4 d e f
  g4 a b c
  \bar "|."
}

% six strings, calculated clef
\score {
  <<
     \new Staff { \mark \markup{6 strings}
                  \clef "G_8" \guitar }
     \new TabStaff   { \tabNumbersOnly
                       \sansSerifTabClef #guitar-tuning
                       \guitar }
  >>
}

% seven strings, calculated clef
\score {
  <<
     \new Staff { \mark \markup{7 strings}
                  \clef "G_8" \guitar }
     \new TabStaff   { \tabNumbersOnly
                       \sansSerifTabClef #guitar-seven-string-tuning
                       \guitar }
  >>
}


_______________________________________________
lilypond-user mailing list
lilypond-user@xxxxxxx
http://lists.gnu.org/mailman/listinfo/lilypond-user


----------
From: Grammostola Rosea <rosea.grammostola@xxxxxxxxx>
Date: 2009/4/25
To:
Cc: lilypond-user@xxxxxxx


Wow, I am very happy about this! I'm gonna test it for sure.

Thanks Marc and Carl!

@David could you  make some progress with the bends and stuff?

Kind regards,

\r



_______________________________________________
lilypond-user mailing list
lilypond-user@xxxxxxx
http://lists.gnu.org/mailman/listinfo/lilypond-user

----------
From: Graham Percival <graham@xxxxxxxxxxxxxxxxx>
Date: 2009/4/25
To: Marc Hohl <marc@xxxxxxxxxx>
Cc: lilypond-user@xxxxxxx, "Carl D. Sorensen" <c_sorensen@xxxxxxx>


Fantastic work!  This is exactly the kind of thing I was hoping
would happen.  Not from a tab-specific viewpoint, but from a
general "getting more people involved in lilypond" standpoint.

I know Marc already knows this, but I want to add emphasis:

- this is a self-contained file; people who want test/use it just
 need to download it and add the \include.

- this requires ZERO compiling of lilypond.  Granted, some
 additions /will/ require C++ hacking... but a lot of things can
 be done in scheme only.

Cheers,
- Graham

----------
From: Jonathan Kulp <jonlancekulp@xxxxxxxxx>
Date: 2009/4/25
To: Grammostola Rosea <rosea.grammostola@xxxxxxxxx>
Cc: lilypond-user@xxxxxxx


Well done, Marc & Carl!  I don't use tab either, but I'm a guitarist
and appreciate the new features from that standpoint.

My only comment would be that whenever traditional staff and tabstaff
are presented together, it's best to use the "treble_8" clef for the
regular staff so that the notes appear in the right place on the
staff, the tab has the correct indications, and the midi output is in
the right octave.  I think there were only two examples in
tablature.ly that didn't use the "treble_8" clef for guitar. All the
other clefs (including the "bass_8" for bass guitar) were correct.

Thanks for the great work, guys!

Jon
--
Jonathan Kulp
http://www.jonathankulp.com
----------
From: Jonathan Kulp <jonlancekulp@xxxxxxxxx>
Date: 2009/4/25
To: Grammostola Rosea <rosea.grammostola@xxxxxxxxx>
Cc: lilypond-user@xxxxxxx


Sorry I meant to say in "tablature-test1.ly"
----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/25
To: Jonathan Kulp <jonlancekulp@xxxxxxxxx>
Cc: lilypond-user@xxxxxxx


Jonathan Kulp schrieb: Yes, you are right. In the first two lines, I
forgot the octaviation sign. But I think, this example will
never be played on a guitar ;-)

Marc
----------
From: Carl D. Sorensen <c_sorensen@xxxxxxx>
Date: 2009/4/25
To: Marc Hohl <marc@xxxxxxxxxx>, "lilypond-user@xxxxxxx"
<lilypond-user@xxxxxxx>, David Stocker <dstocker@xxxxxxxxxxxxxxxxx>,
Grammostola Rosea <rosea.grammostola@xxxxxxxxx>


Looks great, Marc!  *Very* nicely done.


On 4/25/09 4:06 AM, "Marc Hohl" <marc@xxxxxxxxxx> wrote:

> Hello tablature users*,
>
<SNIP>
As your comment indicates, you will want to move these to
scm/output-lib.scm.  When you are up to speed on git, please do so.

Once you send me a patch, I'll check it and push to git, and it will become
part of LilyPond.

Oh, by the way, you will want to make a standard LilyPond comment block at
the top of the file -- see existing files for a pattern.
This is exactly the right thing to do.  LilyPond defined functions should
always be descriptive.  If users want the convenience of defining a
shortcut, it's quite easy to do so.
You're very welcome.  It's always a pleasure to help somebody who is
learning to contribute!

Thanks,

Carl

----------
From: Neil Puttock <n.puttock@xxxxxxxxx>
Date: 2009/4/26
To: Marc Hohl <marc@xxxxxxxxxx>
Cc: lilypond-user@xxxxxxx, "Carl D. Sorensen" <c_sorensen@xxxxxxx>


2009/4/25 Marc Hohl <marc@xxxxxxxxxx>:
> Hello tablature users*,

Like Carl, I'm not a tablature user, so I can only comment on matters of coding.

Some suggestions and thoughts follow below:

> % some publications use the triangled note head
> % for palm mute, so here we go:
> palmMuteOn = { \set shapeNoteStyles = #'#(do do do do do do do ) }

You can use make-vector here, since every entry is the same symbol:

palmMuteOn = { \set shapeNoteStyles = #(make-vector 7 'do)

> palmMuteOff = { \unset shapeNoteStyles }
> % for single notes (or groups of notes within { ...} :
> palmMute =  #(define-music-function (parser location note) (ly:music?)
>      #{
>         \set shapeNoteStyles = #'#(do do do do do do do )
>         $note
>         \unset shapeNoteStyles
>      #})

You've just defined palmMuteOn/Off.  Why not use them here?

palmMute =  #(define-music-function (parser location note) (ly:music?)
     #{
        \palmMuteOn
        $note
        \palmMuteOff
     #})

> % for single notes or groups of notes within {...}:
> deadNotes = #(define-music-function (parser location notes) (ly:music?)
>   #{
>      \override NoteHead #'style = #'cross
>      \set tablatureFormat = #x-tab-format
>      $notes
>      \unset tablatureFormat
>      \revert NoteHead #'style
>   #})

As above, using deadNotesOn/Off.

> #(define-markup-command (customTabClef layout props tuning) (pair?)
>    (let* ((num-strings (length tuning))
>           ;; the number of strings has to be in 4...7
>           (num-strings (cond ((< num-strings 4) 4)
>                              ((> num-strings 7) 7)
>                              (else num-strings)))

This looks a bit strange, since you've just defined num-strings.  You
can use min and max to keep it within range:

(let* ((num-strings (min (max (length tuning) 4) 7))

>           (raise-value (- (* num-strings 0.4) 0.9))

You can junk this, since #:vcenter in the markup below will do it automatically.

>           (font-size (- (* num-strings 1.5) 7))
>           (base-skip (cond ((= 4 num-strings) 1.55)
>                            ((= 5 num-strings) 1.84)
>                            ((= 6 num-strings)  2.00)
>                            ((= 7 num-strings) 2.08)))

Can you rework these so they're not hard-coded?

Imagine a user doesn't like the default staff-space setting for
TabStaff (1.5).  If they change it, none of these empirical values
will work properly.

>           (new-props (cons (list
>                              '(font-family . sans)
>                              (cons 'baseline-skip base-skip))
>                             props)))
>       (interpret-markup layout new-props
>         (markup #:raise raise-value #:bold #:fontsize font-size
>                #:column ("T" "A" "B")))))

Do you want the TAB column left-aligned rather than centred (like the
LSR snippet)?

> % Wrappers for the different clefs
> % the argument is the string-tuning, which is automatically set.
> sansSerifTabClef = #(define-music-function (parser location tuning) (pair?)
>   #{
>      \override TabStaff.Clef #'stencil = #ly:text-interface::print

Use grob-interpret-markup instead of ly:text-interface::print:

\override TabStaff.Clef #'stencil = $(lambda (grob)
(grob-interpret-markup grob (make-customTabClef-markup tuning)))

The docs are slightly lagging behind here, but
ly:text-interface::print should only be used with objects which
support text-interface.

>      \override TabStaff.Clef #'text = \markup \customTabClef $tuning

Can be removed if using grob-interpret-markup.

> calligraphicTabClef = #(define-music-function (parser location tuning)
> (pair?)
>   #{
>      \revert TabStaff.Clef #'stencil
>      \set TabStaff.stringTunings = $tuning
>   #})

On a general note, I'd prefer to keep the string tunings separate from
setting the clef.  To set the traditional tab clef, we have the
command \clef tab, so it would be nice to be able to set the modern
style using e.g. \clef moderntab without having to use a new function.

Regards,
Neil

----------
From: Carl D. Sorensen <c_sorensen@xxxxxxx>
Date: 2009/4/27
To: Neil Puttock <n.puttock@xxxxxxxxx>, Marc Hohl <marc@xxxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>


Neil,

Thanks for your input.  I think it's all really good.
<SNIP>
Marc, there are probably at least two ways to do this.  The easiest one
would be to take each of these magic numbers and divide them by the default
staff-space setting, and then change to something like

(base-skip (cond ((= 4 num-strings) (* staff-space 1.03))

and so forth.  (1.03 = 1.55/1.5)  And you'd need to find the value of
staff-space in order to be able to do this multiplication.

The second way would be to try to define fundamental relationships for
base-skip, but I'm not sure exactly how you'd do that, so I'm not
recommending it right now.

<SNIP>
I'd also like to do that.  But I don't know how to help Marc do it.  Neil,
if you can help him figure it out, I'd appreciate it.

There are two issues that I can't address:

1) I wasn't able to figure out how to get stringTunings in a music function
or a markup function.   How do we do that?

2) I'm not sure how to use a markup, instead of a glyph, as a clef without
redefining the 'stencil property, and I don't know how to redefine the
'stencil property by means of  a \clef cleftype command.  If you can show us
how to do that, it would be really helpful.

Thanks for your help and insight,

Carl


Marc,

Can you revise your code according to Neil's recommendations and make me a
new patch?

Thanks,

Carl

----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/27
To: Neil Puttock <n.puttock@xxxxxxxxx>
Cc: lilypond-user@xxxxxxx, "Carl D. Sorensen" <c_sorensen@xxxxxxx>


Neil Puttock schrieb:
Thank you for your suggestions! As I am no expert in scheme, some things can
surely be done more elegant. I corrected my file as you suggested
above. Ok. That's a bigger problem: first, I used a definition as
shown in the LSR and played a bit with the
values for base-skip, font-size and raise. Here is my first attempt:

tabClefIV = \markup {
 \raise #0.7 {
  \override #'(font-family . sans)
  \bold\fontsize #-1.0
  \override #'(baseline-skip . 1.44)
  \column { "T" "A" "B" }
 }
}

I found out that the base-line for 4 ... 7 strings follows a quadratic equation:
base-skip = ( 0.2 * num-strings + 0.4 )**2
but inserting this into the definition of customTabClef didn't work, and neither
Carl nor I could nail down the problem, so finally, I hard-coded the values..

If you can help me with that, it would be great. Ok, #:column changed
to #:center-column, I simply have overlooked this. Ok, changed. Yes,
that would be better, but I didn't manage to get the information about
the number of strings internally, so I used the tuning as an argument.
Then, to avoid setting it twice, I wrote the wrappers.
On the other hand, I would have to set the tuning before setting \clef
moderntab,
but this could be easily mentioned in the docs.

As said above, any help for the base-skip problem and finding a way to
get the number of strings
without explicitly using the tuning as an argument are appreciated.

Thank you!

Marc
----------
From: Carl D. Sorensen <c_sorensen@xxxxxxx>
Date: 2009/4/27
To: Marc Hohl <marc@xxxxxxxxxx>, Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>


Marc, did you get the email from Robin Bannister?  He found the problem we
were having with customTabClef.  I had you put the baseline-skip override as
a cons to  the property list, instead of using it as an :override function,
and the :fontsize reset the baseline-skip.  That's why things weren't
working right.  I think the code below works with your original quadratic:

#(define-markup-command (customTabClef layout props) ()
  (define (square x) (* x x))
  (let* ((num-strings (length (chain-assoc-get 'stringTunings props '())))
         (base-skip (square (+ (* num-strings 0.2) 0.4)))
         (font-size (- (* num-strings 1.5) 7)))
   (interpret-markup layout props
            #:override #'(font-family . sans)
            #:fontsize font-size
            #:override #(cons 'baseline-skip base-skip)
            #:column ("T" "A" "B")))))
Here Neil points out the thing he's most concerned about.  It's not a
concern about the magic numbers per se, it's that they don't change with
staff-spacing.  In my earlier email (let me know if you didn't get it), I
asked for his help with that problem.
Thank you, too, Marc!

Carl

----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/27
To: "Carl D. Sorensen" <c_sorensen@xxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>


Carl D. Sorensen schrieb:
No, I didn't get this mail. I played around with your suggestions and the
improvements given by Neil and have now:

#(define-markup-command (customTabClef layout props tuning) (pair?)
      (base-skip (square (+ (* num-strings 0.2) 0.4))))
     (interpret-markup layout props
       (markup #:vcenter #:bold                #:center-column ("T" "A" "B")))))

The raise-value calculation has gone, because I use #:vcenter, but I
had to comment
out the font-family line, because I got an error saying "unbound
variable: font-family"
if it is in the source. What's going wrong here? With the definition
above, I inserted #(set-global-staff-size <num>)
and tried values from 10 to 100, and it worked as expected.
So the quadratic equation seems to be the right way.

Marc
----------
From: Carl D. Sorensen <c_sorensen@xxxxxxx>
Date: 2009/4/28
To: Marc Hohl <marc@xxxxxxxxxx>, Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>


I thought that there should be no ' before (cons 'baseline-skip base-skip).
But apparently it works, so perhaps it's evaluated during the markup
interpretation.

The ' is a quote that prevents evaluation.  In this case, we want to
evaluate the expression, because we want to replace the symbol base-skip
with its value, which was assigned above.  But this apparently works with
the macro expansion.
Try #'(cons 'font-family 'sans), and see if that will work.  It may be that
the way things are substituted by the macro expansion is causing it to work
differently than I would expect with straight Scheme.
OK, so the baseline skip is apparently sized in terms of staff spaces, which
means your equations are right.

Thanks,

----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/28
To: "Carl D. Sorensen" <c_sorensen@xxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>


Carl D. Sorensen schrieb:
>
> [snip]

Yes, it works. Great!
Thanks a lot, Carl.
----------
From: Neil Puttock <n.puttock@xxxxxxxxx>
Date: 2009/4/28
To: "Carl D. Sorensen" <c_sorensen@xxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>


2009/4/27 Carl D. Sorensen <c_sorensen@xxxxxxx>:
You don't need to know stringTunings, since it's possible to access
'line-count from any grob which is placed on a StaffSymbol:

(let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
      (line-count (ly:grob-property staff-symbol 'line-count)))
If we add entries in parser-clef.scm to supported-clefs and
c0-pitch-alist (either directly or by consing the new entries within
the tablature file) for the modern tab,

("moderntab" . ("markup.moderntab" 0 0))

("markup.moderntab" . 0)

we can override the Clef 'stencil to check 'glyph before calling the
default print-function.  If the string "markup.moderntab" is found,
then it's simple to return a stencil for the new tab markup.

There's one potential pitfall: it's expected that each clef type has a
variant at a smaller size which is obtained by appending "_change" to
the glyph-name.  You'd probably want to disable this feature by
setting 'full-size-change = ##t.

Regards,
Neil

----------
From: Neil Puttock <n.puttock@xxxxxxxxx>
Date: 2009/4/28
To: Marc Hohl <marc@xxxxxxxxxx>
Cc: lilypond-user@xxxxxxx, "Carl D. Sorensen" <c_sorensen@xxxxxxx>


2009/4/27 Marc Hohl <marc@xxxxxxxxxx>:
Glad to help. :)

You're doing fine with Scheme so far.
I've just remembered a quirk with this: you'll have to add
#:left-align before the #:center-column otherwise it causes a
misalignment with clefs in other staves.

----------
From: Neil Puttock <n.puttock@xxxxxxxxx>
Date: 2009/4/29
To: Marc Hohl <marc@xxxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>, "Carl D.
Sorensen" <c_sorensen@xxxxxxx>


2009/4/27 Marc Hohl <marc@xxxxxxxxxx>:
Too many hashes:

#:override '(font-family . sans) or #:override (cons 'font-family 'sans)

#:override (cons 'baseline-skip base-skip) or #:override
`(baseline-skip . ,base-skip)
That works because changing the global staff size doesn't alter the
default staff-space. See what happens when you add the following
override:

\override TabStaff.StaffSymbol #'staff-space = #1.2

Regards,
Neil

----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/29
To: Neil Puttock <n.puttock@xxxxxxxxx>
Cc: lilypond-user@xxxxxxx, "Carl D. Sorensen" <c_sorensen@xxxxxxx>


Neil Puttock schrieb: Ok, I have added this.

Marc
----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/29
To: Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>, "Carl D.
Sorensen" <c_sorensen@xxxxxxx>


Neil Puttock schrieb:
Ok, as Neil has posted somewhere else in this thread, the formula
works only with a
fixed staff-space. But I don't know how to find the value of staff-space.
I think it could be done similar to the proposals for the line-count
(see below), but this is far beyond my possibilities - any help is highly
appreciated! This is way beyond my knowledge of the internals. I
simply added these lines
accordingly in my definition of customTabClef:          (num-strings
(ly:grob-property staff-symbol 'line-count))          (base-skip
(square (+ (* num-strings 0.195) 0.4))))                #:override
#'(cons 'font-family 'sans)
               #:fontsize font-size
               #:override #'(cons 'baseline-skip base-skip)
               #:left-align but this doesn't work. Lilypond complains with

Unbound variable: grob

How can I assign the right value to this symbolic variable?

Marc
----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/29
To: Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>, "Carl D.
Sorensen" <c_sorensen@xxxxxxx>


Marc Hohl schrieb:
Arrrg, as soon as I have posted this mail, I came up with an idea:

#(define-markup-command (customTabClef layout props num-strings)
(integer?)   (let* ((font-size (- (* num-strings 1.5) 7))
sansSerifTabClef = #(define-music-function (parser location tuning)
(pair?)
 #{            (grob-interpret-markup grob (make-customTabClef-markup
line-count))))
    \set TabStaff.stringTunings = $tuning
 #})

And this worked!
So I'll try to figure out the rest... ( the $tuning-stuff has to be
removed, but just as a first attempt,
it worked).

Marc
----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/29
To: Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>, "Carl D.
Sorensen" <c_sorensen@xxxxxxx>


Marc Hohl schrieb:
So finally, before starting cooking for my family :-),
I came up with this:

#(define-markup-command (customTabClef layout props num-strings
staff-space) (integer? number?)   (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)))            (staff-space  (ly:grob-property
staff-symbol 'staff-space)))
           (grob-interpret-markup grob (make-customTabClef-markup
line-count staff-space))))
    \set TabStaff.stringTunings = $tuning
 #}) Here I need some help from the experts.

Greetings

Marc
----------
From: Carl D. Sorensen <c_sorensen@xxxxxxx>
Date: 2009/4/29
To: Marc Hohl <marc@xxxxxxxxxx>, Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>


See below for my comment.
This was meant to be applied along with Neil's earlier comment about
changing from using ly:text-interface::print for the 'stencil to using
grob-interpret-markup.  I've included his comments below:
When you define 'stencil to be a function of some object  (lambda(grob) is a
function with one parameter), LilyPond will call that function with the
parameter of the grob that is supposed to be printed -- in this case, the
clef.  So then, grob will exist and will have the capability of learning
about both 'line-count and 'staff-space.

If this doesn't point you in the right direction, please let me know.

Thanks again for doing this!

Carl

----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/4/30
To: Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>, "Carl D.
Sorensen" <c_sorensen@xxxxxxx>


[snip]

I have reworked my tablature.ly according to all suggestions and
improvements by Neil and Carl.

The modern tab clef seems to be scaling properly, I played a bit with
some values for staff-space,
and it looks now as it should be (at least in my opinion). I have
managed (with excessive help)
to get the staff-space and the line-count from the staff-symbol
property, so there is no more
need for explicitly using the tuning as an argument for the clef functions.
(And again, I have gained some more insight  in scheme and lilypond,
thank you both!)

As Neil proposed, it should be possible to code

\clef tab

for the current calligraphic clef, and to write

\clef moderntab

for the sans serif-style clef for compatibility's sake.

This issue is beyond my abilities, so I call desperately for help ;-)
I tried to cons these values, and I succeded (or at least it seemed to
me) for the
supported-clefs list, but not with the c0-pitch-alist
(see attached files and lilypond's error messages).
Is this list only locally defined, or am I missing something?

In my opinion, as tablature.ly is meant to be included by the user,
not by default,
the changings in these lists should be done within tablature.ly, if
this is possible. How can I achieve this? Thanks for your help!

Marc

%%%% tablature.ly
%%%%
%%%% source file of the GNU LilyPond music typesetter
%%%%
%%%% (c) 2009 Marc Hohl <marc@xxxxxxxxxx>


% some publications use the triangled note head
% for palm mute, so here we go:
palmMuteOn = { \set shapeNoteStyles = #(make-vector 7 do) }
palmMuteOff = { \unset shapeNoteStyles }
% for single notes (or groups of notes within { ...} :
palmMute =  #(define-music-function (parser location notes) (ly:music?)
     #{
        \palmMuteOn $notes \palmMuteOff
     #})

% x-tab-format uses a "x" instead of the fret number:
#(define (x-tab-format str context event)
   (make-whiteout-markup
     (make-vcenter-markup
       (markup #:musicglyph "noteheads.s2cross"))))

% dead notes are marked with a cross-shape note head,
% both in normal notation and in tablature:
deadNotesOn = {
  \override NoteHead #'style = #'cross
  \set tablatureFormat = #x-tab-format
}
deadNotesOff = {
  \unset tablatureFormat
  \revert NoteHead #'style
}
% for single notes or groups of notes within {...}:
deadNotes = #(define-music-function (parser location notes) (ly:music?)
  #{
     \deadNotesOn  $notes \deadNotesOff
  #})
%
%
% for testing purposes only
#(display "supported-clefs before:")
#(newline)
#(display supported-clefs)
#(newline)
#(display "c0-pitch-alist before:")
#(newline)
#(display c0-pitch-alist)
#(newline)
#(define-public supported-clefs (cons '("moderntab" .
("markup.moderntab" 0 0)) supported-clefs))
#(define c0-pitch-alist (cons '("markup.moderntab" . 0) c0-pitch-alist))
#(display "supported-clefs after:")
#(newline)
#(display supported-clefs)
#(newline)
#(display "c0-pitch-alist after:")
#(newline)
#(display c0-pitch-alist)
#(newline)
% 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)))
          ;;(display "font-size:")(display font-size)(newline)
      (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")))))

% Wrappers for the different clefs
% the argument is the string-tuning, which is automatically set.
sansSerifTabClef = #(define-music-function (parser location) ()
  #{
     \override TabStaff.Clef #'stencil = $(lambda (grob)
     (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)))
            (grob-interpret-markup grob (make-customTabClef-markup
line-count staff-space))))
     \override TabStaff.Clef #'full-size-change = ##t
  #})

calligraphicTabClef = #(define-music-function (parser location) ()
  #{
     \revert TabStaff.Clef #'stencil
     \revert TabStaff.Clef #'full-size-change
  #})

% commands for switching between tablature with numbers only...
tabNumbersOnly = {
  % no time signature
  \override TabStaff.TimeSignature #'stencil = ##f
  % no stems, beams, dots, ties and slurs
  \override TabVoice.Stem #'stencil = ##f
  \override TabVoice.Beam #'stencil = ##f
  \override TabVoice.Dots #'stencil = ##f
  \override TabVoice.Tie  #'stencil = ##f
  \override TabVoice.Slur #'stencil = ##f
  % no tuplet stuff
  \override TabVoice.TupletBracket #'stencil = ##f
  \override TabVoice.TupletNumber #'stencil = ##f
  % no dynamic signs, text spanners etc.
  \override DynamicText #'transparent = ##t
  \override DynamicTextSpanner #'stencil = ##f
  \override TextSpanner #'stencil = ##f
  \override Hairpin #'transparent = ##t
  % no rests
  \override TabVoice.Rest #'stencil = ##f
  \override TabVoice.MultiMeasureRest #'stencil = ##f
  % no markups
  \override TabVoice.Script #'stencil = ##f
  \override TabVoice.TextScript #'stencil = ##f
}
% and the full notation
tabFullNotation = {
  % time signature
  \revert TabStaff.TimeSignature #'stencil
  % stems, beams, dots
  \revert TabVoice.Stem #'stencil
  \revert TabVoice.Beam #'stencil
  \revert TabVoice.Dots #'stencil
  \revert TabVoice.Tie #'stencil
  \revert TabVoice.Slur #'stencil
  % tuplet stuff
  \revert TabVoice.TupletBracket #'stencil
  \revert TabVoice.TupletNumber #'stencil
  % dynamic signs
  \revert DynamicText #'transparent
  \override DynamicTextSpanner #'stencil = ##f
  \revert TabVoice.DynamicTextSpanner #'stencil
  \revert TabVoice.Hairpin #'transparent
  % rests
  \revert TabVoice.Rest #'stencil
  \revert TabVoice.MultiMeasureRest #'stencil
  % markups
  \revert TabVoice.Script #'stencil
  \revert TabVoice.TextScript #'stencil
}

\version "2.12.2"
\include "tablature.ly"

% these definitions will be moved to scm/output-lib.scm
#(define-public guitar-seven-string-tuning '(4 -1 -5 -10 -15 -20 -25))
#(define-public guitar-drop-d-tuning       '(4 -1 -5 -10 -15 -22))
#(define-public bass-four-string-tuning    '(-17 -22 -27 -32))
#(define-public bass-drop-d-tuning         '(-17 -22 -27 -34))
#(define-public bass-five-string-tuning    '(-17 -22 -27 -32 -37))
#(define-public bass-six-string-tuning     '(-12 -17 -22 -27 -32 -37))


\markup { The new sansSerifTab-Clef supports tablatures from 4 to 7 strings..}
% some stuff
bass = \relative c,, {
  e4 g a b
  b4 f g d'
  \bar "|."
}

% four strings, calculated clef
\score {
  <<
     \new Staff      { \mark \markup{4 strings}
                       \clef "bass_8" \bass }
     \new TabStaff   { \tabNumbersOnly
                       \set TabStaff.stringTunings = #bass-four-string-tuning
                       \sansSerifTabClef
                       \bass }
  >>
}

% five strings, calculated clef
\score {
  <<
     \new Staff      { \mark \markup{5 strings}
                       \clef "bass_8" \bass }
     \new TabStaff   { \tabNumbersOnly
                       \set TabStaff.stringTunings = #bass-five-string-tuning
                       \sansSerifTabClef
                       \bass }
  >>
}

% five strings, staff-space =3.0
\score {
  <<
     \new Staff      { \mark \markup{5 strings, Staff space 2.5}
                       \clef "bass_8" \bass }
     \new TabStaff   { \tabNumbersOnly \override TabStaff.StaffSymbol
#'staff-space = #2.5
                       \set TabStaff.stringTunings = #bass-five-string-tuning
                       \sansSerifTabClef
                       \bass }
  >>
}

guitar = \relative c {
  c4 d e f
  g4 a b c
  \bar "|."
}

% six strings, calculated clef
\score {
  <<
     \new Staff      { \mark \markup{6 strings}
                       \clef "G_8" \guitar }
     \new TabStaff   { \tabNumbersOnly
                       \set TabStaff.stringTunings = #guitar-tuning
                       \sansSerifTabClef
                       \guitar }
  >>
}

% six strings, staff-space = 2
\score {
  <<
     \new Staff      { \mark \markup{6 strings, Staff space 2.0}
                       \clef "G_8" \guitar }
     \new TabStaff   { \tabNumbersOnly  \override TabStaff.StaffSymbol
#'staff-space = #2.0
                       \set TabStaff.stringTunings = #guitar-tuning
                       \sansSerifTabClef
                       \guitar }
  >>
}

% seven strings, calculated clef
\score {
  <<
     \new Staff      { \mark \markup{7 strings}
                       \clef "G_8" \guitar }
     \new TabStaff   { \tabNumbersOnly
                       \set TabStaff.stringTunings = #guitar-seven-string-tuning
                       \sansSerifTabClef
                       \guitar }
  >>
}

% seven strings, staff-space = 1.2
\score {
  <<
     \new Staff      { \mark \markup{7 strings, Staff-space 1.2}
                       \clef "G_8" \guitar }
     \new TabStaff   { \tabNumbersOnly \override TabStaff.StaffSymbol
#'staff-space = #1.2
                       \set TabStaff.stringTunings = #guitar-seven-string-tuning
                       \sansSerifTabClef
                       \guitar }
  >>
}

% seven strings, staff-space = 0.9
\score {
  <<
     \new Staff      { \mark \markup{7 strings, Staff-space 0.9}
                       \clef "G_8" \guitar }
     \new TabStaff   { \tabNumbersOnly \override TabStaff.StaffSymbol
#'staff-space = #0.9
                       \set TabStaff.stringTunings = #guitar-seven-string-tuning
                       \sansSerifTabClef
                       \guitar }
  >>
}



_______________________________________________
lilypond-user mailing list
lilypond-user@xxxxxxx
http://lists.gnu.org/mailman/listinfo/lilypond-user


----------
From: Carl D. Sorensen <c_sorensen@xxxxxxx>
Date: 2009/4/30
To: Marc Hohl <marc@xxxxxxxxxx>, Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>


You are correct.  c0-pitch-alist is not public.  So it's currently not
possible to cons a value in with the tablature.ly file.

Your choices at this point are to
a) change the scm/parser-clef.scm file to (define-public c0-pitch-alist .....
and keep the additions to the clef list in tablature.ly

b) hardcode the changes to supported-clefs and c0-pitch-alist in
scm/parser-clef.scm

c) add a scheme function (define-public (add-new-clef clef-name) ....)
to scm/parser-clef.scm.  This function would cons the new clef values onto
both lists.  And because the function is defined in scm/parser-clef.scm, it
will have access to c0-pitch-alist.  Then you would revise tablature.ly to
call add-new-clef to take care of things.

My recommendation is that you pursue option c.  The disadvantage of pursuing
option c is that it won't be available to others until a new release of
LilyPond is issued.

However, the existing tablature.ly file that you posted to the list works
for 2.12, so that will meet the needs of those users.  And you will have
made the changes to scm/parser-clef.scm on your system, so you'll have it
available for your use.  And you can post a patch that those who are
interested can use to make changes to their own version of
scm/parser-clef.scm.

All in all, I'd say go ahead with the new function in scm/parser-clef.scm
and modify tablature.ly to work with the new function.
You can also think about splitting tablature.ly into tablature-init.ly which
will be always be run, and tablature.ly which will only be run if the user
includes it.  That's the way predefined-fretboards works.
Define a new Scheme function to be used as the Clef 'stencil property

(define (newClefPrint grob) ....)

It should check for the 'glyph property of the grob, and if it's
markup.moderntab, it will call the new tab markup function.  Otherwise, it
will call (ly:clef::print grob).


Hope this helps,

----------
From: Neil Puttock <n.puttock@xxxxxxxxx>
Date: 2009/4/30
To: "Carl D. Sorensen" <c_sorensen@xxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>


2009/4/30 Carl D. Sorensen <c_sorensen@xxxxxxx>:
Oops. :)

Sorry Marc, I didn't notice that.  I ran a quick test by amending
parser-clef.scm, so I hadn't actually tried consing values.
I agree, that seems the best option for the moment.

At a later date, we might consider moving the clef callbacks in
clef.cc to scheme completely, so you'd be able to incorporate the
conditional code for modern tabs directly into the clef::print
callback.
I suggest something like `clef::print-modern-tab-if-set' to follow
LilyPond coding style.
Two further points:

Just to be on the safe side, when retrieving 'staff-space, a default
value should be given, since it's not normally set:

(ly:grob-property grob 'staff-space 1)

As I mentioned previously, unless you want to code a smaller clef for
changes, you'll want to set 'full-size-change = ##t.  This will shut
up any complaints about missing a glyph for "markup.moderntab_change".
 You can set it within the new stencil callback using
ly:grob-set-property!:

(ly:grob-set-property! grob 'full-size-change #t)

Regards,
Neil


----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/5/2
To: Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>, "Carl D.
Sorensen" <c_sorensen@xxxxxxx>


Thank you, Carl and Neil, for your answers.

Neil Puttock schrieb: Never mind. It is kind of reassuring to see that
making mistakes is not
completely my domain ;-) Ok, so I inserted the following lines in my
scm/parser-clef.scm:

;; a function to add new clefs at runtime
(define-public (add-new-clef clef-name clef-glyph clef-position
octaviation c0-position)
 "Append the entries for a clef symbol to supported clefs and c0-pitch-alist"
 (set! supported-clefs
      (acons clef-name (list clef-glyph clef-position octaviation)
supported-clefs))
 (set! c0-pitch-alist
      (acons clef-glyph c0-position c0-pitch-alist)))

[ I don't know if everything is correct, see below, but when
everything works, I'll send patches.] I tried to follow your
suggestions, and after some trial and error, I have
rearranged my tablature.ly as follows (see attachment):

#(add-new-clef "moderntab" "markup.moderntab" 0 0 0)

% this function decides which clef to take
#(define (clef::print-modern-tab-if-set grob)
  (let* ((glyph (ly:grob-property grob 'glyph)))
        (if (eq? glyph "markup.moderntab")
            (ly:modern-tab-clef::print grob)
            (ly:clef::print grob))))


#(define (ly:modern-tab-clef::print grob)            (staff-space
(ly:grob-property staff-symbol 'staff-space)))
           (grob-interpret-markup grob (make-customTabClef-markup
line-count staff-space)))) Is this line placed properly? I don't
understand this quite right, does this line
define the default value if 'staff-space is not set at all and doesn't
override 'staff-space
if it s set before? Where have I to put this? I surely want changes to
be enabled for the standard clefs,
so I have to put it after the comparison for "markup.moderntab". On
the other hand,
when it's put too late, then 'glyph has the value
"markup.moderntab_change", so the test for
"markup.moderntab" will fail.

And a final question:
I put the override for the TabStaff.Clef #'stencil into \tabNumbersOnly resp.
\tabFullNotation, so if the user doesn't call one of these commands, the clef
selection mechanism won't work. Is there a workaround, or - even better -
can \tabNumbersOnly be invoked automatically when tablature.ly is included?
This doesn't alter the defaults for older files but would give the
desired functionality
(i.e. numbers only) for tablature users.

Anyway, when I put all the pieces together, lilypond still complains
about not finding
"markup.moderntab", so I have made some mistakes.
Sorry to occupy your time so much, it is hard for me to learn basic
scheme and lilypond's internal
mechanisms at the same time, but in every mail, everything gets a bit
clearer ;-)
%%%% tablature.ly
%%%%
%%%% source file of the GNU LilyPond music typesetter
%%%%
%%%% (c) 2009 Marc Hohl <marc@xxxxxxxxxx>


% some publications use the triangled note head
% for palm mute, so here we go:
palmMuteOn = { \set shapeNoteStyles = #(make-vector 7 do) }
palmMuteOff = { \unset shapeNoteStyles }
% for single notes (or groups of notes within { ...} :
palmMute =  #(define-music-function (parser location notes) (ly:music?)
     #{
        \palmMuteOn $notes \palmMuteOff
     #})

% x-tab-format uses a "x" instead of the fret number:
#(define (x-tab-format str context event)
   (make-whiteout-markup
     (make-vcenter-markup
       (markup #:musicglyph "noteheads.s2cross"))))

% dead notes are marked with a cross-shape note head,
% both in normal notation and in tablature:
deadNotesOn = {
  \override NoteHead #'style = #'cross
  \set tablatureFormat = #x-tab-format
}
deadNotesOff = {
  \unset tablatureFormat
  \revert NoteHead #'style
}
% for single notes or groups of notes within {...}:
deadNotes = #(define-music-function (parser location notes) (ly:music?)
  #{
     \deadNotesOn  $notes \deadNotesOff
  #})
%
% the "moderntab" clef will be added to the list of known clefs:
#(add-new-clef "moderntab" "markup.moderntab" 0 0 0)

% this function decides which clef to take
#(define (clef::print-modern-tab-if-set grob)
   (let* ((glyph (ly:grob-property grob 'glyph)))
         (if (eq? glyph "markup.moderntab")
             (ly:modern-tab-clef::print grob)
             (ly:clef::print grob))))


#(define (ly:modern-tab-clef::print grob)
  (ly:grob-property grob 'staff-space 1)
  (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)))
            (grob-interpret-markup grob (make-customTabClef-markup
line-count staff-space))))
% 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")))))

% commands for switching between tablature with numbers only...
tabNumbersOnly = {
  % no time signature
  \override TabStaff.TimeSignature #'stencil = ##f
  % no stems, beams, dots, ties and slurs
  \override TabVoice.Stem #'stencil = ##f
  \override TabVoice.Beam #'stencil = ##f
  \override TabVoice.Dots #'stencil = ##f
  \override TabVoice.Tie  #'stencil = ##f
  \override TabVoice.Slur #'stencil = ##f
  % no tuplet stuff
  \override TabVoice.TupletBracket #'stencil = ##f
  \override TabVoice.TupletNumber #'stencil = ##f
  % no dynamic signs, text spanners etc.
  \override DynamicText #'transparent = ##t
  \override DynamicTextSpanner #'stencil = ##f
  \override TextSpanner #'stencil = ##f
  \override Hairpin #'transparent = ##t
  % no rests
  \override TabVoice.Rest #'stencil = ##f
  \override TabVoice.MultiMeasureRest #'stencil = ##f
  % no markups
  \override TabVoice.Script #'stencil = ##f
  \override TabVoice.TextScript #'stencil = ##f
  % the clef handler
  \override TabStaff.Clef #'stencil = #clef::print-modern-tab-if-set
}
% and the full notation
tabFullNotation = {
  % time signature
  \revert TabStaff.TimeSignature #'stencil
  % stems, beams, dots
  \revert TabVoice.Stem #'stencil
  \revert TabVoice.Beam #'stencil
  \revert TabVoice.Dots #'stencil
  \revert TabVoice.Tie #'stencil
  \revert TabVoice.Slur #'stencil
  % tuplet stuff
  \revert TabVoice.TupletBracket #'stencil
  \revert TabVoice.TupletNumber #'stencil
  % dynamic signs
  \revert DynamicText #'transparent
  \override DynamicTextSpanner #'stencil = ##f
  \revert TabVoice.DynamicTextSpanner #'stencil
  \revert TabVoice.Hairpin #'transparent
  % rests
  \revert TabVoice.Rest #'stencil
  \revert TabVoice.MultiMeasureRest #'stencil
  % markups
  \revert TabVoice.Script #'stencil
  \revert TabVoice.TextScript #'stencil
  % the clef handler
  \override TabStaff.Clef #'stencil = #clef::print-modern-tab-if-set
}
\version "2.12.2"
\include "tablature.ly"

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

% four strings, calculated clef
\score {
  <<
     \new Staff      { \clef "bass_8" \bass }
     \new TabStaff   { %\tabNumbersOnly
                       \set TabStaff.stringTunings = #bass-tuning
                       \clef tab
                       \bass }
  >>
}

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

%
_______________________________________________
lilypond-user mailing list
lilypond-user@xxxxxxx
http://lists.gnu.org/mailman/listinfo/lilypond-user


----------
From: Neil Puttock <n.puttock@xxxxxxxxx>
Date: 2009/5/2
To: Marc Hohl <marc@xxxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>, "Carl D.
Sorensen" <c_sorensen@xxxxxxx>


2009/5/2 Marc Hohl <marc@xxxxxxxxxx>:
That looks fine.  I'd just suggest changing `octaviation' to `octavation'.
You can't compare strings using eq?; try equal? or (more idiomatic
since we know 'glyph is a string) string=?
I don't think it's necessary to split this out of the function above.

Also, `ly:' is reserved for Scheme functions which have been exported
from the C++ source.
I mean add `1' to the the following line:

(staff-space (ly:grob-property staff-symbol 'staff-space 1)

If 'staff-space can't be found, i.e., it's not set, then
ly:grob-property will return the default value instead.
Actually, you can forget this, since it seem to work fine without
overriding 'full-size-change.
You could place all the default overrides inside a \layout block, in
the same manner as the settings for TabVoice are done in
engraver-init.ly.
Only the string matching, so you've done really well all things considered.

----------
From: Marc Hohl <marc@xxxxxxxxxx>
Date: 2009/5/3
To: Neil Puttock <n.puttock@xxxxxxxxx>
Cc: "lilypond-user@xxxxxxx" <lilypond-user@xxxxxxx>, "Carl D.
Sorensen" <c_sorensen@xxxxxxx>


Neil Puttock schrieb: Ups, that's a "germanism". In Germay, we say
"Oktavierung" and even "Tabulatur", so
I have to look more carefully in the future. Ok, I didn't know that.
Ah, now this makes sense to me.
Thank you for your help, I will write a new example file and send all
patches and stuff to Carl when I'm ready for it.

Marc



--
Regards,
Valentin
%%%% tablature.ly
%%%%
%%%% source file of the GNU LilyPond music typesetter
%%%%
%%%% (c) 2009 Marc Hohl <marc@xxxxxxxxxx>


% some publications use the triangled note head 
% for palm mute, so here we go:
palmMuteOn = { \set shapeNoteStyles = #(make-vector 7 do) }
palmMuteOff = { \unset shapeNoteStyles }
% for single notes (or groups of notes within { ...} :
palmMute =  #(define-music-function (parser location notes) (ly:music?)
      #{
         \palmMuteOn $notes \palmMuteOff
      #})

% x-tab-format uses a "x" instead of the fret number:
#(define (x-tab-format str context event)
    (make-whiteout-markup
      (make-vcenter-markup
        (markup #:musicglyph "noteheads.s2cross"))))

% dead notes are marked with a cross-shape note head,
% both in normal notation and in tablature:
deadNotesOn = {
   \override NoteHead #'style = #'cross
   \set tablatureFormat = #x-tab-format
}
deadNotesOff = {
   \unset tablatureFormat
   \revert NoteHead #'style
}
% for single notes or groups of notes within {...}:
deadNotes = #(define-music-function (parser location notes) (ly:music?)
   #{
      \deadNotesOn  $notes \deadNotesOff
   #})
%
% the "moderntab" clef will be added to the list of known clefs:
#(add-new-clef "moderntab" "markup.moderntab" 0 0 0)

% this function decides which clef to take
#(define (clef::print-modern-tab-if-set grob)
    (let* ((glyph (ly:grob-property grob 'glyph)))
          (if (eq? glyph "markup.moderntab")
              (ly:modern-tab-clef::print grob)
              (ly:clef::print grob))))


#(define (ly:modern-tab-clef::print grob)
   (ly:grob-property grob 'staff-space 1)
   (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)))
             (grob-interpret-markup grob (make-customTabClef-markup line-count staff-space))))
% 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")))))

% commands for switching between tablature with numbers only...
tabNumbersOnly = {
   % no time signature
   \override TabStaff.TimeSignature #'stencil = ##f
   % no stems, beams, dots, ties and slurs
   \override TabVoice.Stem #'stencil = ##f
   \override TabVoice.Beam #'stencil = ##f
   \override TabVoice.Dots #'stencil = ##f
   \override TabVoice.Tie  #'stencil = ##f
   \override TabVoice.Slur #'stencil = ##f
   % no tuplet stuff
   \override TabVoice.TupletBracket #'stencil = ##f
   \override TabVoice.TupletNumber #'stencil = ##f
   % no dynamic signs, text spanners etc.
   \override DynamicText #'transparent = ##t 
   \override DynamicTextSpanner #'stencil = ##f
   \override TextSpanner #'stencil = ##f
   \override Hairpin #'transparent = ##t
   % no rests
   \override TabVoice.Rest #'stencil = ##f
   \override TabVoice.MultiMeasureRest #'stencil = ##f
   % no markups
   \override TabVoice.Script #'stencil = ##f
   \override TabVoice.TextScript #'stencil = ##f
   % the clef handler
   \override TabStaff.Clef #'stencil = #clef::print-modern-tab-if-set
}
% and the full notation
tabFullNotation = {
   % time signature
   \revert TabStaff.TimeSignature #'stencil
   % stems, beams, dots
   \revert TabVoice.Stem #'stencil
   \revert TabVoice.Beam #'stencil
   \revert TabVoice.Dots #'stencil
   \revert TabVoice.Tie #'stencil
   \revert TabVoice.Slur #'stencil
   % tuplet stuff
   \revert TabVoice.TupletBracket #'stencil
   \revert TabVoice.TupletNumber #'stencil
   % dynamic signs
   \revert DynamicText #'transparent
   \override DynamicTextSpanner #'stencil = ##f
   \revert TabVoice.DynamicTextSpanner #'stencil
   \revert TabVoice.Hairpin #'transparent
   % rests
   \revert TabVoice.Rest #'stencil
   \revert TabVoice.MultiMeasureRest #'stencil
   % markups
   \revert TabVoice.Script #'stencil
   \revert TabVoice.TextScript #'stencil
   % the clef handler
   \override TabStaff.Clef #'stencil = #clef::print-modern-tab-if-set
}
\version "2.12.2"
\include "tablature.ly"

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

% four strings, calculated clef
\score {
   <<
      \new Staff      { \clef "bass_8" \bass }
      \new TabStaff   { %\tabNumbersOnly
                        \set TabStaff.stringTunings = #bass-tuning
                        \clef tab
                        \bass }
   >>
}

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

%


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/