Last active
December 19, 2015 23:59
-
-
Save kris7t/6038247 to your computer and use it in GitHub Desktop.
Transposition with Enharmonic Changes and ``Late-Binding'', now with error reporting!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\version "2.17.22" | |
beginning = \relative c'' { | |
\key as \major | |
c1 | |
} | |
middlesection = \relative gis' { | |
\key e \major | |
gis1 | |
} | |
end = \relative c'' { | |
\key as \major | |
c1 | |
\bar "|." | |
} | |
% ``Late-bind'' variables using an arity-0 music function that looks up values | |
% at function call time instead of variable assignment time. | |
late = | |
#(define-scheme-function | |
(parser location embedded-lilypond) | |
(list?) | |
(define-music-function | |
(parser location) | |
() | |
(eval embedded-lilypond | |
(interaction-environment)))) | |
music = \late #'#{ | |
\beginning | |
\middlesection | |
\end | |
#} | |
\score { | |
% The music without the enharmonic change---complex key signature! | |
\new Staff \transpose as g \music | |
\layout {} | |
} | |
% Apply enharmonic transposition to \middlesection. | |
middlesection = \transpose e fes \middlesection | |
\score { | |
% Because variables in \music are ``late-bound'', the enharmonic | |
% transposition is now respected. | |
\new Staff \transpose as g \music | |
\layout {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment