Hi all,
It seems it's been a year since I looked at this problem, and I've just figured out some kind of solution.
Applying the "optionalTranspose" function (see below) to each voice allows me to globally switch all transposition on and off, so as to achieve either a transposed or concert pitch score. This is really useful when dealing with brass band music, as a quick check of pitches without mental transposition.
I can define something like
bflatBassMusic = {
\key g \major
a b c d e
}
bflatBassVoice = {
% stuff
\optionalTranspose treble bass bis c'' \relative c
{
\bflatBassMusic
}
}
Question: In order to avoid an "unbound variable" error, I have to define the switch variable "transposing-score" ahead of including the "optionalTranspose.lyi" file that contains my function.
This isn't very tidy. Is there a cleaner way of creating a "switch" variable, or perhaps to detect the unbound variable as being a null value? Or to define it above the function definition and let me reset it later in the code, perhaps in a globals = {... } block?
I'd also appreciate any other suggestions for improvement of this code. I think it is a useful enough thing to go on the LSR if it is perhaps refined a little.
Thanks in advance,
Chris
-------------
#(define transposing-score #f)
optionalTranspose =
#(define-music-function (parser location transposing-clef concert-clef from to music)
( string? string? ly:pitch? ly:pitch? ly:music?)
(if (eq? #t transposing-score)
#{
\clef #transposing-clef
\transpose #from #to #music
#}
#{
\clef #concert-clef
#music
#}
)
)
---------
Chris Yate <address@hidden> writes:
> On 12 July 2015 at 23:02, David Kastrup <address@hidden> wrote:
>
>> Chris Yate <address@hidden> writes:
>>
>> > I find it would be very convenient every now and again to be able to
>> change
>> > a score to be non-transposing -- in order to easily check pitches etc.
>> >
>> > Any better approaches?
>>
>> Well, the Midi should be fine already, so you need this just for
>> proofreading. And for that, you should be able to just transpose back
>> again.
>>
>> Another possibility is working with music quotes: those are always in
>> concert pitch.
>
> Ah -- applying the inverse transposition on each voice, in the concert
> pitch score? Of course! Yes, I think that would work, will give it a go.
Getting the Midi transpositions out will likely work in 2.19.24 by using
the redefinition
transposition = \tag per-instrument \transposition \etc
in your general includes and then using
\removeTag per-instrument ...
on the music expressions in the partitura. The syntactic sugar \etc is
issue 4487 and will likely appear in origin/master within a week.
--
David Kastrup