lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problems trying to write a conditional \transpose


From: Mark Polesky
Subject: problems trying to write a conditional \transpose
Date: Mon, 5 Aug 2013 20:16:15 -0700 (PDT)

Hi.

I'm trying to write a conditional version of the \transpose
function, that would work something like this:

input = { 
  c c 
  \conditionalTransposition c c' { c c }
}

\input
=> { c c c c }

\processConditionalTransposition \input
=> { c c c' c' }

********************

And I've hit another brick wall.  I experimented with some
of the functions in music-functions.scm (map-some-music,
fold-some-music, etc.), but those hard-to-follow function
descriptions slowed me down again.  I've included some vain
attempts below, which are clearly wrong...

Any advice?

Thanks
- Mark

********************

conditionalTranspose = 
#(define-music-function
   (parser location from to music)
   (ly:pitch? ly:pitch? ly:music?)
   (set! music
     (make-sequential-music
       (list (make-music 
               'Music
               'type 'conditional-transposition
               'from from
               'to   to)
             music)))
   music)

#(define conditional-transposition?
   (lambda (music)
     (eq? (ly:music-property music 'type) 'conditional-transposition)))

#(define sequential-music?
   (lambda (music)
     (music-is-of-type? music 'sequential-music)))

processConditionalTransposition =
#(define-music-function
   (parser location music)
   (ly:music?)
   (let ((music-list (extract-typed-music music '(general-music))))
     (if (list? music-list)
       (for-each (lambda (a b)
                   (if (and (conditional-transposition? a)
                            (sequential-music? b))
                     (ly:music-transpose b ...)))
                 music-list 
                 (cdr music-list)))
     music))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]