lilypond-user
[Top][All Lists]
Advanced

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

Re: Pairing/Combining Two Sequences Together--Feature request


From: David Raleigh Arnold
Subject: Re: Pairing/Combining Two Sequences Together--Feature request
Date: Thu, 6 Jun 2002 07:20:41 +0000

On Thu, 06 Jun 2002 07:52:31 Han-Wen wrote:
address@hidden writes:
> 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?

 (ly-get-mus-property mus 'elements) returns a possibly non-empty list
 of music objects.

 (ly-get-mus-property mus 'element) returns () or a music object.

You should always recurse on both, since constructs like \context
Voice layer  another Music object over their arguments.

> 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?

Repeats happen in interpreting, i.e. after \apply is done, so what you
want can not be done. Better write two functions

        (apply-duration-to-note mus dur)

and

        (apply-durations-to-sequence muslist durlist)

use these  to write a function that  is called like

    \apply #(lambda (x) (apply-durations-to-sequence
    (ly-get-mus-property x 'elements) (list
                         (make-duration 2 1) ;; dotted quarter
                         (make-duration 3 0) ;; eighth
                        ))

The apply-durations-to-sequence should loop through its 2nd argument
for setting durations.  When you go this route, be sure to be careful
with nesting other music in the { } .

Btw, if you finish the code, could we include it in the examples?

I want to suggest the use of placeholders to make the \notes easier to
read and maintain.

a b b c d d e *8. *16 *8 * * * * becomes

a8. b16 b8 b c d d e

If you are willing to move your notes out of the .ly file,
which is a very good idea,  this
can easily be processed with sed.

# this plugin routine replaces gub gub re* * with regub gub
# skip ** if two and write one * fter this procedure.
s/\*\*/TwoAsterisksWriteOne/g
:again
/\*/{
s/\([^ ]*\)[^\*]*\*/&\1/
s/[^ ]*//
s/^ //g
s/\*//
t again
}
s/TwoAsterisksWriteOne/\*/g

----------------------------------------------
Here is an example of an .ly file with a separate score:

% here we have flowing2.ly:

\header {
        title = "The river is flowing"
        composer = "Traditonal (?)"
}
\include "paper16.ly"

\score {
        \simultaneous {
          % accompaniment--chordnames
                \context ChordNames \chords {
                \include "flowing2-pt1.ly" }
        \addlyrics
% melody \context Staff = mel { \property Staff.noAutoBeaming = ##t
                \property Staff.automaticMelismata = ##t
                \notes \relative c' { \include "flowing2-pt2.ly" }
             }
             % lyrics
             \context Lyrics \lyrics { \include "flowing2-pt3.ly" }
             }
        \midi  { }
        \paper { linewidth = 10.0\cm }
}

% and here we have flowing2, the notes.  If you copy this into two
% files and run ./petals flowing2, running ly2dvi on either the
% original flowing.ly (by Han-Wen, in the tutorial) or
% flowing2.ly will produce the same score. The score should start with r8,
% not this comment.
% The field separator is " |" not "|" .

r8 | \partial 8 g8 | The c2:3- f:3-.7 | c4 c8 d [es () d] c4 | ri -- ver is flo- __ wing, d:min es4 c8:min r8 | f4 f8 g [es() d] c g | flo -- wing and gro -- wing, the c2:min f:min7 | c4 c8 d [es () d] c4 | ri -- ver is flo -- wing g:7^3.5 c:min | d4 es8 d c4. \bar "|." | down to the sea.


-----------cut here
Of course it's not petals anymore, that
name is taken by rosegarden.  ly-parts?
I just finished a simple song 64 bars
long.  Each line in the editor is a measure
but you can find the measure by the
lyrics.  Of course I could have put all the
lyrics on one line, but that wouldn't
be a very good idea, would it?  Also
lilypond has no problem finding the
line number in the score part, which is
the same as the line number in your score.
It would be easy to put half a measure or two
measures on each line instead.  Barchecks could
be used for a particular part by doing a matrix
transposition of the part, putting it all on a
single line.  I have never found them useful.
Finding errors is very easy, which is really great.  :-)


=========== Request for feature change
BTW, IMHO midiInstrument should be a
voice property, so that harmonics
could be entered among other things.
Sorry if it's already done.  In
1.4.13 it does not work properly as a
Voice property.  I don't understand why
there is a warning if one uses a different
midi instrument(s) from what's
printed in the output anyway.  What is the point?
So please junk this:
\property Staff.midiInstrument = #"melodic tom"   For this:
\property Voice.midiInstrument = #"melodic tom"

=========================
When I get back to ly-parts I will modify ly-tidy
(aligns parts) and ly-mate (performs matrix transposition)
so they work better in emacs-xemacs.  I did
not align those |'s by hand even so.  I didn't know how
easy it is to run a shell script in an emacs buffer and
save the result.
 ------------------------------------------------------------
Information is not knowledge.           Belief is not truth.
Indoctrination is not teaching.   Tradition is not evidence.
         David Raleigh Arnold   address@hidden


reply via email to

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