;;;;
;;;; LilyPond is free software: you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;;
;;;; LilyPond is free software: you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
(define-public (tab-note-head::whiteout-if-style-set grob)
(let ((style (ly:grob-property grob 'style)))
(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))
- (tab-note-head::print grob))))
+ (case style
+ ((cross slash) (stencil-whiteout (ly:note-head::print grob)))
+ (else (tab-note-head::print grob)))))
;; definitions for the "moderntab" clef:
;; the "moderntab" clef will be added to the list of known clefs,
;; definitions for the "moderntab" clef:
;; the "moderntab" clef will be added to the list of known clefs,
;; if it is "moderntab", we'll draw it
(let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
(line-count (if (ly:grob? staff-symbol)
;; if it is "moderntab", we'll draw it
(let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
(line-count (if (ly:grob? staff-symbol)
(staff-space (ly:staff-symbol-staff-space grob)))
(grob-interpret-markup grob (make-customTabClef-markup line-count
(staff-space (ly:staff-symbol-staff-space grob)))
(grob-interpret-markup grob (make-customTabClef-markup line-count
;; (dotted) half notes to distinguish them from quarter notes:
(define-public (tabvoice::make-double-stem-width-for-half-notes grob)
(let ((X-extent (ly:stem::width grob)))
;; (dotted) half notes to distinguish them from quarter notes:
(define-public (tabvoice::make-double-stem-width-for-half-notes grob)
(let ((X-extent (ly:stem::width grob)))
-
- ;; is the note a (dotted) half note?
- (if (= 1 (ly:grob-property grob 'duration-log))
- ;; yes -> return double stem width
- (cons (car X-extent) (+ 0.5 (* 2 (cdr X-extent))))
- ;; no -> return simple stem width
- X-extent)))
+ ;; does the stem exist and is it on a (dotted) half note?
+ (if (and (not (equal? X-extent empty-interval))
+ (= 1 (ly:grob-property grob 'duration-log)))
+
+ ;; yes -> return double stem X-extent
+ (let* ((single-stem-width (- (cdr X-extent) (car X-extent)))
+ (separation (ly:grob-property grob 'double-stem-separation 0.5))
+ (total-width (+ single-stem-width separation))
+ (half-width (/ total-width 2)))
+ (cons (- half-width) half-width))
+ ;; no -> return simple stem X-extent
+ X-extent)))
- (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)))
+ (let ((stem-stencil (ly:stem::print grob)))
+ ;; does the stem exist and is it on a (dotted) half note?
+ (if (and (ly:stencil? stem-stencil)
+ (= 1 (ly:grob-property grob 'duration-log)))
+
+ ;; yes -> draw double stem
+ (let* ((separation (ly:grob-property grob 'double-stem-separation 0.5))
+ (half-separation (/ separation 2)))
+ (ly:stencil-add
+ (ly:stencil-translate-axis stem-stencil (- half-separation) X)
+ (ly:stencil-translate-axis stem-stencil half-separation X)))
+ ;; no -> draw simple stem (or none at all)
+ stem-stencil)))
;; as default, the glissando line between fret numbers goes
;; upwards, here we have a function to correct this behavior:
;; as default, the glissando line between fret numbers goes
;; upwards, here we have a function to correct this behavior:
(left-pitch (ly:event-property (event-cause left-bound) 'pitch))
(right-pitch (ly:event-property (event-cause right-bound) 'pitch)))
(left-pitch (ly:event-property (event-cause left-bound) 'pitch))
(right-pitch (ly:event-property (event-cause right-bound) 'pitch)))
(ly:grob-set-property! tied-tab-note-head 'stencil tab-note-head::print)))
;; tab note head is invisible
(ly:grob-set-property! tied-tab-note-head 'stencil tab-note-head::print)))
;; tab note head is invisible
(tab-note-head-visible (assoc-get 'note-head-visible repeat-tied-properties #t))
(tab-note-head-parenthesized (assoc-get 'parenthesize repeat-tied-properties #t)))
(tab-note-head-visible (assoc-get 'note-head-visible repeat-tied-properties #t))
(tab-note-head-parenthesized (assoc-get 'parenthesize repeat-tied-properties #t)))
- (if tab-note-head-visible
- ;; tab note head is visible
- (if tab-note-head-parenthesized
- (begin
- (ly:grob-set-property! tied-tab-note-head 'display-cautionary #t)
- (ly:grob-set-property! tied-tab-note-head 'stencil tab-note-head::print)))
- ;; tab note head is invisible
- (ly:grob-set-property! tied-tab-note-head 'transparent #t))))))
+ (if tab-note-head-visible
+ ;; tab note head is visible
+ (if tab-note-head-parenthesized
+ (begin
+ (ly:grob-set-property! tied-tab-note-head 'display-cautionary #t)
+ (ly:grob-set-property! tied-tab-note-head 'stencil tab-note-head::print)))
+ ;; tab note head is invisible
+ (ly:grob-set-property! tied-tab-note-head 'transparent #t))))))
;; the slurs should not be too far apart from the corresponding fret number, so
;; we move the slur towards the TabNoteHeads; moreover, if the left fret number is
;; the slurs should not be too far apart from the corresponding fret number, so
;; we move the slur towards the TabNoteHeads; moreover, if the left fret number is
(define-public (tab-note-head::print grob)
(define (is-harmonic? grob)
(let ((arts (ly:event-property (event-cause grob) 'articulations)))
(or (pair? (filter (lambda (a)
(define-public (tab-note-head::print grob)
(define (is-harmonic? grob)
(let ((arts (ly:event-property (event-cause grob) 'articulations)))
(or (pair? (filter (lambda (a)
- (details (ly:grob-property grob 'details '()))
- (harmonic-props (assoc-get 'harmonic-properties details '()))
- (harmonic-angularity (assoc-get 'angularity harmonic-props 2))
- (harmonic-half-thick (assoc-get 'half-thickness harmonic-props 0.075))
- (harmonic-padding (assoc-get 'padding harmonic-props 0))
- (harmonic-proc (assoc-get 'procedure harmonic-props parenthesize-stencil))
- (harmonic-width (assoc-get 'width harmonic-props 0.25))
- (cautionary-props (assoc-get 'cautionary-properties details '()))
- (cautionary-angularity (assoc-get 'angularity cautionary-props 2))
- (cautionary-half-thick (assoc-get 'half-thickness cautionary-props 0.075))
- (cautionary-padding (assoc-get 'padding cautionary-props 0))
- (cautionary-proc (assoc-get 'procedure cautionary-props parenthesize-stencil))
- (cautionary-width (assoc-get 'width cautionary-props 0.25))
+ (details (ly:grob-property grob 'details '()))
+ (harmonic-props (assoc-get 'harmonic-properties details '()))
+ (harmonic-angularity (assoc-get 'angularity harmonic-props 2))
+ (harmonic-half-thick (assoc-get 'half-thickness harmonic-props 0.075))
+ (harmonic-padding (assoc-get 'padding harmonic-props 0))
+ (harmonic-proc (assoc-get 'procedure harmonic-props parenthesize-stencil))
+ (harmonic-width (assoc-get 'width harmonic-props 0.25))
+ (cautionary-props (assoc-get 'cautionary-properties details '()))
+ (cautionary-angularity (assoc-get 'angularity cautionary-props 2))
+ (cautionary-half-thick (assoc-get 'half-thickness cautionary-props 0.075))
+ (cautionary-padding (assoc-get 'padding cautionary-props 0))
+ (cautionary-proc (assoc-get 'procedure cautionary-props parenthesize-stencil))
+ (cautionary-width (assoc-get 'width cautionary-props 0.25))
- (ref-grob (grob-interpret-markup grob "8"))
- (offset-factor (assoc-get 'head-offset details 3/5))
- (column-offset (* offset-factor
- (interval-length
- (ly:stencil-extent
- (grob-interpret-markup grob "8")
- X)))))
+ (ref-grob (grob-interpret-markup grob "8"))
+ (offset-factor (assoc-get 'head-offset details 3/5))
+ (column-offset (* offset-factor
+ (interval-length
+ (ly:stencil-extent
+ (grob-interpret-markup grob "8")
+ X)))))
;; According to the arithmetic sum, the position of m/n is at 1/2*(n-2)(n-1)+(m-1)
;; if we start counting from zero
(vector 12
;; According to the arithmetic sum, the position of m/n is at 1/2*(n-2)(n-1)+(m-1)
;; if we start counting from zero
(vector 12
(define-public (ratio->pitch ratio)
"Calculate a pitch given @var{ratio} for the harmonic."
(let* ((partial (1- (denominator ratio)))
(pitch (vector-ref partial-pitch partial)))
(define-public (ratio->pitch ratio)
"Calculate a pitch given @var{ratio} for the harmonic."
(let* ((partial (1- (denominator ratio)))
(pitch (vector-ref partial-pitch partial)))
(define-public (fret->pitch fret)
"Calculate a pitch given @var{fret} for the harmonic."
(let* ((partial (assoc-get fret fret-partials 0))
(pitch (vector-ref partial-pitch partial)))
(define-public (fret->pitch fret)
"Calculate a pitch given @var{fret} for the harmonic."
(let* ((partial (assoc-get fret fret-partials 0))
(pitch (vector-ref partial-pitch partial)))
(define-public (calc-harmonic-pitch pitch music)
"Calculate the harmonic pitches in @var{music} given
(define-public (calc-harmonic-pitch pitch music)
"Calculate the harmonic pitches in @var{music} given
- ((pair? es)
- (ly:music-set-property! music 'elements
- (map (lambda (x) (calc-harmonic-pitch pitch x)) es)))
- ((ly:music? e)
- (ly:music-set-property! music 'element (calc-harmonic-pitch pitch e)))
- ((ly:pitch? p)
- (begin
- (set! p (ly:pitch-transpose p pitch))
- (ly:music-set-property! music 'pitch p))))
+ ((pair? es)
+ (ly:music-set-property! music 'elements
+ (map (lambda (x) (calc-harmonic-pitch pitch x)) es)))
+ ((ly:music? e)
+ (ly:music-set-property! music 'element (calc-harmonic-pitch pitch e)))
+ ((ly:pitch? p)
+ (begin
+ (set! p (ly:pitch-transpose p pitch))
+ (ly:music-set-property! music 'pitch p))))
music))
(define-public (make-harmonic mus)
"Convert music variable @var{mus} to harmonics."
(let ((elts (ly:music-property mus 'elements))
(elt (ly:music-property mus 'element)))
music))
(define-public (make-harmonic mus)
"Convert music variable @var{mus} to harmonics."
(let ((elts (ly:music-property mus 'elements))
(elt (ly:music-property mus 'element)))
- (cond
- ((pair? elts)
- (map make-harmonic elts))
- ((ly:music? elt)
- (make-harmonic elt))
- ((music-is-of-type? mus 'note-event)
- (set! (ly:music-property mus 'articulations)
- (append
- (ly:music-property mus 'articulations)
- (list (make-music 'HarmonicEvent))))))
- mus))
+ (cond
+ ((pair? elts)
+ (for-each make-harmonic elts))
+ ((ly:music? elt)
+ (make-harmonic elt))
+ ((music-is-of-type? mus 'note-event)
+ (set! (ly:music-property mus 'articulations)
+ (append
+ (ly:music-property mus 'articulations)
+ (list (make-music 'HarmonicEvent))))))
+ mus))