[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 12:37:18 -0400 |
Hi David,
You are worth your weight in gold, to me personally and to the whole Lilypond
community. =)
For everyone to see how great this is, I've modified your snippet slightly:
1. I've added \relative notes.
2. I've added a NON-SMART version of your SMART score.
> You owe me a snippet submission or its monetary equivalent.
ABSOLUTELY — the snippet for sure, and possibly some money as well.
I truly believe this needs to be in the regular distro.
I will work on a patch (with the slightly better function name \smartkey,
unless someone else has an even better suggestion).
Many thanks,
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)))))))
music =
\relative c' {
\key c \minor { c es g <c, es g> }
\key cis \major { cis eis gis <cis, eis gis> }
\key es \minor { es ges bes <es, ges bes> }
}
smartmusic =
\relative c' {
\smartkey c\minor { c es g <c, es g> }
\smartkey cis\major { cis eis gis <cis, eis gis> }
\smartkey es\minor { es ges bes <es, ges bes> }
}
<<
\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 <=
- 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, 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