X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fchord-entry.scm;h=d8587dcf839cefc843f734c9abf97ed6af6b993c;hb=ee0ef98a35634718033d505deb8a355e05513d6a;hp=b7d09142d06a4110c17e079e4b9cb6583ccfcccb;hpb=57e9d4bb7dc057ffddb1b5b82aaddb8a996af89b;p=lilypond.git diff --git a/scm/chord-entry.scm b/scm/chord-entry.scm index b7d09142d0..d8587dcf83 100644 --- a/scm/chord-entry.scm +++ b/scm/chord-entry.scm @@ -1,18 +1,30 @@ -;;;; chord-entry.scm -- Generate chord names for the parser. +;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; source file of the GNU LilyPond music typesetter +;;;; Copyright (C) 2004--2012 Han-Wen Nienhuys ;;;; -;;;; (c) 2004--2005 Han-Wen Nienhuys +;;;; 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 . -(define-public (construct-chord root duration modifications) - " Build a chord on root using modifiers in MODIFICATIONS. NoteEvent -have duration DURATION.. +; for define-safe-public when byte-compiling using Guile V2 +(use-modules (scm safe-utility-defs)) -Notes: natural 11 is left from chord if not explicitly specified. +(define-public (construct-chord-elements root duration modifications) + "Build a chord on root using modifiers in @var{modifications}. +@code{NoteEvents} have duration @var{duration}. -Entry point for the parser. +Notes: Natural 11 is left from chord if not explicitly specified. -" +Entry point for the parser." (let* ((flat-mods (flatten-list modifications)) (base-chord (stack-thirds (ly:make-pitch 0 4 0) the-canonical-chord)) (complete-chord '()) @@ -23,7 +35,7 @@ Entry point for the parser. (start-additions #t)) (define (interpret-inversion chord mods) - "Read /FOO part. Side effect: INVERSION is set." + "Read /FOO part. Side effect: INVERSION is set." (if (and (> (length mods) 1) (eq? (car mods) 'chord-slash)) (begin (set! inversion (cadr mods)) @@ -31,13 +43,13 @@ Entry point for the parser. (interpret-bass chord mods)) (define (interpret-bass chord mods) - "Read /+FOO part. Side effect: BASS is set." + "Read /+FOO part. Side effect: BASS is set." (if (and (> (length mods) 1) (eq? (car mods) 'chord-bass)) (begin (set! bass (cadr mods)) (set! mods (cddr mods)))) (if (pair? mods) - (scm-error 'chord-format "construct-chord" "Spurious garbage following chord: ~A" mods #f)) + (ly:warning (_ "Spurious garbage following chord: ~A") mods)) chord) (define (interpret-removals chord mods) @@ -51,7 +63,7 @@ Entry point for the parser. (interpret-inversion chord mods))) (define (interpret-additions chord mods) - "Interpret additions. TODO: should restrict modifier use?" + "Interpret additions. TODO: should restrict modifier use?" (cond ((null? mods) chord) ((ly:pitch? (car mods)) (if (= (pitch-step (car mods)) 11) @@ -155,12 +167,12 @@ the bass specified. (write-me "inversion: " inversion) (write-me "bass: " bass))) (if inversion - (make-chord (cdr complete-chord) bass duration (car complete-chord) + (make-chord-elements (cdr complete-chord) bass duration (car complete-chord) inversion) - (make-chord complete-chord bass duration #f #f)))) + (make-chord-elements complete-chord bass duration #f #f)))) -(define (make-chord pitches bass duration inversion original-inv-pitch) +(define (make-chord-elements pitches bass duration inversion original-inv-pitch) "Make EventChord with notes corresponding to PITCHES, BASS and DURATION, and INVERSION." (define (make-note-ev pitch) @@ -181,7 +193,7 @@ DURATION, and INVERSION." (- (ly:pitch-octave inversion) (ly:pitch-octave original-inv-pitch))) (set! nots (cons inv-note nots)))) - (make-event-chord nots))) + nots)) ;;;;;;;;;;;;;;;; ; chord modifiers change the pitch list. @@ -219,13 +231,14 @@ DURATION, and INVERSION." (map (lambda (n) (define (nca x) (if (= x 7) FLAT 0)) + (if (>= n 8) (ly:make-pitch 1 (- n 8) (nca n)) (ly:make-pitch 0 (- n 1) (nca n)))) '(1 3 5 7 9 11 13))) (define (stack-thirds upper-step base) - "Stack thirds listed in BASE until we reach UPPER-STEP. Add + "Stack thirds listed in BASE until we reach UPPER-STEP. Add UPPER-STEP separately." (cond ((null? base) '()) ((> (ly:pitch-steps upper-step) (ly:pitch-steps (car base)))