[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with music-function generating music
From: |
David Kastrup |
Subject: |
Re: Help with music-function generating music |
Date: |
Thu, 27 Mar 2014 09:19:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
Urs Liska <address@hidden> writes:
>> \version "2.18.0"
>>
>> myNotes =
>> #(define-music-function (parser location note num)
>> (ly:music? number?)
>> "Returns a series of notes. @var{note} is repeated @var{num} times.
>> @var{note} is supposed to be a single note."
>> ;; iteration by named let
>> (let loop
>> ;; two variables/arguments,
>> ;; i is the iteration count
>> ;; nts is the list of notes we're building
>> ((i 0)
>> (nts '()))
>>
>> ;; conditional
>> (cond
>> ((< i num)
>> ;; call the loop again with modified values for i and nts
>> (loop
>> (+ i 1)
>> (append nts (list (ly:music-deep-copy note)))))
>>
>> (else
>> ;; when done, return the music
>> (make-music 'SequentialMusic 'elements nts)))))
>>
In this case, it is likely easier to replace the named let with
(make-sequential-music
(ly:music-deep-copy
(make-list num note)))
Which is a bit of a dead end for further manipulation which one would
likely do with map or similar on the list returned by
ly:music-deep-copy.
--
David Kastrup