[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: transposing music via command line argument
From: |
Marc Hohl |
Subject: |
Re: transposing music via command line argument |
Date: |
Thu, 29 Dec 2011 11:03:56 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111109 Thunderbird/3.1.16 |
Am 27.12.2011 14:45, schrieb Marc Hohl:
Hello list,
in another thread, my problems with command line arguments were
solved (or workarounds provided), but now I am stuck with
another but similar problem:
I want to transpose some music and tell lilypond the 'to' pitch
in the command line:
lilypond -dpitch="e'" myfile.ly
where myfile.ly is
\version "2.15.24"
optionalTranspose = #(define-music-function (parser location music)
(ly:music?)
(let ((mypitch (ly:get-option 'pitch)))
#{ \transpose c $mypitch $music #}))
melody = { c'4 d' e'2 }
\score {
\new Staff {
\new Voice { \optionalTranspose \melody }
}
}
Lilypond refuses to see mypitch as a pitch. I tried to convert it
with (ly:music-property mypitch 'pitch), but lilypond soesn't take
the command line argument as a music expression, too.
Is there any chance to convince lilypond to accept a pitch on
the command line?
To answer my own request: I got around the problem by using
three command line options:octave, note and alteration.
optionalTranspose = #(define-music-function (parser location music)
(ly:music?)
(let* ((octave (or (ly:get-option 'octave) -1))
(note (or (ly:get-option 'note) 0))
(alteration (or (ly:get-option 'alteration) 0))
(to (ly:make-pitch octave note alteration)))
#{ \transpose c $to $music #}))
music = {
\key c \major
c'4 d' e'2
}
\score {
\new Staff {
\new Voice {
\optionalTranspose { \music }
}
}
}
This works with
lilypond -doctave=-1 test.ly
lilypond -dnote=1 -dalteration=-1/2 test.ly
and so on.
Regards,
Marc