lilypond-user
[Top][All Lists]
Advanced

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

Re: Pairing/Combining Two Sequences Together


From: Mats Bengtsson
Subject: Re: Pairing/Combining Two Sequences Together
Date: Fri, 07 Jun 2002 00:10:55 +0200

Take a look at the example file input/test/music-box.ly
in the distribution. I think it does more or less what
you're trying to achieve.

  /Mats


> Does anyone know how to perform an operation (using the Guile
> interpreter) that combines two sequences of notes?  I'm not entirely
> sure how to iterate from note to note, and I'm not sure how to get at
> the notes after they have been evaluated for unfolding repeats.
> 
> I wanted to pair two sequences of music together so that I could avoid
> redundant durations.
> 
> This:
> 
> ---
> music = \notes \context Voice \relative c' { c d e f g a b c }
> myduration = \notes \repeat unfold 4 { s4. s8 }
> 
> \apply #combine-dur { \music \myduration }
> ---
> 
> Should result in about the same thing as this:
> 
> ---
> \notes \context Voice \relative c' { c4. d8 e4. f8 g4. a8 b4. c8 }
> ---
> 
> Just to test things, I defined the function 'combine-dur' like this:
> 
> ---
> #(define (combine-dur x)
>       (display "\n===\n")
>     (let ((a (ly-get-mus-property x 'elements)))
>         (display (car a))
>       (display "\n===\n")
>       (display (cadr a))
>     )
>       x)
> ---
> 
> I noticed by looking at what displayed that (car a) was the
> \myduration sequence and (cadr a) was \music.  However, the two
> resulting sequences do not act like ordinary lists, and normal mapping
> functions do not work.  In addition, (car a) is the unevaluated form
> of \myduration, with information about how many times to repeat but the
> repeats themselves not unfolded.
> 
> At this point I'm at a total loss.  Are (car a) and (cadr a) both
> valid types of music?  If so, why do they return () for every call to
> ly-get-mus-property?  Can I evaluate nested sequences like nested
> lists?  Is there a better way to do all this?
> 
> I spent a few hours looking through the documentation, and I searched
> a while on the mailing list archives, and I couldn't find a similar
> question.  The music-reversal example was informative, but it doesn't
> deal with sequences inside of sequences and post-unfold-evaluation.
> 
> 
> Starling
> 
> _______________________________________________
> Lilypond-user mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/lilypond-user




reply via email to

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