lilypond-user
[Top][All Lists]
Advanced

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

Pairing/Combining Two Sequences Together


From: Starling
Subject: Pairing/Combining Two Sequences Together
Date: Wed, 05 Jun 2002 13:52:38 -0700
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

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



reply via email to

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