Re: how to split into two parts
Dear Gilles, thanks again for Your explanation! Best, Stefan Am Sa., 23. Apr. 2022 um 22:45 Uhr schrieb Gilles Thibault : > > > I would like to ask You two questions concerning the code, You've > > sended: > > > 1. How does the function noteToRest "know", that the f sharp has to be > > converted to a rest? > > It is not an EventChord, only a NoteEvent > > > 2. Is it possible to to convert > >fis'8 r8 > > to > >r4 > > You can then use "arranger.ly" > > %%% > \version "2.22.0" > > \include "arranger.ly" > > global = { \time 7/8 s8*7*2 } > #(init '(dummy)) > > flutes = { >8 r fis' 8 r 8 r8 r >8 r fis' 8 r r4 } > > noteToRest = #(define-music-function (music) (ly:music?) >(map-some-music > (lambda(evt) > (case (name-of evt) ;; defined in "chordsAndVoices.ly" > ((EventChord) evt) > ((NoteEvent) (make-music 'RestEvent >'duration (ly:music-property evt > 'duration))) > (else #f))) > music)) > > flA = \extractNote #2 \flutes > flB = \extractNote #1 \noteToRest \flutes > > #(rm 'flB '(1 4) #{ r4 #}) > > \score { << >\new Staff << \global \flutes >> >\new Staff << \global \flA >> >\new Staff << \global \flB >> >>> > } > > > > If you want to insert #{ r4 #} in the second beat of several bars, you > can use x-rm > and apply : > > #(apply x-rm 'flB #{ r4 #} (map (lambda(n)(list n 4)) > '(1 3 7 12 19))) % => '((1 4) (3 4) (7 > 4)) > > If the 2 first bars are a rhythmic pattern used a lot of time in the > piece, you would probably prefer to use the function cp (changePitch). > > -- > Gilles >
Re: how to split into two parts
I would like to ask You two questions concerning the code, You've sended: 1. How does the function noteToRest "know", that the f sharp has to be converted to a rest? It is not an EventChord, only a NoteEvent 2. Is it possible to to convert fis'8 r8 to r4 You can then use "arranger.ly" %%% \version "2.22.0" \include "arranger.ly" global = { \time 7/8 s8*7*2 } #(init '(dummy)) flutes = { 8 r fis' 8 r 8 r8 r 8 r fis' 8 r r4 } noteToRest = #(define-music-function (music) (ly:music?) (map-some-music (lambda(evt) (case (name-of evt) ;; defined in "chordsAndVoices.ly" ((EventChord) evt) ((NoteEvent) (make-music 'RestEvent 'duration (ly:music-property evt 'duration))) (else #f))) music)) flA = \extractNote #2 \flutes flB = \extractNote #1 \noteToRest \flutes #(rm 'flB '(1 4) #{ r4 #}) \score { << \new Staff << \global \flutes >> \new Staff << \global \flA >> \new Staff << \global \flB >> >> } If you want to insert #{ r4 #} in the second beat of several bars, you can use x-rm and apply : #(apply x-rm 'flB #{ r4 #} (map (lambda(n)(list n 4)) '(1 3 7 12 19))) % => '((1 4) (3 4) (7 4)) If the 2 first bars are a rhythmic pattern used a lot of time in the piece, you would probably prefer to use the function cp (changePitch). -- Gilles
Re: how to split into two parts
Is there an easy way to get this result automatically? Sorry Stephan, to answer so late. % \version "2.22.0" \include "chordsAndVoices.ly" global = { \time 7/8 } flutes = { \global 8 r fis' 8 r 8 r8 r 8 r fis' 8 r r4 } noteToRest = #(define-music-function (music) (ly:music?) (map-some-music (lambda(evt) (case (name-of evt) ;; defined in "chordsAndVoices.ly" ((EventChord) evt) ((NoteEvent) (make-music 'RestEvent 'duration (ly:music-property evt 'duration))) (else #f))) music)) flA = { \global \extractNote #2 \flutes } flB = { \global \extractNote #1 \noteToRest \flutes } \score { << \new Staff \flutes \new Staff \flA \new Staff \flB >>} Didn't know about the chordsAndVoices http://lsr.di.unimi.it/LSR/Item?u=1&id=545 Download link : http://gillesth.free.fr/Lilypond/chordsAndVoices/ chordsAndVoices.ly is also include in the arranger.ly project : https://github.com/gilles-th/arranger.ly -- Gilles
Re: how to split into two parts
Dear Hans, sorry, it was a mistake of mine. I should have written flA = { \global \extractNote #2 \flutes } flB = { \global \extractNote #1 \flutes } My idea is: if there are 2 pitches at once, they shall be splitted (this works fine), if there is only one sinle, it should be only in the first flute and there should be a rest in the second one. Best, Stefan Am Mo., 18. Apr. 2022 um 13:43 Uhr schrieb Hans Aikema < hans.aik...@aikebah.net>: > > > > On 18 Apr 2022, at 12:23, Stefan Thomas > wrote: > > > > > > Dear community, > > I would like to split the following example into two parts: > > \version "2.22.1" > > global = { \time 7/8 } > > flutes = { > > \global > > 8 r fis' 8 r 8 r8 r > > 8 r fis' 8 r r4 > > } > > I know I can do it with chordsAndVoices.ly > > But the result is the desired only for the first flute. > > Whe I do > > flA = { \global \extractNote #2 \flutes } > > flB = { \global \extractNote #2 \flutes } > > I get > > flA = { \global g'8 r fis' 8 r gis'8 r8 r > > g'8 r fis' gis'8 r r4 > > } % as expexted > > flB = { \global > > f' 8 r fis' 8 r d' 8 r8 r > > f'8 r fis' d'8 r r4 > > } > > But I would like to get for the 2nd flute: > > flB = { \global > > f' 8 r r4 d' 8 r8 r > > f'8 r r d'8 r r4 > > } > > > > Is there an easy way to get this result automatically? > > Thanks, > > Stefan > > Didn't know about the chordsAndVoices, but I do spot that you both times > "\extractNote #2" - which to me seems to instruct to extract the second > note of the chord. > > I expect > flB = { \global \extractNote #1 \flutes } > > to yield you the result you're after > > regards, > Hans > >
Re: how to split into two parts
> On 18 Apr 2022, at 12:23, Stefan Thomas wrote: > > > Dear community, > I would like to split the following example into two parts: > \version "2.22.1" > global = { \time 7/8 } > flutes = { > \global > 8 r fis' 8 r 8 r8 r > 8 r fis' 8 r r4 > } > I know I can do it with chordsAndVoices.ly > But the result is the desired only for the first flute. > Whe I do > flA = { \global \extractNote #2 \flutes } > flB = { \global \extractNote #2 \flutes } > I get > flA = { \global g'8 r fis' 8 r gis'8 r8 r > g'8 r fis' gis'8 r r4 > } % as expexted > flB = { \global > f' 8 r fis' 8 r d' 8 r8 r > f'8 r fis' d'8 r r4 > } > But I would like to get for the 2nd flute: > flB = { \global > f' 8 r r4 d' 8 r8 r > f'8 r r d'8 r r4 > } > > Is there an easy way to get this result automatically? > Thanks, > Stefan Didn't know about the chordsAndVoices, but I do spot that you both times "\extractNote #2" - which to me seems to instruct to extract the second note of the chord. I expect flB = { \global \extractNote #1 \flutes } to yield you the result you're after regards, Hans
Re: how to split into two parts
Hmmm.. nevermind... wasn't reading well.. thought you got twice the same part > On 18 Apr 2022, at 13:43, Hans Aikema wrote: > > > >> On 18 Apr 2022, at 12:23, Stefan Thomas wrote: >> >> >> Dear community, >> I would like to split the following example into two parts: >> \version "2.22.1" >> global = { \time 7/8 } >> flutes = { >> \global >> 8 r fis' 8 r 8 r8 r >> 8 r fis' 8 r r4 >> } >> I know I can do it with chordsAndVoices.ly >> But the result is the desired only for the first flute. >> Whe I do >> flA = { \global \extractNote #2 \flutes } >> flB = { \global \extractNote #2 \flutes } >> I get >> flA = { \global g'8 r fis' 8 r gis'8 r8 r >> g'8 r fis' gis'8 r r4 >> } % as expexted >> flB = { \global >> f' 8 r fis' 8 r d' 8 r8 r >> f'8 r fis' d'8 r r4 >> } >> But I would like to get for the 2nd flute: >> flB = { \global >> f' 8 r r4 d' 8 r8 r >> f'8 r r d'8 r r4 >> } >> >> Is there an easy way to get this result automatically? >> Thanks, >> Stefan > > Didn't know about the chordsAndVoices, but I do spot that you both times > "\extractNote #2" - which to me seems to instruct to extract the second note > of the chord. > > I expect > flB = { \global \extractNote #1 \flutes } > > to yield you the result you're after > > regards, > Hans >
how to split into two parts
Dear community, I would like to split the following example into two parts: \version "2.22.1" global = { \time 7/8 } flutes = { \global 8 r fis' 8 r 8 r8 r 8 r fis' 8 r r4 } I know I can do it with chordsAndVoices.ly But the result is the desired only for the first flute. Whe I do flA = { \global \extractNote #2 \flutes } flB = { \global \extractNote #2 \flutes } I get flA = { \global g'8 r fis' 8 r gis'8 r8 r g'8 r fis' gis'8 r r4 } % as expexted flB = { \global f' 8 r fis' 8 r d' 8 r8 r f'8 r fis' d'8 r r4 } But I would like to get for the 2nd flute: flB = { \global f' 8 r r4 d' 8 r8 r f'8 r r d'8 r r4 } Is there an easy way to get this result automatically? Thanks, Stefan