[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "smart" transposition of key signatures
From: |
Kieren MacMillan |
Subject: |
Re: "smart" transposition of key signatures |
Date: |
Mon, 7 Oct 2013 13:00:36 -0400 |
Hi David,
One small improvement could [possibly?] be made: allowing for the extraction of
the keys into a variable separate from the notes.
As you can see in the attached snippet, that doesn't work as expected.
*THAT* solution will definitely be worth both a snippet and some euros.
Thanks again,
Kieren.
_________________________
smartkey =
#(define-music-function (parser location pitch scale music)
(ly:pitch? list? ly:music?)
(let ((key #{ \key $pitch #scale #}))
(make-music 'SequentialMusic
'elements (list key music)
'elements-callback
(lambda (m)
(let* ((elts (ly:music-property m 'elements))
(key (car elts))
(sh (fold (lambda (elt total) (+ (cdr elt) total))
0
(ly:music-property key 'pitch-alist))))
(cond ((< sh -3)
(map (lambda (m)
(ly:music-transpose m #{ bis #}))
elts))
((> sh 3)
(map (lambda (m)
(ly:music-transpose m #{ deses' #}))
elts))
(else elts)))))))
global = {
\key c \minor s1
\key cis \major s1
\key es \minor s1
}
smartglobal = {
\smartkey c \minor s1
\smartkey cis \major s1
\smartkey es \minor s1
}
notes = \relative c' {
c4 es g <c, es g>
cis eis gis <cis, eis gis>
es ges bes <es, ges bes>
}
music = << \global \notes >>
smartmusic = << \smartglobal \notes >>
<<
\new Staff \music
\new Staff \transpose c g \music
\new Staff \transpose c es \music
\new Staff \transpose c fis \music
>>
<<
\new Staff \smartmusic
\new Staff \transpose c g \smartmusic
\new Staff \transpose c es \smartmusic
\new Staff \transpose c fis \smartmusic
>>
- "smart" transposition of key signatures, Kieren MacMillan, 2013/10/07
- Re: "smart" transposition of key signatures, Urs Liska, 2013/10/07
- Re: "smart" transposition of key signatures, David Kastrup, 2013/10/07
- Re: "smart" transposition of key signatures, Kieren MacMillan, 2013/10/07
- Re: "smart" transposition of key signatures,
Kieren MacMillan <=
- Re: "smart" transposition of key signatures, David Kastrup, 2013/10/07
- Re: "smart" transposition of key signatures, Kieren MacMillan, 2013/10/07
- Re: "smart" transposition of key signatures, David Kastrup, 2013/10/07
- Re: "smart" transposition of key signatures, Urs Liska, 2013/10/08
- Re: "smart" transposition of key signatures, Hans Aberg, 2013/10/08
Re: "smart" transposition of key signatures, Janek Warchoł, 2013/10/07