Hello all,

I tried to write such a function, but failed at the point you’ll see in the attachment. I’d like to learn how this can be made to work ;-) … The problem is in extracting the list from SequentialMusic’s 'element property. And I suspect it has to do with the following question:
With display-music I can obtain:
#<Prob: Music C++: Music((duration . #<Duration 4 >) (pitch . #<Pitch e >) (origin . #<location c:/users/simon/appdata/local/temp/frescobaldi-_4tllv/tmpdndxnp/bgr.ly:25:10>))((display-methods #<procedure #f (note parser)>) (name . NoteEvent) (iterator-ctor . #<primitive-procedure ly:rhythmic-music-iterator::constructor>) (types general-music event note-event rhythmic-event melodic-event)) >

: { ((duration . #<Duration 4 >) (pitch . #<Pitch e >) (origin . #<location c:/users/simon/appdata/local/temp/frescobaldi-_4tllv/tmpdndxnp/bgr.ly:25:10>)) }
and with display-scheme-music:
(make-music

'NoteEvent

'duration

(ly:make-duration 2)

'pitch

(ly:make-pitch -1 2))
What kind of syntax is the first one? And how can I compute one from the other?


Grateful as always for help and with best regards,
Simon


Am 23.10.2014 um 14:05 schrieb Peter Crighton:
Hello all,

I’m taking my very first little steps into Scheme right now by trying to write a function that can make single note heads (and accidentals) in a chord smaller (to differentiate background vocals from lead vocal when writing them all in one voice).


What I have so far is:

bgr = #(define-music-function
        (parser location note)
        (ly:music?)
        #{
          \tweak NoteHead.font-size #-2
          \tweak Accidental.font-size #-2
          #note
        #})

or

bgr = #(define-music-function
         (parser location note)
 (ly:music?)
         (set! (ly:music-property note 'tweaks)
 (cons (cons (cons (quote NoteHead) (quote font-size))
   -2)
 (ly:music-property note 'tweaks)))
         (set! (ly:music-property note 'tweaks)
 (cons (cons (cons (quote Accidental) (quote font-size))
   -2)
 (ly:music-property note 'tweaks)))
         note)

which should be the same.


Here is an example that uses it:

\new Voice <<
  \relative c' {
    c4 d e f
  }

  \relative c' {
    \bgr e4
    \bgr f
    \bgr g
    \bgr a
  }
>>

But I would like to be able to use the function as follows, so it doesn’t only affect the next note, but a sequence of notes enclosed in { … }:

\new Voice <<
  \relative c' {
    c4 d e f
  }

  \relative c' {
    \bgr { e4 f g a }
  }
>>

Can somebody point me in the right direction how to do this?

--
Peter Crighton | Musician & Music Engraver based in Mainz, Germany
http://www.petercrighton.de


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

\version "2.19.12"

bgr = #(define-music-function
        (parser location mus)
        (ly:music?)
        
        ;;;;;;;;; for testing only
        ;(display-scheme-music mus)
        ;mus
        
         (map 
          (lambda (note) (set! (ly:music-property note 'tweaks)
               (list (cons (cons (quote Accidental) (quote font-size))
                      -2)
                (cons (cons (quote NoteHead) (quote font-size))
                      -2))))
          (ly:music-property mus 'elements)))

\new Voice <<
  \relative c' {
    c4 d e f
  }

  \relative c' {
    \bgr e4
    \bgr f
    \bgr g
    \bgr a
  }
>>

\new Voice <<
  \relative c' {
    c4 d e f
  }
  \relative c' {
    \bgr { e4 f g a }
  }
>>
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to