lilypond-devel
[Top][All Lists]
Advanced

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

Re: critical issues


From: David Kastrup
Subject: Re: critical issues
Date: Wed, 04 Jan 2012 19:51:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

David Kastrup <address@hidden> writes:

> Janek Warchoł <address@hidden> writes:
>
>>>  \layout {
>>>    \context {
>>>      \Score
>>>      \with \settingsFrom { \compressFullBarRests }
>>>    }
>>>    \context {
>>>      \Staff
>>>      \with \settingsFrom { \accidentalStyle modern }
>>>    }
>>>  }
>>> }
>>> \end{lilypond}
>>>
>>> \ph is a music function written in Scheme.  Can you understand it?
>>
>> Yes, but i get lost on \parallellMusic :(
>
> It's intended for using.  And yes, it likely could be simpler given
> useful APIs for manipulating Scheme.
>
>>> \settingsFrom is actually returning a Scheme expression for \with to
>>> use.  It makes things rather simpler than more complex, even though it
>>> constitutes a Scheme expression.
>>
>> Um... i would really love to be able to type
>>  \layout {
>>      \compressFullBarRests
>>      \override Score.SpacingSpanner #'common-shortest-duration =
>> #(ly:make-moment 6 10)
>>      etc...
>> }
>
> Well, create a layout modification type, let \layout accept Scheme
> expressions of that type, write a Scheme function \layout-from in
> analogue to \settingsFrom, and it becomes
>
> \layout {
>    \layout-from { \compressFullBarRests
>      \override Score.SpacingSpanner #'common-shortest-duration =
>      #(ly:make-moment 6 10)
>    }
>    etc...
> }
>
> Stuff like that is reasonably straightforward to implement.  It would
> have the advantage that you don't have to know what contexts
> \settingsFrom should be placed in.

"layout-from" =
#(define-void-function (parser location music)
   (ly:music?)
   (_i "To be used in output definitions.  Take the layout instruction
events from @var{music} and do the equivalent of context modifications
duplicating their effect.")
   (define (musicop m mods)
     (if (music-is-of-type? m 'layout-instruction-event)
         (ly:add-context-mod
          mods
          (case (ly:music-property m 'name)
            ((PropertySet)
             (list 'assign
                   (ly:music-property m 'symbol)
                   (ly:music-property m 'value)))
            ((PropertyUnset)
             (list 'unset
                   (ly:music-property m 'symbol)))
            ((OverrideProperty)
             (list 'push
                   (ly:music-property m 'symbol)
                   (ly:music-property m 'grob-property-path)
                   (ly:music-property m 'grob-value)))
            ((RevertProperty)
             (list 'pop
                   (ly:music-property m 'symbol)
                   (ly:music-property m 'grob-property-path)))))
         (case (ly:music-property m 'name)
             ((SequentialMusic SimultaneousMusic)
              (for-each (lambda (x)
                          (musicop x mods))
                        (ly:music-property m 'elements)))
             ((ContextSpeccedMusic)
              (module-set! (current-module)
                           (ly:music-property m 'context-type)
                           #{ \context { $(module-ref (current-module)
                                                      (ly:music-property m 
'context-type))
                                         $(musicop (ly:music-property m 
'element)
                                                   (ly:make-context-mod))
                                         } #}))))
     mods)
   (musicop music (ly:make-context-mod)))


It is a bit wonky, but should work for most purposes.

At least it works with

    \layout-from \accidentalStyle "dodecaphonic"

and with the above example.

-- 
David Kastrup




reply via email to

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