[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how do I change enharmonic spellings produced by the /transpose func
From: |
David Kastrup |
Subject: |
Re: how do I change enharmonic spellings produced by the /transpose function? |
Date: |
Sat, 13 Apr 2013 15:59:39 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
robert edge <address@hidden> writes:
> I write music that is not strictly tonal, and years ago I adopted the
> convention of always using the same enharmonic spellings. So my
> chromatic scale goes: c cis d ees e f fis g aes a bes b. I never
> write something like an A sharp or a G flat.
>
> Of course Lilypond doesn't know about my silly ideas and \transpose
> gives me all sorts of g sharps and d sharps in my tenor sax charts,
> for instance.
>
> My current workflow is transposing the chart using \transpose, using
> the \displayLilyMusic function, pasting the output back in to the
> source file and then making the changes using search and replace in
> EMACS.
>
> I'd like to automate this process, I've got a lot of charts.
>
> Anyone have any ideas on how to do this, or where I can find some code
> that does something similar I might be able to adapt?
How about the following:
myScale =
#(event-chord-pitches #{ <c cis d ees e f fis g aes a bes b> #})
chromaScale =
#(define-music-function (parser location music) (ly:music?)
(for-some-music
(lambda (m)
(and (ly:pitch? (ly:music-property m 'pitch))
(let* ((s (ly:pitch-semitones (ly:music-property m 'pitch)))
(oct (floor (/ s 12)))
(step (modulo s 12))
(p (list-ref myScale step)))
(set! (ly:music-property m 'pitch)
(ly:make-pitch oct
(ly:pitch-notename p)
(ly:pitch-alteration p))))
#t))
music)
music)
\chromaScale \relative c' { c des es fes ceses }
--
David Kastrup