[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: instrumentSwitch and addInstrumentDefinition use
From: |
Kieren MacMillan |
Subject: |
Re: instrumentSwitch and addInstrumentDefinition use |
Date: |
Mon, 12 Jan 2015 09:36:15 -0500 |
Hi Keith,
Thanks for the function and snippet. Here is a [compiling, but non-functional]
revision showing how I *want* to use it:
%%%% SNIPPET BEGINS
\version "2.19.15"
transpositionUpdateKey =
#(define-music-function (parser location new-transposition) (ly:pitch?)
(_i "Set instrument transposition and, based on the previous
transposition and key, generate the key-change to keep the sounding key.")
(define (generate-key-change c)
(define (same-scale-step? a b) (= (car a) (car b)))
(let* ((old-alt (delete-duplicates!
(append (ly:context-property c 'keyAlterations)
major)
same-scale-step?))
(old-tonic (ly:context-property c 'tonic (ly:make-pitch 0 0 0)))
(old-transp (ly:context-property c 'instrumentTransposition
(ly:make-pitch 0 0 0)))
(delta (ly:pitch-diff old-transp new-transposition))
(new-alt (ly:transpose-key-alist old-alt delta))
(new-tonic (ly:pitch-transpose old-tonic delta))
(sev (ly:make-stream-event `(key-change-event)
`((pitch-alist . ,new-alt)
(tonic . ,new-tonic)))))
(ly:broadcast (ly:context-event-source c) sev)))
#{
\applyContext #generate-key-change
\transposition $new-transposition
#} )
prep_alto = {
\set Staff.shortInstrumentName = "AF"
<>^\markup \box "take alto flute"
\transpositionUpdateKey g,
}
play_alto = {
<>^\markup \bold "Alto Flute"
\once \set Staff.whichBar = "||"
}
global = {
\key c \major
s1*12
}
flute_part = {
\compressFullBarRests
c'2 c'' |
b'4 g'8 a' b'4 c'' |
c'2 a' |
g'2. r4 |
\prep_alto R1*4 |
\play_alto a2 f' |
e'4 c'8 d' e'4 f'4 |
d'4 b8 c' d'4 e' |
c'2. r4
}
\score {
<<
\new Staff \with { instrumentName = "Flute" } \flute_part
>>
}
%%%% SNIPPET ENDS
Note in particular that in the flute_part variable, I [want to] simply put
\prep_alto to trigger the physical switch, and \play_alto to switch the key
signature (which your function does perfectly!) *and* the notated transposition
(which is currently not happening: the notes should be up a perfect fourth).
This is why I think we should brainstorm and implement a really well-designed
instrumentSwitch/instrumentDefinition mechanism — we wouldn’t need any of this.
We’d simply put something like
reedI = {
\instrument “flute"
[flute music here, no need for transposition]
\instrument “alto flute”
[alto music here; transposed properly in part, but optionally not in score]
\instrument “tenor sax”
[tenor sax music here; transposed properly in part, but optionally not in
score]
}
This might tie in to Janek’s instrument-definition work… don’t know, since I
haven’t checked it out yet.
Of course, I know I can roll this myself using variables — that’s what I’ve
been doing to date.
But with all the key signature problems, I’d almost given up hope.
Now, with your function, I’m optimistic we might solve this once and for all.
Thoughts, comments, etc., welcome!
Thanks,
Kieren.
_______________________
Kieren MacMillan, composer
www: <http://www.kierenmacmillan.info>
email: address@hidden
- instrumentSwitch and addInstrumentDefinition use, Paul Scott, 2015/01/10
- Re: instrumentSwitch and addInstrumentDefinition use, Keith OHara, 2015/01/11
- Re: instrumentSwitch and addInstrumentDefinition use, Kieren MacMillan, 2015/01/11
- Re: instrumentSwitch and addInstrumentDefinition use, Keith OHara, 2015/01/12
- Re: instrumentSwitch and addInstrumentDefinition use, Kieren MacMillan, 2015/01/12
- Re: instrumentSwitch and addInstrumentDefinition use, Urs Liska, 2015/01/14
- Re: instrumentSwitch and addInstrumentDefinition use, Paul Scott, 2015/01/19
- Re: instrumentSwitch and addInstrumentDefinition use, Kieren MacMillan, 2015/01/19
- Re: instrumentSwitch and addInstrumentDefinition use, Keith OHara, 2015/01/20
- Message not available
- Re: instrumentSwitch and addInstrumentDefinition use,
Kieren MacMillan <=
- Re: instrumentSwitch and addInstrumentDefinition use, Keith OHara, 2015/01/13
- Re: instrumentSwitch and addInstrumentDefinition use, Kieren MacMillan, 2015/01/13
- Re: instrumentSwitch and addInstrumentDefinition use, Keith OHara, 2015/01/18
- Re: instrumentSwitch and addInstrumentDefinition use, Kieren MacMillan, 2015/01/18
- Re: instrumentSwitch and addInstrumentDefinition use, Keith OHara, 2015/01/20
- Re: instrumentSwitch and addInstrumentDefinition use, Kieren MacMillan, 2015/01/20
- Re: instrumentSwitch and addInstrumentDefinition use, Keith OHara, 2015/01/25
- Re: instrumentSwitch and addInstrumentDefinition use, Jan-Peter Voigt, 2015/01/13
- Re: instrumentSwitch and addInstrumentDefinition use, Paul Scott, 2015/01/12