Re: Easy way to switch off transpositions

2016-07-11 Thread Chris Yate
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
   #}
   )
  )
-


On Mon, 13 Jul 2015 at 00:14 David Kastrup  wrote:

> Chris Yate  writes:
>
> > On 12 July 2015 at 23:02, David Kastrup  wrote:
> >
> >> Chris Yate  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
>
\version "2.19.35"

#(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
   #}
   )
  )

\optionalTranspose treble bass bis c'' \relative c { a b c d e }

#(define transposing-score #t)

\optionalTranspose treble bass bes c'' \relative c { a b c d e }

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Easy way to switch off transpositions

2015-07-12 Thread David Kastrup
Chris Yate chrisy...@gmail.com 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.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Easy way to switch off transpositions

2015-07-12 Thread Chris Yate
On 12 July 2015 at 23:02, David Kastrup d...@gnu.org wrote:

 Chris Yate chrisy...@gmail.com 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.

 --
 David Kastrup


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.

Chris
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Easy way to switch off transpositions

2015-07-12 Thread David Kastrup
Chris Yate chrisy...@gmail.com writes:

 On 12 July 2015 at 23:02, David Kastrup d...@gnu.org wrote:

 Chris Yate chrisy...@gmail.com 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

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user