1 %% Do not edit this file; it is auto-generated from input/new
2 %% This file is in the public domain.
6 Este ejemplo utiliza código de Scheme para forzar las
7 modificaciones enarmónicas de las notas, y así tener el menor
8 número de alteraciones accidentales. En este caso se aplican las
13 Se quitan las dobles alteraciones
29 De esta forma se selecciona el mayor número de notas enarmónicas
33 texidoc = "This example uses some Scheme code to enforce enharmonic
34 modifications for notes in order to have the minimum number of
35 accidentals. In this case, the following rules apply:
39 Double accidentals should be removed
55 In this manner, the most natural enharmonic notes are chosen.
57 doctitle = "Transposing music with minimum accidentals"
60 #(define (naturalize-pitch p)
61 (let* ((o (ly:pitch-octave p))
62 (a (* 4 (ly:pitch-alteration p)))
63 ; alteration, a, in quarter tone steps, for historical reasons
64 (n (ly:pitch-notename p)))
66 ((and (> a 1) (or (eq? n 6) (eq? n 2)))
69 ((and (< a -1) (or (eq? n 0) (eq? n 3)))
73 ((> a 2) (set! a (- a 4)) (set! n (+ n 1)))
74 ((< a -2) (set! a (+ a 4)) (set! n (- n 1))))
75 (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
76 (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
77 (ly:make-pitch o n (/ a 4))))
79 #(define (naturalize music)
80 (let* ((es (ly:music-property music 'elements))
81 (e (ly:music-property music 'element))
82 (p (ly:music-property music 'pitch)))
84 (ly:music-set-property!
86 (map (lambda (x) (naturalize x)) es)))
88 (ly:music-set-property!
93 (set! p (naturalize-pitch p))
94 (ly:music-set-property! music 'pitch p)))
98 #(define-music-function (parser location m)
102 music = \relative c' { c4 d e g }
106 \transpose c ais \music
107 \naturalizeMusic \transpose c ais \music
108 \transpose c deses \music
109 \naturalizeMusic \transpose c deses \music