lilypond-user
[Top][All Lists]
Advanced

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

Re: Pattern-generating Scheme function challenge


From: Jan-Peter Voigt
Subject: Re: Pattern-generating Scheme function challenge
Date: Wed, 17 Jul 2013 04:05:45 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7

OK, sorry ... I missed the point, you want pattern generation ;)


--snip--

#(use-modules (srfi srfi-60))

#(define-public pattern

(define-music-function (parser location n pitch dur)

(integer? ly:pitch? ly:duration?)

(let ((l (list)))

(define (pat i)

(if (< i n)

(append (pat (* 2 i))

(list

(if (= (bitwise-and i n) 0)

(make-music 'RestEvent 'duration dur)

(make-music 'NoteEvent 'duration dur 'pitch pitch))))

(list)))

(make-music 'SequentialMusic

'elements (pat 1))

)))


\new Staff {

\time 7/2

\pattern #73 c'' 2

}

--snip--


This will create a series of note- and restevents based on the binary pattern of the given integer.


I'll be back next week ;)
HTH

Best, Jan-Peter





reply via email to

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