--- /dev/null
+\version "2.19.22"
+
+\header {
+ lsrtags = "pitches, scheme-language, workaround"
+
+ texidoc = "
+This example uses some Scheme code to enforce enharmonic modifications
+for notes in order to have the minimum number of accidentals. In this
+case, the following rules apply:
+
+Double accidentals should be removed
+
+
+B sharp -> C
+
+
+E sharp -> F
+
+
+C flat -> B
+
+
+F flat -> E
+
+
+In this manner, the most natural enharmonic notes are chosen.
+
+"
+ doctitle = "Transposing pitches with minimum accidentals (\"Smart\" transpose)"
+}
+#(define (naturalize-pitch p)
+ (let ((o (ly:pitch-octave p))
+ (a (* 4 (ly:pitch-alteration p)))
+ ;; alteration, a, in quarter tone steps,
+ ;; for historical reasons
+ (n (ly:pitch-notename p)))
+ (cond
+ ((and (> a 1) (or (eqv? n 6) (eqv? n 2)))
+ (set! a (- a 2))
+ (set! n (+ n 1)))
+ ((and (< a -1) (or (eqv? n 0) (eqv? n 3)))
+ (set! a (+ a 2))
+ (set! n (- n 1))))
+ (cond
+ ((> a 2) (set! a (- a 4)) (set! n (+ n 1)))
+ ((< a -2) (set! a (+ a 4)) (set! n (- n 1))))
+ (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
+ (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
+ (ly:make-pitch o n (/ a 4))))
+
+#(define (naturalize music)
+ (let ((es (ly:music-property music 'elements))
+ (e (ly:music-property music 'element))
+ (p (ly:music-property music 'pitch)))
+ (if (pair? es)
+ (ly:music-set-property!
+ music 'elements
+ (map naturalize es)))
+ (if (ly:music? e)
+ (ly:music-set-property!
+ music 'element
+ (naturalize e)))
+ (if (ly:pitch? p)
+ (begin
+ (set! p (naturalize-pitch p))
+ (ly:music-set-property! music 'pitch p)))
+ music))
+
+naturalizeMusic =
+#(define-music-function (m)
+ (ly:music?)
+ (naturalize m))
+
+music = \relative c' { c4 d e g }
+
+\score {
+ \new Staff {
+ \transpose c ais { \music }
+ \naturalizeMusic \transpose c ais { \music }
+ \transpose c deses { \music }
+ \naturalizeMusic \transpose c deses { \music }
+ }
+ \layout { }
+}
-%% DO NOT EDIT this file manually; it is automatically
-%% generated from LSR http://lsr.di.unimi.it
-%% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
-%% and then run scripts/auxiliar/makelsr.py
-%%
-%% This file is in the public domain.
+% DO NOT EDIT this file manually; it is automatically
+% generated from Documentation/snippets/new
+% Make any changes in Documentation/snippets/new/
+% and then run scripts/auxiliar/makelsr.py
+%
+% This file is in the public domain.
+%% Note: this file works from version 2.19.22
\version "2.19.22"
\header {
;; for historical reasons
(n (ly:pitch-notename p)))
(cond
- ((and (> a 1) (or (eq? n 6) (eq? n 2)))
+ ((and (> a 1) (or (eqv? n 6) (eqv? n 2)))
(set! a (- a 2))
(set! n (+ n 1)))
- ((and (< a -1) (or (eq? n 0) (eq? n 3)))
+ ((and (< a -1) (or (eqv? n 0) (eqv? n 3)))
(set! a (+ a 2))
(set! n (- n 1))))
(cond
(ly:spanner-set-bound! spanner RIGHT item)))
#(define (axis-offset-symbol axis)
- (if (eq? axis X) 'X-offset 'Y-offset))
+ (if (eqv? axis X) 'X-offset 'Y-offset))
#(define (set-axis! grob axis)
(if (not (number? (ly:grob-property grob 'side-axis)))
(set! (ly:grob-property grob 'side-axis) axis)
(ly:grob-chain-callback
grob
- (if (eq? axis X)
+ (if (eqv? axis X)
ly:side-position-interface::x-aligned-side
side-position-interface::y-aligned-side)
(axis-offset-symbol axis)))))
*/
for (vsize i = 0; i < left_objects_.size (); i++)
{
- if (scm_is_eq (left_objects_[i]->get_property ("side-axis"), scm_from_int (X_AXIS)))
+ if (ly_is_equal (left_objects_[i]->get_property ("side-axis"), scm_from_int (X_AXIS)))
Side_position_interface::add_support (left_objects_[i], a);
}
vector<Grob *> current_elts;
current_elts.push_back (elements[i]);
while (i + 1 < elements.size ()
- && scm_is_eq (elements[i + 1]->get_property ("outside-staff-priority"), priority))
+ && ly_is_equal (elements[i + 1]->get_property ("outside-staff-priority"), priority))
{
if (!to_boolean (elements[i + 1]->get_property ("cross-staff")))
current_elts.push_back (elements[i + 1]);
Grob *last = 0;
for (vsize i = 0; i < text_.size (); i++)
{
- if (scm_is_eq (dir, text_[i]->get_property ("direction")))
+ if (ly_is_equal (dir, text_[i]->get_property ("direction")))
{
if (last)
Side_position_interface::add_support (text_[i], last);
vector<Transform_matrix_and_expression>
stencil_traverser (PangoMatrix trans, SCM expr)
{
- if (scm_is_null (expr))
- return vector<Transform_matrix_and_expression> ();
- else if (scm_is_eq (expr, ly_string2scm ("")))
+ if (scm_is_null (expr)
+ || (scm_is_string (expr) && scm_is_true (scm_string_null_p (expr))))
return vector<Transform_matrix_and_expression> ();
else if (scm_is_eq (scm_car (expr), ly_symbol2scm ("combine-stencil")))
{
#(define (ac:up note)
(let* ((pitch (ly:music-property note 'pitch))
(notename (ly:pitch-notename pitch))
- (new-notename (if (eq? notename 6) 0 (+ 1 notename)))
+ (new-notename (if (eqv? notename 6) 0 (+ 1 notename)))
(alterations (ly:music-property ac:current-key 'pitch-alist))
(new-alteration (cdr (assq new-notename alterations)))
- (new-octave (if (eq? new-notename 0) (+ 1 (ly:pitch-octave pitch))
+ (new-octave (if (eqv? new-notename 0) (+ 1 (ly:pitch-octave pitch))
(ly:pitch-octave pitch)))
)
(set! (ly:music-property note 'pitch)(ly:make-pitch new-octave new-notename new-alteration))))
#(define (ac:down note)
(begin (let* ((pitch (ly:music-property note 'pitch))
(notename (ly:pitch-notename pitch))
- (new-notename (if (eq? notename 0) 6 (- notename 1)))
+ (new-notename (if (eqv? notename 0) 6 (- notename 1)))
(alterations (ly:music-property ac:current-key 'pitch-alist))
(new-alteration (cdr (assq new-notename alterations)))
- (new-octave (if (eq? new-notename 6) (- (ly:pitch-octave pitch) 1)
+ (new-octave (if (eqv? new-notename 6) (- (ly:pitch-octave pitch) 1)
(ly:pitch-octave pitch)))
)
(set! (ly:music-property note 'pitch)(ly:make-pitch new-octave new-notename new-alteration))))
((SlurEvent)
(let ((direction (ly:music-property e 'span-direction)))
- (set! ac:inSlur (eq? direction -1))
- (set! at-end-of-slur (eq? direction 1))
+ (set! ac:inSlur (eqv? direction -1))
+ (set! at-end-of-slur (eqv? direction 1))
(loop factor newelements tail actions)))
((TrillSpanEvent)
(let ((direction (ly:music-property e 'span-direction)))
- (set! ac:inTrill (eq? direction -1))
+ (set! ac:inTrill (eqv? direction -1))
(if ac:inTrill
(loop factor newelements tail (cons 'trill actions))
(loop factor (cons e newelements) tail actions))))
((PhrasingSlurEvent)
(let ((direction (ly:music-property e 'span-direction)))
- (set! ac:inPhrasingSlur (eq? direction -1))
+ (set! ac:inPhrasingSlur (eqv? direction -1))
(loop factor newelements tail actions)))
(else (loop factor (cons e newelements) tail actions))))))))
(len (ly:duration-log ac:currentDuration))
(dots (ly:duration-dot-count ac:currentDuration)))
- (if (not (eq? num denom))
+ (if (not (eqv? num denom))
(make-sequential-music
(list (ac:to128 music)
(make-music 'EventChord 'elements
(grace-orig-len (ly:music-length grace))
(main-orig-len (ly:music-length main))
(numerator (ly:moment-main-numerator maindur))
- (factor (if (eq? (remainder numerator 3) 0)
+ (factor (if (eqv? (remainder numerator 3) 0)
(ly:make-moment 1/3) (ly:make-moment 1/2))))
(ly:music-compress grace
(ly:moment-mul factor (ly:moment-div main-orig-len grace-orig-len)))
(interval-start extent)
Y))))
- (if (eq? dir LEFT)
+ (if (eqv? dir LEFT)
stencil
(ly:stencil-scale stencil -1 1))))
label-stencil
(stencil-coordinates
(* size fret-distance (1+ label-vertical-offset))
- (if (eq? label-dir LEFT)
+ (if (eqv? label-dir LEFT)
(- label-outside-diagram)
(+ (* size string-distance (1- string-count))
label-outside-diagram))))))
;; outer let to trigger suicide
(let ((sten (ly:hairpin::print grob)))
(if (grob::is-live? grob)
- (let* ((decresc? (eq? (ly:grob-property grob 'grow-direction) LEFT))
+ (let* ((decresc? (eqv? (ly:grob-property grob 'grow-direction) LEFT))
(thick (ly:grob-property grob 'thickness 0.1))
(thick (* thick (layout-line-thickness grob)))
(xex (ly:stencil-extent sten X))