-;;;; translation-functions.scm --
-;;;;
-;;;; source file of the GNU LilyPond music typesetter
+;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
;;;; (c) 1998--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
;;;; Jan Nieuwenhuizen <janneke@gnu.org>
+;;;;
+;;;; LilyPond is free software: you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation, either version 3 of the License, or
+;;;; (at your option) any later version.
+;;;;
+;;;; LilyPond is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set! (ly:grob-property grob 'dot-placement-list)
(if (not (null? predefined-fretboard))
predefined-fretboard
- (let ((minimum-fret
- (ensure-number
- (ly:context-property context 'minimumFret)
- 0))
- (max-stretch
- (ensure-number
- (ly:context-property context 'maximumFretStretch)
- 4))
- (string-frets
- (determine-frets-mf
+ (let* ((minimum-fret
+ (ensure-number
+ (ly:context-property context 'minimumFret)
+ 0))
+ (max-stretch
+ (ensure-number
+ (ly:context-property context 'maximumFretStretch)
+ 4))
+ (string-frets
+ (determine-frets-mf
notes
string-numbers
minimum-fret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; tablature
-;; The TabNoteHead tablatureFormat callback.
-;; Compute the text grob-property
-(define-public (fret-number-tablature-format string context event)
+;; The TabNoteHead tablatureFormat callbacks.
+
+;; Calculate the fret from pitch and string number as letter
+;; The fret letter is taken from 'fretLabels if present
+(define-public (fret-letter-tablature-format string-number context event)
+ (let* ((tuning (ly:context-property context 'stringTunings))
+ (pitch (ly:event-property event 'pitch))
+ (labels (ly:context-property context 'fretLabels))
+ (fret (- (ly:pitch-semitones pitch)
+ (list-ref tuning (- string-number 1)))))
+ (make-vcenter-markup
+ (cond
+ ((= 0 (length labels))
+ (string (integer->char (+ fret (char->integer #\a)))))
+ ((and (<= 0 fret) (< fret (length labels)))
+ (list-ref labels fret))
+ (else
+ (ly:warning "No label for fret ~a (~a on string ~a);
+only ~a fret labels provided"
+ fret pitch string-number (length labels))
+ ".")))))
+
+;; Calculate the fret from pitch and string number as number
+(define-public (fret-number-tablature-format string-number context event)
(let* ((tuning (ly:context-property context 'stringTunings))
(pitch (ly:event-property event 'pitch)))
-
- (make-whiteout-markup
- (make-vcenter-markup
- (format
- "~a"
- (- (ly:pitch-semitones pitch)
- (list-ref tuning
- ;; remove 1 because list index starts at 0
- ;;and guitar string at 1.
- (1- string))))))))
+ (make-vcenter-markup
+ (format
+ "~a"
+ (- (ly:pitch-semitones pitch)
+ (list-ref tuning
+ ;; remove 1 because list index starts at 0
+ ;;and guitar string at 1.
+ (1- string-number)))))))
;; The 5-string banjo has got a extra string, the fifth (duh), which
;; starts at the fifth fret on the neck. Frets on the fifth string
;; the "first fret" on the fifth string is really the sixth fret
;; on the banjo neck.
;; We solve this by defining a new fret-number-tablature function:
-(define-public (fret-number-tablature-format-banjo string context event)
+(define-public (fret-number-tablature-format-banjo string-number context event)
(let* ((tuning (ly:context-property context 'stringTunings))
(pitch (ly:event-property event 'pitch)))
-
- (make-whiteout-markup
- (make-vcenter-markup
- (let ((fret (- (ly:pitch-semitones pitch) (list-ref tuning (1- string)))))
- (number->string (cond
- ((and (> fret 0) (= string 5))
- (+ fret 5))
- (else fret))))))))
+ (make-vcenter-markup
+ (let ((fret (- (ly:pitch-semitones pitch)
+ (list-ref tuning (1- string-number)))))
+ (number->string (cond
+ ((and (> fret 0) (= string-number 5))
+ (+ fret 5))
+ (else fret)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;