lilypond-user
[Top][All Lists]
Advanced

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

Re: tablature.ly


From: Marc Hohl
Subject: Re: tablature.ly
Date: Thu, 30 Apr 2009 09:36:17 +0200
User-agent: Thunderbird 2.0.0.21 (X11/20090318)

[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 ;-)
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)
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.
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.

How can I achieve this?
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


Thanks for your help!

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


% 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 }
   >>
}



reply via email to

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