Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1057)

Side by Side Diff: scm/music-functions.scm

Issue 79680044: Add dodecaphonic-first accidental style
Patch Set: Created 11 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Documentation/notation/pitches.itely ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ;;;; This file is part of LilyPond, the GNU music typesetter. 1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;; 2 ;;;;
3 ;;;; Copyright (C) 1998--2014 Jan Nieuwenhuizen <janneke@gnu.org> 3 ;;;; Copyright (C) 1998--2014 Jan Nieuwenhuizen <janneke@gnu.org>
4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl> 4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
5 ;;;; 5 ;;;;
6 ;;;; LilyPond is free software: you can redistribute it and/or modify 6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by 7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or 8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version. 9 ;;;; (at your option) any later version.
10 ;;;; 10 ;;;;
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 alteration-def))) 1412 alteration-def)))
1413 (and (symbol? def) def))) 1413 (and (symbol? def) def)))
1414 1414
1415 (define (extract-alteration alteration-def) 1415 (define (extract-alteration alteration-def)
1416 (cond ((number? alteration-def) 1416 (cond ((number? alteration-def)
1417 alteration-def) 1417 alteration-def)
1418 ((pair? alteration-def) 1418 ((pair? alteration-def)
1419 (car alteration-def)) 1419 (car alteration-def))
1420 (else 0))) 1420 (else 0)))
1421 1421
1422 (define (check-pitch-against-signature context pitch barnum laziness octaveness) 1422 (define (check-pitch-against-signature context pitch barnum laziness octaveness all-naturals)
1423 "Checks the need for an accidental and a @q{restore} accidental against 1423 "Checks the need for an accidental and a @q{restore} accidental against
1424 @code{localKeySignature}. The @var{laziness} is the number of measures 1424 @code{localKeySignature}. The @var{laziness} is the number of measures
1425 for which reminder accidentals are used (i.e., if @var{laziness} is zero, 1425 for which reminder accidentals are used (i.e., if @var{laziness} is zero,
1426 only cancel accidentals in the same measure; if @var{laziness} is three, 1426 only cancel accidentals in the same measure; if @var{laziness} is three,
1427 we cancel accidentals up to three measures after they first appear. 1427 we cancel accidentals up to three measures after they first appear.
1428 @var{octaveness} is either @code{'same-octave} or @code{'any-octave} and 1428 @var{octaveness} is either @code{'same-octave} or @code{'any-octave} and
1429 specifies whether accidentals should be canceled in different octaves." 1429 specifies whether accidentals should be canceled in different octaves.
1430 If @var{all-naturals} is ##t, notes that do not occur in @code{keySignature}
1431 also get an accidental."
1430 (let* ((ignore-octave (cond ((equal? octaveness 'any-octave) #t) 1432 (let* ((ignore-octave (cond ((equal? octaveness 'any-octave) #t)
1431 ((equal? octaveness 'same-octave) #f) 1433 ((equal? octaveness 'same-octave) #f)
1432 (else 1434 (else
1433 (ly:warning (_ "Unknown octaveness type: ~S ") oc taveness) 1435 (ly:warning (_ "Unknown octaveness type: ~S ") oc taveness)
1434 (ly:warning (_ "Defaulting to 'any-octave.")) 1436 (ly:warning (_ "Defaulting to 'any-octave."))
1435 #t))) 1437 #t)))
1436 (key-sig (ly:context-property context 'keySignature)) 1438 (key-sig (ly:context-property context 'keySignature))
1437 (local-key-sig (ly:context-property context 'localKeySignature)) 1439 (local-key-sig (ly:context-property context 'localKeySignature))
1438 (notename (ly:pitch-notename pitch)) 1440 (notename (ly:pitch-notename pitch))
1439 (octave (ly:pitch-octave pitch)) 1441 (octave (ly:pitch-octave pitch))
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 ;; not recent enough, extract from key signature/local key signature 1479 ;; not recent enough, extract from key signature/local key signature
1478 (from-key-sig 1480 (from-key-sig
1479 (set! previous-alteration from-key-sig))) 1481 (set! previous-alteration from-key-sig)))
1480 1482
1481 (if (accidental-invalid? previous-alteration) 1483 (if (accidental-invalid? previous-alteration)
1482 (set! need-accidental #t) 1484 (set! need-accidental #t)
1483 1485
1484 (let* ((prev-alt (extract-alteration previous-alteration)) 1486 (let* ((prev-alt (extract-alteration previous-alteration))
1485 (this-alt (ly:pitch-alteration pitch))) 1487 (this-alt (ly:pitch-alteration pitch)))
1486 1488
1487 (if (not (= this-alt prev-alt)) 1489 (if (or (and all-naturals (eq? #f previous-alteration)) (not (= this-a lt prev-alt)))
1488 (begin 1490 (begin
1489 (set! need-accidental #t) 1491 (set! need-accidental #t)
1490 (if (and (not (= this-alt 0)) 1492 (if (and (not (= this-alt 0))
1491 (and (< (abs this-alt) (abs prev-alt)) 1493 (and (< (abs this-alt) (abs prev-alt))
1492 (> (* prev-alt this-alt) 0))) 1494 (> (* prev-alt this-alt) 0)))
1493 (set! need-restore #t)))))) 1495 (set! need-restore #t))))))
1494 1496
1495 (cons need-restore need-accidental))) 1497 (cons need-restore need-accidental)))
1496 1498
1497 (define-public ((make-accidental-rule octaveness laziness) context pitch barnum measurepos) 1499 (define-public ((make-accidental-rule octaveness laziness) context pitch barnum measurepos)
1498 "Create an accidental rule that makes its decision based on the octave of 1500 "Create an accidental rule that makes its decision based on the octave of
1499 the note and a laziness value. 1501 the note and a laziness value.
1500 1502
1501 @var{octaveness} is either @code{'same-octave} or @code{'any-octave} and 1503 @var{octaveness} is either @code{'same-octave} or @code{'any-octave} and
1502 defines whether the rule should respond to accidental changes in other 1504 defines whether the rule should respond to accidental changes in other
1503 octaves than the current. @code{'same-octave} is the normal way to typeset 1505 octaves than the current. @code{'same-octave} is the normal way to typeset
1504 accidentals -- an accidental is made if the alteration is different from the 1506 accidentals -- an accidental is made if the alteration is different from the
1505 last active pitch in the same octave. @code{'any-octave} looks at the last 1507 last active pitch in the same octave. @code{'any-octave} looks at the last
1506 active pitch in any octave. 1508 active pitch in any octave.
1507 1509
1508 @var{laziness} states over how many bars an accidental should be remembered. 1510 @var{laziness} states over how many bars an accidental should be remembered.
1509 @code{0}@tie{}is the default -- accidental lasts over 0@tie{}bar lines, that 1511 @code{0}@tie{}is the default -- accidental lasts over 0@tie{}bar lines, that
1510 is, to the end of current measure. A positive integer means that the 1512 is, to the end of current measure. A positive integer means that the
1511 accidental lasts over that many bar lines. @w{@code{-1}} is `forget 1513 accidental lasts over that many bar lines. @w{@code{-1}} is `forget
1512 immediately', that is, only look at key signature. @code{#t} is `forever'." 1514 immediately', that is, only look at key signature. @code{#t} is `forever'."
1513 1515
1514 (check-pitch-against-signature context pitch barnum laziness octaveness)) 1516 (check-pitch-against-signature context pitch barnum laziness octaveness #f))
1517
1518 (define-public ((make-accidental-dodecaphonic-rule octaveness laziness) context pitch barnum measurepos)
1519 "Variation on function make-accidental-rule that creates an dodecaphonic
1520 accidental rule."
1521
1522 (check-pitch-against-signature context pitch barnum laziness octaveness #t))
1515 1523
1516 (define (key-entry-notename entry) 1524 (define (key-entry-notename entry)
1517 "Return the pitch of an @var{entry} in @code{localKeySignature}. 1525 "Return the pitch of an @var{entry} in @code{localKeySignature}.
1518 The @samp{car} of the entry is either of the form @code{notename} or 1526 The @samp{car} of the entry is either of the form @code{notename} or
1519 of the form @code{(octave . notename)}. The latter form is used for special 1527 of the form @code{(octave . notename)}. The latter form is used for special
1520 key signatures or to indicate an explicit accidental. 1528 key signatures or to indicate an explicit accidental.
1521 1529
1522 The @samp{cdr} of the entry is either a rational @code{alter} indicating 1530 The @samp{cdr} of the entry is either a rational @code{alter} indicating
1523 a key signature alteration, or of the form 1531 a key signature alteration, or of the form
1524 @code{(alter . (barnum . measurepos))} indicating an alteration caused by 1532 @code{(alter . (barnum . measurepos))} indicating an alteration caused by
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 '() 1725 '()
1718 context)) 1726 context))
1719 ;; As in dodecaphonic style with the exception that immediately 1727 ;; As in dodecaphonic style with the exception that immediately
1720 ;; repeated notes (in the same voice) don't get an accidental 1728 ;; repeated notes (in the same voice) don't get an accidental
1721 ((equal? style 'dodecaphonic-no-repeat) 1729 ((equal? style 'dodecaphonic-no-repeat)
1722 (set-accidentals-properties #f 1730 (set-accidentals-properties #f
1723 `(Staff ,(make-accidental-rule 'same-octave 0) 1731 `(Staff ,(make-accidental-rule 'same-octave 0)
1724 ,dodecaphonic-no-repeat-rule) 1732 ,dodecaphonic-no-repeat-rule)
1725 '() 1733 '()
1726 context)) 1734 context))
1735 ;; Variety of the dodecaphonic style. Each note gets an accidental,
1736 ;; except notes that were already handled in the same measure.
1737 ((equal? style 'dodecaphonic-first)
1738 (set-accidentals-properties #f
1739 `(Staff ,(make-accidental-dodecaphonic-rule 's ame-octave 0))
1740 '()
1741 context))
1742
1727 ;; Multivoice accidentals to be read both by musicians playing one voice 1743 ;; Multivoice accidentals to be read both by musicians playing one voice
1728 ;; and musicians playing all voices. 1744 ;; and musicians playing all voices.
1729 ;; Accidentals are typeset for each voice, but they ARE canceled across voi ces. 1745 ;; Accidentals are typeset for each voice, but they ARE canceled across voi ces.
1730 ((equal? style 'modern-voice) 1746 ((equal? style 'modern-voice)
1731 (set-accidentals-properties #f 1747 (set-accidentals-properties #f
1732 `(Voice ,(make-accidental-rule 'same-octave 0 ) 1748 `(Voice ,(make-accidental-rule 'same-octave 0 )
1733 ,(make-accidental-rule 'any-octave 0) 1749 ,(make-accidental-rule 'any-octave 0)
1734 ,(make-accidental-rule 'same-octave 1 ) 1750 ,(make-accidental-rule 'same-octave 1 )
1735 Staff ,(make-accidental-rule 'same-oc tave 0) 1751 Staff ,(make-accidental-rule 'same-oc tave 0)
1736 ,(make-accidental-rule 'any-octave 0) 1752 ,(make-accidental-rule 'any-octave 0)
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 2370
2355 (if (>= total-found 2) 2371 (if (>= total-found 2)
2356 (helper siblings offsets) 2372 (helper siblings offsets)
2357 (offset-multiple-types vals (car offsets))))) 2373 (offset-multiple-types vals (car offsets)))))
2358 2374
2359 (begin 2375 (begin
2360 (ly:warning "the property '~a of ~a cannot be offset" property g rob) 2376 (ly:warning "the property '~a of ~a cannot be offset" property g rob)
2361 vals)))) 2377 vals))))
2362 ; return the closure named `self' 2378 ; return the closure named `self'
2363 self) 2379 self)
OLDNEW
« no previous file with comments | « Documentation/notation/pitches.itely ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b