2013/8/31 David Kastrup <[email protected]>: > Thomas Morley <[email protected]> writes: > >> \version "2.17.25" >> >> scalesAndTriads = >> #(define-music-function (parser location m music)(ly:music? ly:music?) >> (let* ((elts (ly:music-property m 'elements)) >> (pitches (map (lambda (x) (ly:music-property x 'pitch)) elts)) >> (pitch-octaves (map (lambda (x) (ly:pitch-octave x)) pitches)) > > (pitch-octaves (map ly:pitch-octave pitches)) > >> (pitch-notename (map (lambda (x) (ly:pitch-notename x)) pitches)) > > (pitch-notename (map ly:pitch-notename pitches)) > >> (pitch-alteration (map (lambda (x) (ly:pitch-alteration x)) >> pitches))) > > guess... > >> #{ >> $(make-simultaneous-music >> (map >> (lambda (octave note alter) >> #{ >> \new Staff >> \transpose c $(ly:make-pitch octave note alter) >> \relative $music >> #}) >> pitch-octaves pitch-notename pitch-alteration)) >> #})) > > What's the point of picking the pitches apart into octave/note/alter and > then assembling them into a pitch again without change? Why not map > over the pitches directly in the first place? > >> } >> >> \scalesAndTriads { c f bes ees aes des ges g d a e b fis } \scale >> >> >> >> Franky, it took me more than two minutes, although I recycled some old >> code for tranposing sequential music, but less than 30 min. >> >> _And_ I now have two functions to reuse again and again: One for >> sequential and another for simultaneous music. > > Why use two? Just do (music-clone m 'origin location 'elements (map ... > > And then you use either > \scalesAndTriads { c f bes ees aes des ges g d a e b fis } > or > \scalesAndTriads << c f bes ees aes des ges g d a e b fis >> > > I'd not use \relative $music here: that looks like asking for trouble. > If people want \relative music, they should spell it out. > > -- > David Kastrup > > > _______________________________________________ > lilypond-user mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/lilypond-user
Hi David, thanks for the hints. Will see how I manage to integrate them. -Harm _______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
