sg2002

filterChordChanges

Oct 6th, 2018
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 1.35 KB | None | 0 0
  1. \version "2.19.82"
  2.  
  3. #(define (filterChanges music)
  4.    (let ((es (ly:music-property music 'elements))
  5.          (e (ly:music-property music 'element))
  6.          (p (ly:music-property music 'pitch)))
  7.      (if (and
  8.           (pair? es)
  9.           (not
  10.            (music-is-of-type? music 'event-chord)))
  11.          (ly:music-set-property!
  12.           music 'elements
  13.           (map (lambda (x) (filterChanges x)) es)))
  14.      (if (ly:music? e)
  15.          (ly:music-set-property!
  16.           music 'element
  17.           (filterChanges e)))
  18.      (if (and (not (pair? es))
  19.               (music-is-of-type? music 'event-chord))
  20.          (set! music (make-music
  21.                         'RestEvent
  22.                         'duration
  23.                         (ly:music-property music 'duration))))
  24.  
  25.      (if (ly:pitch? p)
  26.          (begin
  27.            (set! music (make-music
  28.                         'RestEvent
  29.                         'duration
  30.                         (ly:music-property music 'duration)))))
  31.      music))
  32.  
  33. filterChordChanges =
  34. #(define-music-function (parser location m)
  35.      (ly:music?)
  36.    (filterChanges m))
  37.  
  38. music = { d \chordmode { d:m/a } f, q d q f, q  e, \chordmode { e:7^5/gis }  gis, q e, q gis, q }
  39.  
  40. \new Staff { \clef "bass"
  41.   <<
  42.     \new ChordNames {
  43.       \set noChordSymbol = ""
  44.       \filterChordChanges \music
  45.   }
  46.   \music
  47.   >>
  48. }
Advertisement
Add Comment
Please, Sign In to add comment