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