Re: multi-instrument parts
Hi Jay, This doesn't Do The Right Thing™ when the key signatures are abstracted, e.g., \version 2.17.10 #(define (adjust-note mus key currkey) (cond ((or (eq? (ly:music-property mus 'name) 'NoteEvent) (eq? (ly:music-property mus 'name) 'KeyChangeEvent)) (ly:music-transpose mus (car currkey))) ((and (eq? (ly:music-property mus 'name) 'PropertySet) (eq? (ly:music-property mus 'symbol) 'instrumentTransposition)) (set-car! currkey (ly:pitch-negate (ly:music-property mus 'value))) (ly:music-set-property! mus 'value (ly:make-pitch 0 0 0)) mus) (else mus))) normalizeTransposition = #(define-music-function (parser location key music) (ly:pitch? ly:music?) (ly:music-transpose (let ((currkey (list (ly:make-pitch 0 0 0 (music-map (lambda (x) (adjust-note x key currkey)) music)) (ly:pitch-negate key))) global = { \time 4/4 \key c \major s1 \key d \major s1 \key e \major s1 } music = \relative c' { \transposition f c4 e g c | \transposition ees c, e g c | \transposition g c, e g c | } \score { \new Staff \global \music \new Staff \normalizeTransposition c' \global \music } Any way to easily fix that? If so, this would be a killer solution to my multi-instrumentalist problem. Thanks! Kieren. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
Hi Kieren, just stumbled across this thread. I once was trying to create an engraver, that recognizes transposition/instrument changes and inserts a time signature there. (IIRC it was a piece with a change between oboe and english horn) In the end I inserted tagged key-sigs, whenever I inserted an instrumentSwitch. But perhaps now is the time to look at this again? Cheers, Jan-Peter Am 16.01.2013 06:43, schrieb Kieren MacMillan: Hi Jay, There's this: http://lsr.dsi.unimi.it/LSR/Item?id=697 which is useful when the transposition changes mid-piece (like for clarinets, horns, and trumpets). Also you don't have to think about the 'from' pitch. You only need the 'to' pitch. That doesn't seem to handle key signatures very well — is there a workaround? Thanks, Kieren. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user \version 2.16.0 % tonic is equal - octave is not checked! #(define (ly:tonic=? p1 p2) (or (and (ly:pitch? p1) (ly:pitch? p2) (= (ly:pitch-notename p1) (ly:pitch-notename p2)) (= (ly:pitch-alteration p1) (ly:pitch-alteration p2)) ) (and (eq? #f p1) (eq? #f p2)) )) %%% don't watch this hack ... just to display real notenames here ... % pitch-notename #(define (nona pp) (if (ly:pitch? pp) (let ((str ?)) (define (search pl pp) (if (pair? pl) (let* ((pr (car pl)) (pq (cdr pr))) (if (ly:tonic=? pq pp) (set! str (car pr)) (search (cdr pl) pp)) ) )) (search pitchnames pp) str ) ?) ) %% % engraver to ... % recognize every change of instrument transposition #(define-public keyT (lambda (context) (let ((tonic (ly:make-pitch 0 0 0)) (sig '()) (last-pitch (ly:make-pitch 0 0 0))) ; no transp assumed `((process-music . ,(lambda (trans) (let ((current-pitch (ly:context-property context 'instrumentTransposition))) ; if pitch (instrument transposition) has changed, create new time signature (if (and (not (ly:tonic=? last-pitch current-pitch)) (ly:pitch? current-pitch)) (begin ; how to create a time signature grob? ; how to create the needed properties ; - concert pitch = bes maj, instr transp bes ; = should give c maj key sig with key cancelation (let ((time-sig (ly:engraver-make-grob trans 'KeySignature '( (ly:message What to do here?) ) (let ((time-sig (ly:engraver-make-grob trans 'TextScript '( (set! tonic (ly:context-property context 'tonic)) (set! sig (ly:context-property context 'keySignature)) (ly:grob-set-property! time-sig 'text (format ~A~A (nona last-pitch) (nona current-pitch))) (set! last-pitch current-pitch) ) ) ; if #t ; if #f not set ) ; fi ))) (stop-translation-timestep . ,(lambda (trans) (set! tonic (ly:make-pitch 0 0 0) ) )) % use this engraver \layout { \context { \Staff \consists #keyT } } % a test score \score { \relative c'' { \key bes \major bes2 a \transposition bes c^we should get a c maj with key cancel. b } \layout { } \midi { } } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
On Tue, Jan 15, 2013 at 10:43 PM, Kieren MacMillan kieren_macmil...@sympatico.ca wrote: There's this: http://lsr.dsi.unimi.it/LSR/Item?id=697 which is useful when the transposition changes mid-piece (like for clarinets, horns, and trumpets). Also you don't have to think about the 'from' pitch. You only need the 'to' pitch. That doesn't seem to handle key signatures very well — is there a workaround? It was a simple change to make it take into account the key signatures. I updated it for the latest version as well (functions should take in pitches directly). I'm used to horn music devoid of key signatures :). \version 2.17.10 #(define (adjust-note mus key currkey) (cond ((or (eq? (ly:music-property mus 'name) 'NoteEvent) (eq? (ly:music-property mus 'name) 'KeyChangeEvent)) (ly:music-transpose mus (car currkey))) ((and (eq? (ly:music-property mus 'name) 'PropertySet) (eq? (ly:music-property mus 'symbol) 'instrumentTransposition)) (set-car! currkey (ly:pitch-negate (ly:music-property mus 'value))) (ly:music-set-property! mus 'value (ly:make-pitch 0 0 0)) mus) (else mus))) normalizeTransposition = #(define-music-function (parser location key music) (ly:pitch? ly:music?) (ly:music-transpose (let ((currkey (list (ly:make-pitch 0 0 0 (music-map (lambda (x) (adjust-note x key currkey)) music)) (ly:pitch-negate key))) music = \relative c' { \time 4/4 \transposition f \key c \major c e g c | \transposition ees \key c \major c, e g c | \transposition g \key c \major c, e g c | } \score { \new Staff { \music } \new Staff { \normalizeTransposition c' \music } \layout {} \midi {} } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
multi-instrument parts
Hello all! Has anyone successfully written multi-instrument player parts correctly (i.e., using \addInstrumentDefinition and \switchInstrument, and not manually \transpose-ing bits)? I would love to see an example, so I can fix my hacks. Even seeing this non-working [in several ways… like why is the cue name doubled?] snippet fixed would be very helpful: \version 2.17.9 \language english \addInstrumentDefinition #flute #`((instrumentTransposition . ,(ly:make-pitch 0 0 0)) (shortInstrumentName . Fl.) (clefGlyph . clefs.G) (middleCPosition . -6) (clefPosition . -2) (instrumentCueName . ,(make-bold-markup fl.)) (midiInstrument . clarinet)) \addInstrumentDefinition #clarinet_bf #`((instrumentTransposition . ,(ly:make-pitch 0 0 -200)) (shortInstrumentName . Cl.) (clefGlyph . clefs.G) (middleCPosition . -6) (clefPosition . -2) (instrumentCueName . ,(make-bold-markup cl.)) (midiInstrument . clarinet)) global = { \key d \major %% flute s1 %% clarinet s1 \key f \major s1 %% flute s1 } windMusic = \relative d' { \instrumentSwitch flute d8 e fs g a b cs d | \instrumentSwitch clarinet_bf d, e fs g a b cs d | d, e fs g a b cs d | \instrumentSwitch flute d, e fs g a b cs d | } \score { \new Staff \global \windMusic } Thanks, Kieren. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
Kieren MacMillan kieren_macmillan at sympatico.ca writes: Has anyone successfully written multi-instrument player parts [...] using \addInstrumentDefinition and \switchInstrument [...] ? Almost certainly not. \addInstrumentDefinition is inconvenient. Google says: No results found for instrumentSwitch site:mutopiaproject.org \addInstrumentDefinition #clarinet_bf #`((instrumentTransposition . ,(ly:make-pitch 0 0 -200)) The third argument to make-pitch is in equal-tempered whole-tones, so you would think you want (ly:make-pitch -1 6 -1/2) for B-flat if instrumentTransposition works like \transposition However, from trial-and-error, it seems instrumentTransposition needs the pitch written for the instrument that /sounds/ concert C, so D for a soprano clarinet (instrumentTransposition . ,(ly:make-pitch 0 1 0)) global = { \key d \major %% flute s1 %% clarinet s1 Setting the transposition in LilyPond tells her that the music sounds at a different pitch than written, for purposes of quoting, cue-ing, and MIDI. Only \transpose changes the pitches that are printed. \score { \new Staff \global \windMusic } The instrumentSwitch applies to the whole Staff, and the instumentCueName is printed for each Voice, in your case it is printed once for \windMusic and once for \global. You could say \new Staff \new Voice \global windMusic Printing for each Voice is silly, so a bug is tracked as issue 2835, but I don't see any way to fix that bug without breaking Reinhold's OrchestraLily system, which explicitly sets the name on a single voice \set Voice.instrumentCueName = Violin So the best I can do is below. The manual method is easier. = \version 2.16.0 \addInstrumentDefinition #flute #`((instrumentTransposition . ,(ly:make-pitch 0 0 0)) (shortInstrumentName . Fl.) (clefGlyph . clefs.G) (middleCPosition . -6) (clefPosition . -2) (instrumentCueName . ,(make-bold-markup fl.)) (midiInstrument . flute)) \addInstrumentDefinition #clarinet_bf #`((instrumentTransposition . ,(ly:make-pitch 0 1 0)) (shortInstrumentName . Cl.) (clefGlyph . clefs.G) (middleCPosition . -6) (clefPosition . -2) (instrumentCueName . ,(make-bold-markup cl.)) (midiInstrument . clarinet)) windMusic = { \instrumentSwitch flute \key d \major \relative d' { d8 e fis g a b cis d } \instrumentSwitch clarinet_bf \transpose bes c' \relative d' { \key d\major d e fis g a b cis d \bar || \key f \major d, e fis g a b cis d } \instrumentSwitch flute \key f \major \relative d' { d e fis g a b cis d } } \score { \new Staff \windMusic \layout {} \midi {} } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
Hi Keith, Thank you so much for the detailed and considered response. Boo. I really wish Lily would Do The Right Thing™ with regard to transposing parts. I want to be able to say \switchInstrument at any time, and easily generate C and transposed scores/parts (with all key signatures automatically included, etc.) without breaking the music into multiple variables, using tags, etc. After my current engraving madnesses wind down, perhaps I'll put together an official feature request… Thanks again! Kieren. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
p.s. It would help immensely if I could at least say \tag #'part { \transpose c d } c4 d e f and then use the tag filter to leave the transposition out of the C-score. However, this doesn't seem to work — any ideas how I can accomplish such a thing (or very similar)? Thanks, Kieren. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
On Tue, 15 Jan 2013 19:41:00 -0800, Kieren MacMillan kieren_macmil...@sympatico.ca wrote: Boo. I really wish Lily would Do The Right Thing™ with regard to transposing parts. I want [...] perhaps I'll put together an official feature request… Almost certainly, \instrumentSwitch was written in response to a similar request. The basic Lilypond structures can do quite a lot by themselves, see below. It would help immensely if I could at least say \tag #'part { \transpose c d } c4 d e f and then use the tag filter to leave the transposition out of the C-score In LilyPond \transpose c d {...} is an action, acting immediately on the music in {...} LilyPond does not store the name of the action separately from the music it is acting upon, so it does not provide a way to remove the action and leave the music. But you can store the music in a variable, and perform the action of transposing only where you need it. music = \relative c' { \transposition c \key bes \major bes4 c d es } clar = \music flute = \music % A bit silly, but everything is clear if they play in unison \new Staff { \flute } % Flute part \new Staff { \transpose bes c' { \clar } } % Clarinet part, transpose for printing \score { % Score in Concert Pitch \new Staff \flute \new Staff \clar } You might see that people often define their variables to store the music in pitches as-written for the different instruments. The manuals encourage storing music in concert pitch, though, which is probably less confusing, at least until you have used LilyPond for a while. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
On Tue, Jan 15, 2013 at 10:21 PM, Keith OHara k-ohara5...@oco.net wrote: On Tue, 15 Jan 2013 19:41:00 -0800, Kieren MacMillan kieren_macmil...@sympatico.ca wrote: Boo. I really wish Lily would Do The Right Thing™ with regard to transposing parts. I want [...] perhaps I'll put together an official feature request… There's this: http://lsr.dsi.unimi.it/LSR/Item?id=697 which is useful when the transposition changes mid-piece (like for clarinets, horns, and trumpets). Also you don't have to think about the 'from' pitch. You only need the 'to' pitch. -Jay ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
Hi Keith, Almost certainly, \instrumentSwitch was written in response to a similar request. If I remember correctly, Han-Wen wrote it and I paid him a bounty for it… =) you can store the music in a variable, and perform the action of transposing only where you need it. Yes, of course, that's what I've been doing — but I consider it hacky, so I was hoping someone had a more elegant solution. You might see that people often define their variables to store the music in pitches as-written for the different instruments. The manuals encourage storing music in concert pitch, though, which is probably less confusing, at least until you have used LilyPond for a while. I've been using it for 10 years now. This piece (Robin Hood: The Legendary Musical Comedy) is simply taxing Lilypond's abilities more than other works I've engraved in the past: 2.5 hours of music theatre for 8 instruments (including 2 multi-instrumentalists), 9 vocal soloists, and a chorus of up to three independent two-part lines. Thanks! Kieren. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
Hi Jay, There's this: http://lsr.dsi.unimi.it/LSR/Item?id=697 which is useful when the transposition changes mid-piece (like for clarinets, horns, and trumpets). Also you don't have to think about the 'from' pitch. You only need the 'to' pitch. That doesn't seem to handle key signatures very well — is there a workaround? Thanks, Kieren. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
On Tue, 15 Jan 2013 21:43:04 -0800, Kieren MacMillan kieren_macmil...@sympatico.ca wrote: I've been using it for 10 years now. Sorry, I've seen so many names they are all a jumble in my head. In that case, for the part where the player switches instruments, you'd probably like to store the as-written pitches along with the transpositions. Then you can use LilyPond's quoting system to get the music in concert pitch for the C-score. windMusic = { ^\markup\bold Flute \transposition c' \key d \major \relative d' { d8( e fis g a b cis d) } ^\markup\bold\concat{ Clarinet in B \flat} \transposition bes \transpose bes c' \relative d' { \tag#'part \key d\major d( e fis g a b cis d) \bar || %% This gets lost, maybe due to a bug \key f \major d,( e fis g a b cis d) } ^\markup\bold Flute \transposition c' \tag#'part \key f \major \relative d' { d( e fis g a b cis d) } } \addQuote wind \keepWithTag#'score \windMusic windMusicInC = \quoteDuring wind #(skip-of-length windMusic ) \new Staff \keepWithTag#'part \windMusic % Part \score { \new Voice \windMusicInC } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
Hi Keith, for the part where the player switches instruments, you'd probably like to store the as-written pitches along with the transpositions. Then you can use LilyPond's quoting system to get the music in concert pitch for the C-score. Now we're getting somewhere! Thanks! I will test this technique with more abstracted setups (e.g., the key signatures in a global variable, shared across multiple multi-instrumentalists), and see how it works. All the best, Kieren. windMusic = { ^\markup\bold Flute \transposition c' \key d \major \relative d' { d8( e fis g a b cis d) } ^\markup\bold\concat{ Clarinet in B \flat} \transposition bes \transpose bes c' \relative d' { \tag#'part \key d\major d( e fis g a b cis d) \bar || %% This gets lost, maybe due to a bug \key f \major d,( e fis g a b cis d) } ^\markup\bold Flute \transposition c' \tag#'part \key f \major \relative d' { d( e fis g a b cis d) } } \addQuote wind \keepWithTag#'score \windMusic windMusicInC = \quoteDuring wind #(skip-of-length windMusic ) \new Staff \keepWithTag#'part \windMusic % Part \score { \new Voice \windMusicInC } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
Hi Keith, for the part where the player switches instruments, you'd probably like to store the as-written pitches along with the transpositions. Then you can use LilyPond's quoting system to get the music in concert pitch for the C-score. Now we're getting somewhere! Thanks! I will test this technique with more abstracted setups (e.g., the key signatures in a global variable, shared across multiple multi-instrumentalists), and see how it works. All the best, Kieren. windMusic = { ^\markup\bold Flute \transposition c' \key d \major \relative d' { d8( e fis g a b cis d) } ^\markup\bold\concat{ Clarinet in B \flat} \transposition bes \transpose bes c' \relative d' { \tag#'part \key d\major d( e fis g a b cis d) \bar || %% This gets lost, maybe due to a bug \key f \major d,( e fis g a b cis d) } ^\markup\bold Flute \transposition c' \tag#'part \key f \major \relative d' { d( e fis g a b cis d) } } \addQuote wind \keepWithTag#'score \windMusic windMusicInC = \quoteDuring wind #(skip-of-length windMusic ) \new Staff \keepWithTag#'part \windMusic % Part \score { \new Voice \windMusicInC } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
Keith OHara k-ohara5...@oco.net writes: On Tue, 15 Jan 2013 21:43:04 -0800, Kieren MacMillan kieren_macmil...@sympatico.ca wrote: I've been using it for 10 years now. Sorry, I've seen so many names they are all a jumble in my head. And you are not even likely to keep confusing Keith with Kieren. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: multi-instrument parts
On Wed, Jan 16, 2013 at 01:48:21AM -0500, Kieren MacMillan wrote: Hi Keith, for the part where the player switches instruments, you'd probably like to store the as-written pitches along with the transpositions. Then you can use LilyPond's quoting system to get the music in concert pitch for the C-score. Now we're getting somewhere! Thanks! I will test this technique with more abstracted setups (e.g., the key signatures in a global variable, shared across multiple multi-instrumentalists), and see how it works. I can't prove it but I believe had conflicts between quoting and tags in a large score. I didn't have time to diagnose it so I just removed a lot of useful cues which would have cluttered the score without tags to remove them from the score. Paul Scott All the best, Kieren. windMusic = { ^\markup\bold Flute \transposition c' \key d \major \relative d' { d8( e fis g a b cis d) } ^\markup\bold\concat{ Clarinet in B \flat} \transposition bes \transpose bes c' \relative d' { \tag#'part \key d\major d( e fis g a b cis d) \bar || %% This gets lost, maybe due to a bug \key f \major d,( e fis g a b cis d) } ^\markup\bold Flute \transposition c' \tag#'part \key f \major \relative d' { d( e fis g a b cis d) } } \addQuote wind \keepWithTag#'score \windMusic windMusicInC = \quoteDuring wind #(skip-of-length windMusic ) \new Staff \keepWithTag#'part \windMusic % Part \score { \new Voice \windMusicInC } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user